| 1 | package Finance::Robinhood::Forex::Currency; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | =encoding utf-8 | ||||||||||||||||||
| 4 | |||||||||||||||||||
| 5 | =for stopwords watchlist watchlists untradable urls | ||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | Finance::Robinhood::Forex::Currency - Represents a Single Forex Currency | ||||||||||||||||||
| 10 | Watchlist | ||||||||||||||||||
| 11 | |||||||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | use Finance::Robinhood; | ||||||||||||||||||
| 15 | my $rh = Finance::Robinhood->new; | ||||||||||||||||||
| 16 | |||||||||||||||||||
| 17 | # TODO | ||||||||||||||||||
| 18 | |||||||||||||||||||
| 19 | =cut | ||||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | 1 | our $VERSION = '0.92_003'; | |||||||||||||||||
| 22 | 1 | ▶ | use Mojo::Base-base, -signatures; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 23 | 1 | ▶ | use Mojo::URL; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 24 | 1 | ▶ | use Finance::Robinhood::Forex::Quote; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 25 | |||||||||||||||||||
| 26 | 1 | ▶ | sub _test__init { | ||||||||||||||||
|
Subroutine
_test__init: called CC=1 SCAR=3.5
| |||||||||||||||||||
| 27 | 1 | my $rh = t::Utility::rh_instance(1); | |||||||||||||||||
| 28 | 0 | my $btc | |||||||||||||||||
| 29 | = $rh->forex_currency_by_id('d674efea-e623-4396-9026-39574b92b093') | ||||||||||||||||||
| 30 | ; # BTC | ||||||||||||||||||
| 31 | 0 | isa_ok($btc, __PACKAGE__); | |||||||||||||||||
| 32 | 0 | t::Utility::stash('CURRENCY', $btc); # Store it for later | |||||||||||||||||
| 33 | } | ||||||||||||||||||
| 34 | 0 | ▶ | use overload '""' => sub ($s, @) { $s->{id} }, fallback => 1; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||
| 35 | |||||||||||||||||||
| 36 | 1 | ▶ | sub _test_stringify { | ||||||||||||||||
|
Subroutine
_test_stringify: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 37 | 1 | ▶ | t::Utility::stash('CURRENCY') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("CURRENCY") // skip_all()
MC/DC0%0/2
t::Utility::stash("CURRENCY") // skip_all()
t::Utility::stash("CURRENCY")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("CURRENCY")B= skip_all()
| |||||||||||||||||||
| 38 | 0 | like(+t::Utility::stash('CURRENCY'), | |||||||||||||||||
| 39 | qr'^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'i | ||||||||||||||||||
| 40 | ); | ||||||||||||||||||
| 41 | } | ||||||||||||||||||
| 42 | # | ||||||||||||||||||
| 43 | 1 | has _rh => undef => weak => 1; | |||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | =head1 METHODS | ||||||||||||||||||
| 46 | |||||||||||||||||||
| 47 | =head2 C<brand_color( )> | ||||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | If defined, this returns a hex color code used for display. | ||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | =head2 C<code( )> | ||||||||||||||||||
| 52 | |||||||||||||||||||
| 53 | Short code used to represent this currency for display. 'USD', for example. | ||||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | =head2 C<id( )> | ||||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | Returns a UUID. | ||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | =head2 C<increment( )> | ||||||||||||||||||
| 60 | |||||||||||||||||||
| 61 | The increment used as a minimum for display, etc. For example, USD would return | ||||||||||||||||||
| 62 | C<0.01> to prevent sub-penny price display. | ||||||||||||||||||
| 63 | |||||||||||||||||||
| 64 | =head2 C<name( )> | ||||||||||||||||||
| 65 | |||||||||||||||||||
| 66 | Returns a string suited for display. And example would be 'US Dollar'. | ||||||||||||||||||
| 67 | |||||||||||||||||||
| 68 | =head2 C<type( )> | ||||||||||||||||||
| 69 | |||||||||||||||||||
| 70 | This is the asset type. Currently, C<fiat> or C<cryptocurrency>. | ||||||||||||||||||
| 71 | |||||||||||||||||||
| 72 | =cut | ||||||||||||||||||
| 73 | |||||||||||||||||||
| 74 | 1 | has ['brand_color', 'code', 'id', 'increment', 'name', 'type']; | |||||||||||||||||
| 75 | |||||||||||||||||||
| 76 | =head2 C<news( )> | ||||||||||||||||||
| 77 | |||||||||||||||||||
| 78 | my $news = $currency->news; | ||||||||||||||||||
| 79 | |||||||||||||||||||
| 80 | Returns an iterator containing Finance::Robinhood::News elements. | ||||||||||||||||||
| 81 | |||||||||||||||||||
| 82 | =cut | ||||||||||||||||||
| 83 | |||||||||||||||||||
| 84 | 0 | ▶ | sub news ($s) { $s->_rh->news($s->id) } | ||||||||||||||||
|
Subroutine
news: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 85 | |||||||||||||||||||
| 86 | 1 | ▶ | sub _test_news { | ||||||||||||||||
|
Subroutine
_test_news: called CC=2 SCAR=11.6
| |||||||||||||||||||
| 87 | 1 | ▶ | t::Utility::stash('CURRENCY') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("CURRENCY") // skip_all()
MC/DC0%0/2
t::Utility::stash("CURRENCY") // skip_all()
t::Utility::stash("CURRENCY")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("CURRENCY")B= skip_all()
| |||||||||||||||||||
| 88 | 0 | my $news = t::Utility::stash('CURRENCY')->news; | |||||||||||||||||
| 89 | 0 | isa_ok($news, 'Finance::Robinhood::Utilities::Iterator'); | |||||||||||||||||
| 90 | 0 | isa_ok($news->current, 'Finance::Robinhood::News'); | |||||||||||||||||
| 91 | } | ||||||||||||||||||
| 92 | |||||||||||||||||||
| 93 | =head2 C<pair( )> | ||||||||||||||||||
| 94 | |||||||||||||||||||
| 95 | my $pair = $currency->pair; | ||||||||||||||||||
| 96 | |||||||||||||||||||
| 97 | Returns a Finance::Robinhood::Forex::Pair object. | ||||||||||||||||||
| 98 | |||||||||||||||||||
| 99 | =cut | ||||||||||||||||||
| 100 | |||||||||||||||||||
| 101 | 0 | ▶ | sub pair ($s) { | ||||||||||||||||
|
Subroutine
pair: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 102 | my ($retval) | ||||||||||||||||||
| 103 | 0 | = grep { $_->asset_currency->id eq $s->id } $s->_rh->forex_pairs->all; | |||||||||||||||||
| 104 | 0 | $retval; | |||||||||||||||||
| 105 | } | ||||||||||||||||||
| 106 | |||||||||||||||||||
| 107 | 1 | ▶ | sub _test_pairs { | ||||||||||||||||
|
Subroutine
_test_pairs: called CC=2 SCAR=10.5
| |||||||||||||||||||
| 108 | 1 | ▶ | t::Utility::stash('CURRENCY') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("CURRENCY") // skip_all()
MC/DC0%0/2
t::Utility::stash("CURRENCY") // skip_all()
t::Utility::stash("CURRENCY")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("CURRENCY")B= skip_all()
| |||||||||||||||||||
| 109 | 0 | my $pair = t::Utility::stash('CURRENCY')->pair; | |||||||||||||||||
| 110 | 0 | isa_ok($pair, 'Finance::Robinhood::Forex::Pair'); | |||||||||||||||||
| 111 | } | ||||||||||||||||||
| 112 | |||||||||||||||||||
| 113 | =head1 LEGAL | ||||||||||||||||||
| 114 | |||||||||||||||||||
| 115 | This is a simple wrapper around the API used in the official apps. The author | ||||||||||||||||||
| 116 | provides no investment, legal, or tax advice and is not responsible for any | ||||||||||||||||||
| 117 | damages incurred while using this software. This software is not affiliated | ||||||||||||||||||
| 118 | with Robinhood Financial LLC in any way. | ||||||||||||||||||
| 119 | |||||||||||||||||||
| 120 | For Robinhood's terms and disclosures, please see their website at | ||||||||||||||||||
| 121 | https://robinhood.com/legal/ | ||||||||||||||||||
| 122 | |||||||||||||||||||
| 123 | =head1 LICENSE | ||||||||||||||||||
| 124 | |||||||||||||||||||
| 125 | Copyright (C) Sanko Robinson. | ||||||||||||||||||
| 126 | |||||||||||||||||||
| 127 | This library is free software; you can redistribute it and/or modify it under | ||||||||||||||||||
| 128 | the terms found in the Artistic License 2. Other copyrights, terms, and | ||||||||||||||||||
| 129 | conditions may apply to data transmitted through this module. Please refer to | ||||||||||||||||||
| 130 | the L<LEGAL> section. | ||||||||||||||||||
| 131 | |||||||||||||||||||
| 132 | =head1 AUTHOR | ||||||||||||||||||
| 133 | |||||||||||||||||||
| 134 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||||||||||||||||||
| 135 | |||||||||||||||||||
| 136 | =cut | ||||||||||||||||||
| 137 | |||||||||||||||||||
| 138 | 1 | 1; | |||||||||||||||||