| 1 | package Finance::Robinhood::Forex::Holding; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | =encoding utf-8 | ||||||||||||||||||
| 4 | |||||||||||||||||||
| 5 | =for stopwords watchlist watchlists untradable urls forex | ||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | Finance::Robinhood::Forex::Holding - Represents a Single Forex Currency Holding | ||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | use Finance::Robinhood; | ||||||||||||||||||
| 14 | my $rh = Finance::Robinhood->new; | ||||||||||||||||||
| 15 | |||||||||||||||||||
| 16 | # TODO | ||||||||||||||||||
| 17 | |||||||||||||||||||
| 18 | =cut | ||||||||||||||||||
| 19 | |||||||||||||||||||
| 20 | 1 | our $VERSION = '0.92_003'; | |||||||||||||||||
| 21 | 1 | ▶ | use Mojo::Base-base, -signatures; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 22 | 1 | ▶ | use Mojo::URL; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 23 | 1 | ▶ | use Finance::Robinhood::Forex::Currency; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 24 | 1 | ▶ | use Finance::Robinhood::Forex::Cost; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 25 | 1 | ▶ | use Time::Moment; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 26 | |||||||||||||||||||
| 27 | 1 | ▶ | sub _test__init { | ||||||||||||||||
|
Subroutine
_test__init: called CC=1 SCAR=3.5
| |||||||||||||||||||
| 28 | 1 | my $rh = t::Utility::rh_instance(1); | |||||||||||||||||
| 29 | 0 | my $holding = $rh->forex_holdings->current; | |||||||||||||||||
| 30 | 0 | isa_ok($holding, __PACKAGE__); | |||||||||||||||||
| 31 | 0 | t::Utility::stash('HOLDING', $holding); # Store it for later | |||||||||||||||||
| 32 | } | ||||||||||||||||||
| 33 | 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
| |||||||||||||||||||
| 34 | |||||||||||||||||||
| 35 | 1 | ▶ | sub _test_stringify { | ||||||||||||||||
|
Subroutine
_test_stringify: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 36 | 1 | ▶ | t::Utility::stash('HOLDING') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("HOLDING") // skip_all()
MC/DC0%0/2
t::Utility::stash("HOLDING") // skip_all()
t::Utility::stash("HOLDING")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("HOLDING")B= skip_all()
| |||||||||||||||||||
| 37 | 0 | like(+t::Utility::stash('HOLDING'), | |||||||||||||||||
| 38 | 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 | ||||||||||||||||||
| 39 | ); | ||||||||||||||||||
| 40 | } | ||||||||||||||||||
| 41 | # | ||||||||||||||||||
| 42 | 1 | has _rh => undef => weak => 1; | |||||||||||||||||
| 43 | |||||||||||||||||||
| 44 | =head1 METHODS | ||||||||||||||||||
| 45 | |||||||||||||||||||
| 46 | |||||||||||||||||||
| 47 | =head2 C<id( )> | ||||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | Returns a UUID. | ||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | =head2 C<quantity( )> | ||||||||||||||||||
| 52 | |||||||||||||||||||
| 53 | Total asset size. | ||||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | =head2 C<quantity_available( )> | ||||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | Amount not being held for outstanding orders. | ||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | =head2 C<quantity_held_for_buy( )> | ||||||||||||||||||
| 60 | |||||||||||||||||||
| 61 | Amount being held for outstanding buy orders. | ||||||||||||||||||
| 62 | |||||||||||||||||||
| 63 | =head2 C<quantity_held_for_sell( )> | ||||||||||||||||||
| 64 | |||||||||||||||||||
| 65 | Amount being held for outstanding sell orders. | ||||||||||||||||||
| 66 | |||||||||||||||||||
| 67 | =cut | ||||||||||||||||||
| 68 | |||||||||||||||||||
| 69 | 1 | has ['id', 'quantity', | |||||||||||||||||
| 70 | 'quantity_available', 'quantity_held_for_buy', | ||||||||||||||||||
| 71 | 'quantity_held_for_sell' | ||||||||||||||||||
| 72 | ]; | ||||||||||||||||||
| 73 | |||||||||||||||||||
| 74 | =head2 C<currency( )> | ||||||||||||||||||
| 75 | |||||||||||||||||||
| 76 | Returns a Finance::Robinhood::Forex::Currency object. | ||||||||||||||||||
| 77 | |||||||||||||||||||
| 78 | =cut | ||||||||||||||||||
| 79 | |||||||||||||||||||
| 80 | 0 | ▶ | sub currency ($s) { | ||||||||||||||||
|
Subroutine
currency: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 81 | Finance::Robinhood::Forex::Currency->new(_rh => $s->_rh, | ||||||||||||||||||
| 82 | 0 | %{$s->{currency}}); | |||||||||||||||||
| 83 | } | ||||||||||||||||||
| 84 | |||||||||||||||||||
| 85 | 1 | ▶ | sub _test_currency { | ||||||||||||||||
|
Subroutine
_test_currency: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 86 | 1 | ▶ | t::Utility::stash('HOLDING') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("HOLDING") // skip_all()
MC/DC0%0/2
t::Utility::stash("HOLDING") // skip_all()
t::Utility::stash("HOLDING")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("HOLDING")B= skip_all()
| |||||||||||||||||||
| 87 | 0 | isa_ok(t::Utility::stash('HOLDING')->currency, | |||||||||||||||||
| 88 | 'Finance::Robinhood::Forex::Currency'); | ||||||||||||||||||
| 89 | } | ||||||||||||||||||
| 90 | |||||||||||||||||||
| 91 | =head2 C<created_at( )> | ||||||||||||||||||
| 92 | |||||||||||||||||||
| 93 | Returns a Time::Moment object. | ||||||||||||||||||
| 94 | |||||||||||||||||||
| 95 | =cut | ||||||||||||||||||
| 96 | |||||||||||||||||||
| 97 | 0 | ▶ | sub created_at ($s) { | ||||||||||||||||
|
Subroutine
created_at: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 98 | 0 | Time::Moment->from_string($s->{created_at}); | |||||||||||||||||
| 99 | } | ||||||||||||||||||
| 100 | |||||||||||||||||||
| 101 | 1 | ▶ | sub _test_created_at { | ||||||||||||||||
|
Subroutine
_test_created_at: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 102 | 1 | ▶ | t::Utility::stash('HOLDING') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("HOLDING") // skip_all()
MC/DC0%0/2
t::Utility::stash("HOLDING") // skip_all()
t::Utility::stash("HOLDING")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("HOLDING")B= skip_all()
| |||||||||||||||||||
| 103 | 0 | isa_ok(t::Utility::stash('HOLDING')->created_at, 'Time::Moment'); | |||||||||||||||||
| 104 | } | ||||||||||||||||||
| 105 | |||||||||||||||||||
| 106 | =head2 C<updated_at( )> | ||||||||||||||||||
| 107 | |||||||||||||||||||
| 108 | Returns a Time::Moment object. | ||||||||||||||||||
| 109 | |||||||||||||||||||
| 110 | =cut | ||||||||||||||||||
| 111 | |||||||||||||||||||
| 112 | 0 | ▶ | sub updated_at ($s) { | ||||||||||||||||
|
Subroutine
updated_at: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 113 | 0 | Time::Moment->from_string($s->{updated_at}); | |||||||||||||||||
| 114 | } | ||||||||||||||||||
| 115 | |||||||||||||||||||
| 116 | 1 | ▶ | sub _test_updated_at { | ||||||||||||||||
|
Subroutine
_test_updated_at: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 117 | 1 | ▶ | t::Utility::stash('PAIR') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("PAIR") // skip_all()
MC/DC0%0/2
t::Utility::stash("PAIR") // skip_all()
t::Utility::stash("PAIR")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("PAIR")B= skip_all()
| |||||||||||||||||||
| 118 | 0 | isa_ok(t::Utility::stash('PAIR')->updated_at, 'Time::Moment'); | |||||||||||||||||
| 119 | } | ||||||||||||||||||
| 120 | |||||||||||||||||||
| 121 | =head2 C<account( )> | ||||||||||||||||||
| 122 | |||||||||||||||||||
| 123 | my $acct = $holding->account(); | ||||||||||||||||||
| 124 | |||||||||||||||||||
| 125 | Returns a Finance::Robinhood::Forex::Account object. | ||||||||||||||||||
| 126 | |||||||||||||||||||
| 127 | =cut | ||||||||||||||||||
| 128 | |||||||||||||||||||
| 129 | 0 | ▶ | sub account ($s) { | ||||||||||||||||
|
Subroutine
account: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 130 | 0 | $s->_rh->forex_account_by_id($s->{account_id}); | |||||||||||||||||
| 131 | } | ||||||||||||||||||
| 132 | |||||||||||||||||||
| 133 | 1 | ▶ | sub _test_account { | ||||||||||||||||
|
Subroutine
_test_account: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 134 | 1 | ▶ | t::Utility::stash('HOLDING') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("HOLDING") // skip_all()
MC/DC0%0/2
t::Utility::stash("HOLDING") // skip_all()
t::Utility::stash("HOLDING")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("HOLDING")B= skip_all()
| |||||||||||||||||||
| 135 | 0 | isa_ok(t::Utility::stash('HOLDING')->account(), | |||||||||||||||||
| 136 | 'Finance::Robinhood::Forex::Account'); | ||||||||||||||||||
| 137 | } | ||||||||||||||||||
| 138 | |||||||||||||||||||
| 139 | =head2 C<cost_bases( )> | ||||||||||||||||||
| 140 | |||||||||||||||||||
| 141 | Returns a list of Finance::Robinhood::Forex::Holding::Cost objects. | ||||||||||||||||||
| 142 | |||||||||||||||||||
| 143 | =cut | ||||||||||||||||||
| 144 | |||||||||||||||||||
| 145 | 0 | ▶ | sub cost_bases ($s) { | ||||||||||||||||
|
Subroutine
cost_bases: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 146 | 0 | map { Finance::Robinhood::Forex::Cost->new(_rh => $s->_rh, %{$_}); } | |||||||||||||||||
| 147 | 0 | @{$s->{cost_bases}}; | |||||||||||||||||
| 148 | } | ||||||||||||||||||
| 149 | |||||||||||||||||||
| 150 | 1 | ▶ | sub _test_cost_bases { | ||||||||||||||||
|
Subroutine
_test_cost_bases: called CC=3 SCAR=19.2
| |||||||||||||||||||
| 151 | 1 | ▶ | t::Utility::stash('HOLDING') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("HOLDING") // skip_all()
MC/DC0%0/2
t::Utility::stash("HOLDING") // skip_all()
t::Utility::stash("HOLDING")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("HOLDING")B= skip_all()
| |||||||||||||||||||
| 152 | 0 | my ($cost_base) = t::Utility::stash('HOLDING')->cost_bases(); | |||||||||||||||||
| 153 | 0 | ▶ | $cost_base || skip_all('No currency holdings with defined cost bases.'); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 154 | 0 | isa_ok($cost_base, 'Finance::Robinhood::Forex::Cost'); | |||||||||||||||||
| 155 | } | ||||||||||||||||||
| 156 | |||||||||||||||||||
| 157 | =head1 LEGAL | ||||||||||||||||||
| 158 | |||||||||||||||||||
| 159 | This is a simple wrapper around the API used in the official apps. The author | ||||||||||||||||||
| 160 | provides no investment, legal, or tax advice and is not responsible for any | ||||||||||||||||||
| 161 | damages incurred while using this software. This software is not affiliated | ||||||||||||||||||
| 162 | with Robinhood Financial LLC in any way. | ||||||||||||||||||
| 163 | |||||||||||||||||||
| 164 | For Robinhood's terms and disclosures, please see their website at | ||||||||||||||||||
| 165 | https://robinhood.com/legal/ | ||||||||||||||||||
| 166 | |||||||||||||||||||
| 167 | =head1 LICENSE | ||||||||||||||||||
| 168 | |||||||||||||||||||
| 169 | Copyright (C) Sanko Robinson. | ||||||||||||||||||
| 170 | |||||||||||||||||||
| 171 | This library is free software; you can redistribute it and/or modify it under | ||||||||||||||||||
| 172 | the terms found in the Artistic License 2. Other copyrights, terms, and | ||||||||||||||||||
| 173 | conditions may apply to data transmitted through this module. Please refer to | ||||||||||||||||||
| 174 | the L<LEGAL> section. | ||||||||||||||||||
| 175 | |||||||||||||||||||
| 176 | =head1 AUTHOR | ||||||||||||||||||
| 177 | |||||||||||||||||||
| 178 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||||||||||||||||||
| 179 | |||||||||||||||||||
| 180 | =cut | ||||||||||||||||||
| 181 | |||||||||||||||||||
| 182 | 1 | 1; | |||||||||||||||||