| 1 | package Finance::Robinhood::Equity::Account; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | =encoding utf-8 | ||||||||||||||||||
| 4 | |||||||||||||||||||
| 5 | =for stopwords watchlist watchlists untradable urls | ||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | Finance::Robinhood::Equity::Account - Represents a Single Robinhood Account | ||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | use Finance::Robinhood; | ||||||||||||||||||
| 14 | my $rh = Finance::Robinhood->new->login('user', 'pass'); | ||||||||||||||||||
| 15 | my $account = $rh->equity_accounts->current(); | ||||||||||||||||||
| 16 | |||||||||||||||||||
| 17 | CORE::say sprintf '$%0.2f of $%0.2f can be withdrawn', | ||||||||||||||||||
| 18 | $account->cash_available_for_withdrawal, | ||||||||||||||||||
| 19 | $account->cash; | ||||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | =cut | ||||||||||||||||||
| 22 | |||||||||||||||||||
| 23 | 1 | our $VERSION = '0.92_003'; | |||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | 1 | ▶ | sub _test__init { | ||||||||||||||||
|
Subroutine
_test__init: called CC=1 SCAR=3.5
| |||||||||||||||||||
| 26 | 1 | my $rh = t::Utility::rh_instance(1); | |||||||||||||||||
| 27 | 0 | my $acct = $rh->equity_accounts->current; | |||||||||||||||||
| 28 | 0 | isa_ok($acct, __PACKAGE__); | |||||||||||||||||
| 29 | 0 | t::Utility::stash('ACCT', $acct); # Store it for later | |||||||||||||||||
| 30 | } | ||||||||||||||||||
| 31 | 1 | ▶ | use Mojo::Base-base, -signatures; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 32 | 1 | ▶ | use Mojo::URL; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 33 | 0 | ▶ | use overload '""' => sub ($s, @) { $s->{url} }, fallback => 1; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||
| 34 | 1 | ▶ | use Finance::Robinhood::Equity::Account::Portfolio; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 35 | 1 | ▶ | use Finance::Robinhood::Equity::Account::InstantEligibility; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 36 | 1 | ▶ | use Finance::Robinhood::Equity::Account::MarginBalances; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 37 | |||||||||||||||||||
| 38 | 1 | ▶ | sub _test_stringify { | ||||||||||||||||
|
Subroutine
_test_stringify: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 39 | 1 | ▶ | t::Utility::stash('ACCT') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("ACCT") // skip_all()
MC/DC0%0/2
t::Utility::stash("ACCT") // skip_all()
t::Utility::stash("ACCT")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("ACCT")B= skip_all()
| |||||||||||||||||||
| 40 | 0 | like(+t::Utility::stash('ACCT'), | |||||||||||||||||
| 41 | qr'https://api.robinhood.com/accounts/.+/'); | ||||||||||||||||||
| 42 | } | ||||||||||||||||||
| 43 | ## | ||||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | =head1 METHODS | ||||||||||||||||||
| 46 | |||||||||||||||||||
| 47 | =cut | ||||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | 1 | has _rh => undef => weak => 1; | |||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | =head2 C<account_number( )> | ||||||||||||||||||
| 52 | |||||||||||||||||||
| 53 | The string used to identify this account. Used in the URL for many endpoints. | ||||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | =head2 C<buying_power( )> | ||||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | The maximum amount of cash on hand and available margin you may use to buy | ||||||||||||||||||
| 58 | stuff. | ||||||||||||||||||
| 59 | |||||||||||||||||||
| 60 | =head2 C<cash( )> | ||||||||||||||||||
| 61 | |||||||||||||||||||
| 62 | The amount of settled cash on hand. | ||||||||||||||||||
| 63 | |||||||||||||||||||
| 64 | =head2 C<cash_available_for_withdrawal( )> | ||||||||||||||||||
| 65 | |||||||||||||||||||
| 66 | The amount of settled cash on hand that has been in the account long enough to | ||||||||||||||||||
| 67 | be withdrawn back to the original bank account. | ||||||||||||||||||
| 68 | |||||||||||||||||||
| 69 | =head2 C<cash_held_for_orders( )> | ||||||||||||||||||
| 70 | |||||||||||||||||||
| 71 | Money set aside for buy orders that have not yet executed. | ||||||||||||||||||
| 72 | |||||||||||||||||||
| 73 | =head2 C<deactivated( )> | ||||||||||||||||||
| 74 | |||||||||||||||||||
| 75 | Returns true if the account has been closed. | ||||||||||||||||||
| 76 | |||||||||||||||||||
| 77 | =head2 C<deposit_halted( )> | ||||||||||||||||||
| 78 | |||||||||||||||||||
| 79 | Returns true if ACH deposits are disabled. | ||||||||||||||||||
| 80 | |||||||||||||||||||
| 81 | =head2 C<is_pinnacle_account( )> | ||||||||||||||||||
| 82 | |||||||||||||||||||
| 83 | True if account is backed by Robinhood Clearing rather than Apex Clearing. | ||||||||||||||||||
| 84 | |||||||||||||||||||
| 85 | =head2 C<max_ach_early_access_amount( )> | ||||||||||||||||||
| 86 | |||||||||||||||||||
| 87 | Maximum amount instantly available after an ACH deposit. Unless you have a Gold | ||||||||||||||||||
| 88 | subscription, this will likely be Instant's standard $1000. | ||||||||||||||||||
| 89 | |||||||||||||||||||
| 90 | =head2 C<only_position_closing_trades( )> | ||||||||||||||||||
| 91 | |||||||||||||||||||
| 92 | If your account is restricted from opening new positions, this will be true. | ||||||||||||||||||
| 93 | |||||||||||||||||||
| 94 | =head2 C<option_level( )> | ||||||||||||||||||
| 95 | |||||||||||||||||||
| 96 | One of several options: | ||||||||||||||||||
| 97 | |||||||||||||||||||
| 98 | =over | ||||||||||||||||||
| 99 | |||||||||||||||||||
| 100 | =item * C<option_level_1> | ||||||||||||||||||
| 101 | |||||||||||||||||||
| 102 | =item * C<option_level_2> | ||||||||||||||||||
| 103 | |||||||||||||||||||
| 104 | =item * C<option_level_3> | ||||||||||||||||||
| 105 | |||||||||||||||||||
| 106 | =back | ||||||||||||||||||
| 107 | |||||||||||||||||||
| 108 | =head2 C<rhs_account_number( )> | ||||||||||||||||||
| 109 | |||||||||||||||||||
| 110 | Internal account number used for official documents (tax forms, etc.) | ||||||||||||||||||
| 111 | |||||||||||||||||||
| 112 | =head2 C<sma( )> | ||||||||||||||||||
| 113 | |||||||||||||||||||
| 114 | TODO | ||||||||||||||||||
| 115 | |||||||||||||||||||
| 116 | =head2 C<sma_held_for_orders( )> | ||||||||||||||||||
| 117 | |||||||||||||||||||
| 118 | TODO | ||||||||||||||||||
| 119 | |||||||||||||||||||
| 120 | =head2 C<sweep_enabled( )> | ||||||||||||||||||
| 121 | |||||||||||||||||||
| 122 | Returns true if sweep is enabled to move cash between your brokerage account to | ||||||||||||||||||
| 123 | RH's crypto service. | ||||||||||||||||||
| 124 | |||||||||||||||||||
| 125 | =head2 C<type( )> | ||||||||||||||||||
| 126 | |||||||||||||||||||
| 127 | Simple C<cash> or C<margin> account flag. | ||||||||||||||||||
| 128 | |||||||||||||||||||
| 129 | =head2 C<uncleared_deposits( )> | ||||||||||||||||||
| 130 | |||||||||||||||||||
| 131 | Incoming ACH deposits that have not cleared yet. | ||||||||||||||||||
| 132 | |||||||||||||||||||
| 133 | =head2 C<unsettled_debit( )> | ||||||||||||||||||
| 134 | |||||||||||||||||||
| 135 | Outgoing funds that are not yet settled. | ||||||||||||||||||
| 136 | |||||||||||||||||||
| 137 | =head2 C<unsettled_funds( )> | ||||||||||||||||||
| 138 | |||||||||||||||||||
| 139 | Funds that are not yet settled but may be used thanks to Gold or Instant margin | ||||||||||||||||||
| 140 | accounts. | ||||||||||||||||||
| 141 | |||||||||||||||||||
| 142 | =head2 C<withdrawal_halted( )> | ||||||||||||||||||
| 143 | |||||||||||||||||||
| 144 | True if the account has been flagged and ACH withdrawal has been disabled. | ||||||||||||||||||
| 145 | |||||||||||||||||||
| 146 | =cut | ||||||||||||||||||
| 147 | |||||||||||||||||||
| 148 | 1 | has ['account_number', 'cash', | |||||||||||||||||
| 149 | 'buying_power', 'cash_available_for_withdrawal', | ||||||||||||||||||
| 150 | 'cash_held_for_orders', 'deactivated', | ||||||||||||||||||
| 151 | 'deposit_halted', 'is_pinnacle_account', | ||||||||||||||||||
| 152 | 'max_ach_early_access_amount', 'only_position_closing_trades', | ||||||||||||||||||
| 153 | 'option_level', 'rhs_account_number', | ||||||||||||||||||
| 154 | 'sma', 'sma_held_for_orders', | ||||||||||||||||||
| 155 | 'sweep_enabled', 'type', | ||||||||||||||||||
| 156 | 'uncleared_deposits', 'unsettled_debit', | ||||||||||||||||||
| 157 | 'unsettled_funds', 'url', | ||||||||||||||||||
| 158 | 'withdrawal_halted' | ||||||||||||||||||
| 159 | ]; | ||||||||||||||||||
| 160 | |||||||||||||||||||
| 161 | =head2 C<created_at( )> | ||||||||||||||||||
| 162 | |||||||||||||||||||
| 163 | Returns a Time::Moment object. | ||||||||||||||||||
| 164 | |||||||||||||||||||
| 165 | =cut | ||||||||||||||||||
| 166 | |||||||||||||||||||
| 167 | 0 | ▶ | sub created_at ($s) { | ||||||||||||||||
|
Subroutine
created_at: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 168 | 0 | Time::Moment->from_string($s->{created_at}); | |||||||||||||||||
| 169 | } | ||||||||||||||||||
| 170 | |||||||||||||||||||
| 171 | 1 | ▶ | sub _test_created_at { | ||||||||||||||||
|
Subroutine
_test_created_at: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 172 | 1 | ▶ | t::Utility::stash('ACCT') // skip_all('No account object in stash'); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
MC/DC0%0/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
t::Utility::stash("ACCT")
skip_all("No account object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("ACCT")B= skip_all("No account object in stash")
| |||||||||||||||||||
| 173 | 0 | isa_ok(t::Utility::stash('ACCT')->created_at, 'Time::Moment'); | |||||||||||||||||
| 174 | } | ||||||||||||||||||
| 175 | |||||||||||||||||||
| 176 | =head2 C<updated_at( )> | ||||||||||||||||||
| 177 | |||||||||||||||||||
| 178 | Returns a Time::Moment object. | ||||||||||||||||||
| 179 | |||||||||||||||||||
| 180 | =cut | ||||||||||||||||||
| 181 | |||||||||||||||||||
| 182 | 0 | ▶ | sub updated_at ($s) { | ||||||||||||||||
|
Subroutine
updated_at: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 183 | 0 | Time::Moment->from_string($s->{updated_at}); | |||||||||||||||||
| 184 | } | ||||||||||||||||||
| 185 | |||||||||||||||||||
| 186 | 1 | ▶ | sub _test_updated_at { | ||||||||||||||||
|
Subroutine
_test_updated_at: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 187 | 1 | ▶ | t::Utility::stash('ACCT') // skip_all('No account object in stash'); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
MC/DC0%0/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
t::Utility::stash("ACCT")
skip_all("No account object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("ACCT")B= skip_all("No account object in stash")
| |||||||||||||||||||
| 188 | 0 | isa_ok(t::Utility::stash('ACCT')->updated_at, 'Time::Moment'); | |||||||||||||||||
| 189 | } | ||||||||||||||||||
| 190 | |||||||||||||||||||
| 191 | =head2 C<user( )> | ||||||||||||||||||
| 192 | |||||||||||||||||||
| 193 | Returns the related Finance::Robinhood::Equity::Account object. | ||||||||||||||||||
| 194 | |||||||||||||||||||
| 195 | =cut | ||||||||||||||||||
| 196 | |||||||||||||||||||
| 197 | 0 | ▶ | sub user ($s) { | ||||||||||||||||
|
Subroutine
user: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||
| 198 | 0 | my $res = $s->_rh->_get($s->{user}); | |||||||||||||||||
| 199 | 0 | require Finance::Robinhood::User; | |||||||||||||||||
| 200 | $res->is_success | ||||||||||||||||||
| 201 | 0 | ▶ | ? Finance::Robinhood::User->new(_rh => $s->_rh, %{$res->json}) | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 202 | : Finance::Robinhood::Error->new( | ||||||||||||||||||
| 203 | $res->is_server_error ? (details => $res->message) : $res->json); | ||||||||||||||||||
| 204 | } | ||||||||||||||||||
| 205 | |||||||||||||||||||
| 206 | 1 | ▶ | sub _test_user { | ||||||||||||||||
|
Subroutine
_test_user: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 207 | 1 | ▶ | t::Utility::stash('ACCT') // skip_all('No account object in stash'); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
MC/DC0%0/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
t::Utility::stash("ACCT")
skip_all("No account object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("ACCT")B= skip_all("No account object in stash")
| |||||||||||||||||||
| 208 | 0 | isa_ok(t::Utility::stash('ACCT')->user, 'Finance::Robinhood::User'); | |||||||||||||||||
| 209 | } | ||||||||||||||||||
| 210 | |||||||||||||||||||
| 211 | =head2 C<can_downgrade_to_cash( )> | ||||||||||||||||||
| 212 | |||||||||||||||||||
| 213 | This method returns a true value if your account is currently eligible for | ||||||||||||||||||
| 214 | downgrading from a margin account (Instant or Gold) to a cash account. | ||||||||||||||||||
| 215 | |||||||||||||||||||
| 216 | =cut | ||||||||||||||||||
| 217 | |||||||||||||||||||
| 218 | 0 | ▶ | sub can_downgrade_to_cash ($s) { | ||||||||||||||||
|
Subroutine
can_downgrade_to_cash: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||
| 219 | 0 | my $res = $s->_rh->_get($s->{can_downgrade_to_cash}); | |||||||||||||||||
| 220 | $res->is_success | ||||||||||||||||||
| 221 | ? $res->json->{can_downgrade_to_cash} | ||||||||||||||||||
| 222 | 0 | ▶ | : Finance::Robinhood::Error->new( | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 223 | $res->is_server_error ? (details => $res->message) : $res->json); | ||||||||||||||||||
| 224 | } | ||||||||||||||||||
| 225 | |||||||||||||||||||
| 226 | 1 | ▶ | sub _test_can_downgrade_to_cash { | ||||||||||||||||
|
Subroutine
_test_can_downgrade_to_cash: called CC=2 SCAR=10.5
| |||||||||||||||||||
| 227 | 1 | ▶ | t::Utility::stash('ACCT') // skip_all('No account object in stash'); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
MC/DC0%0/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
t::Utility::stash("ACCT")
skip_all("No account object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("ACCT")B= skip_all("No account object in stash")
| |||||||||||||||||||
| 228 | 0 | my $can_downgrade_to_cash | |||||||||||||||||
| 229 | = t::Utility::stash('ACCT')->can_downgrade_to_cash; | ||||||||||||||||||
| 230 | 0 | isa_ok($can_downgrade_to_cash, 'JSON::PP::Boolean'); | |||||||||||||||||
| 231 | } | ||||||||||||||||||
| 232 | |||||||||||||||||||
| 233 | =head2 C<instant_eligibility( )> | ||||||||||||||||||
| 234 | |||||||||||||||||||
| 235 | Returns the related Finance::Robinhood::Equity::Account::InstantEligibility | ||||||||||||||||||
| 236 | object. | ||||||||||||||||||
| 237 | |||||||||||||||||||
| 238 | =cut | ||||||||||||||||||
| 239 | |||||||||||||||||||
| 240 | 0 | ▶ | sub instant_eligibility ($s) { | ||||||||||||||||
|
Subroutine
instant_eligibility: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 241 | Finance::Robinhood::Equity::Account::InstantEligibility->new( | ||||||||||||||||||
| 242 | _rh => $s->_rh, | ||||||||||||||||||
| 243 | 0 | %{$s->{instant_eligibility}} | |||||||||||||||||
| 244 | ); | ||||||||||||||||||
| 245 | } | ||||||||||||||||||
| 246 | |||||||||||||||||||
| 247 | 1 | ▶ | sub _test_instant_eligibility { | ||||||||||||||||
|
Subroutine
_test_instant_eligibility: called CC=2 SCAR=10.5
| |||||||||||||||||||
| 248 | 1 | ▶ | t::Utility::stash('ACCT') // skip_all('No account object in stash'); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
MC/DC0%0/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
t::Utility::stash("ACCT")
skip_all("No account object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("ACCT")B= skip_all("No account object in stash")
| |||||||||||||||||||
| 249 | 0 | my $instant_eligibility = t::Utility::stash('ACCT')->instant_eligibility; | |||||||||||||||||
| 250 | 0 | isa_ok($instant_eligibility, | |||||||||||||||||
| 251 | 'Finance::Robinhood::Equity::Account::InstantEligibility'); | ||||||||||||||||||
| 252 | } | ||||||||||||||||||
| 253 | |||||||||||||||||||
| 254 | =head2 C<margin_balances( )> | ||||||||||||||||||
| 255 | |||||||||||||||||||
| 256 | Returns the related Finance::Robinhood::Equity::Account::MarginBalances object. | ||||||||||||||||||
| 257 | |||||||||||||||||||
| 258 | =cut | ||||||||||||||||||
| 259 | |||||||||||||||||||
| 260 | 0 | ▶ | sub margin_balances ($s) { | ||||||||||||||||
|
Subroutine
margin_balances: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 261 | Finance::Robinhood::Equity::Account::MarginBalances->new( | ||||||||||||||||||
| 262 | _rh => $s->_rh, | ||||||||||||||||||
| 263 | 0 | %{$s->{margin_balances}} | |||||||||||||||||
| 264 | ); | ||||||||||||||||||
| 265 | } | ||||||||||||||||||
| 266 | |||||||||||||||||||
| 267 | 1 | ▶ | sub _test_margin_balances { | ||||||||||||||||
|
Subroutine
_test_margin_balances: called CC=2 SCAR=10.5
| |||||||||||||||||||
| 268 | 1 | ▶ | t::Utility::stash('ACCT') // skip_all('No account object in stash'); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
MC/DC0%0/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
t::Utility::stash("ACCT")
skip_all("No account object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("ACCT")B= skip_all("No account object in stash")
| |||||||||||||||||||
| 269 | 0 | my $margin_balances = t::Utility::stash('ACCT')->margin_balances; | |||||||||||||||||
| 270 | 0 | isa_ok($margin_balances, | |||||||||||||||||
| 271 | 'Finance::Robinhood::Equity::Account::MarginBalances'); | ||||||||||||||||||
| 272 | } | ||||||||||||||||||
| 273 | |||||||||||||||||||
| 274 | =head2 C<portfolio( )> | ||||||||||||||||||
| 275 | |||||||||||||||||||
| 276 | Returns the related Finance::Robinhood::Equity::Account::Portfolio object. | ||||||||||||||||||
| 277 | |||||||||||||||||||
| 278 | =cut | ||||||||||||||||||
| 279 | |||||||||||||||||||
| 280 | 0 | ▶ | sub portfolio ($s) { | ||||||||||||||||
|
Subroutine
portfolio: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||
| 281 | 0 | my $res = $s->_rh->_get($s->{portfolio}); | |||||||||||||||||
| 282 | $res->is_success | ||||||||||||||||||
| 283 | ? Finance::Robinhood::Equity::Account::Portfolio->new(_rh => $s->_rh, | ||||||||||||||||||
| 284 | 0 | ▶ | %{$res->json}) | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 285 | : Finance::Robinhood::Error->new( | ||||||||||||||||||
| 286 | $res->is_server_error ? (details => $res->message) : $res->json); | ||||||||||||||||||
| 287 | } | ||||||||||||||||||
| 288 | |||||||||||||||||||
| 289 | 1 | ▶ | sub _test_portfolio { | ||||||||||||||||
|
Subroutine
_test_portfolio: called CC=2 SCAR=10.5
| |||||||||||||||||||
| 290 | 1 | ▶ | t::Utility::stash('ACCT') // skip_all('No account object in stash'); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
MC/DC0%0/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
t::Utility::stash("ACCT")
skip_all("No account object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("ACCT")B= skip_all("No account object in stash")
| |||||||||||||||||||
| 291 | 0 | my $portfolio = t::Utility::stash('ACCT')->portfolio; | |||||||||||||||||
| 292 | 0 | isa_ok($portfolio, 'Finance::Robinhood::Equity::Account::Portfolio'); | |||||||||||||||||
| 293 | } | ||||||||||||||||||
| 294 | |||||||||||||||||||
| 295 | =head2 C<positions( )> | ||||||||||||||||||
| 296 | |||||||||||||||||||
| 297 | my $positions = $account->equity_positions( ); | ||||||||||||||||||
| 298 | |||||||||||||||||||
| 299 | Returns the related paginated list object filled with | ||||||||||||||||||
| 300 | Finance::Robinhood::Equity::Position objects. | ||||||||||||||||||
| 301 | |||||||||||||||||||
| 302 | my $positions = $account->equity_positions( nonzero => \1 ); | ||||||||||||||||||
| 303 | |||||||||||||||||||
| 304 | You can filter and modify the results. All options are optional. | ||||||||||||||||||
| 305 | |||||||||||||||||||
| 306 | =over | ||||||||||||||||||
| 307 | |||||||||||||||||||
| 308 | =item C<nonzero> - true or false. Default is false. | ||||||||||||||||||
| 309 | |||||||||||||||||||
| 310 | =item C<ordering> - List of equity instruments | ||||||||||||||||||
| 311 | |||||||||||||||||||
| 312 | =back | ||||||||||||||||||
| 313 | |||||||||||||||||||
| 314 | =cut | ||||||||||||||||||
| 315 | |||||||||||||||||||
| 316 | 0 | ▶ | sub positions ($s, %filters) { | ||||||||||||||||
|
Subroutine
positions: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||
| 317 | $filters{nonzero} = !!$filters{nonzero} ? 'true' : 'false' | ||||||||||||||||||
| 318 | 0 | ▶ | if defined $filters{nonzero}; | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 319 | Finance::Robinhood::Utilities::Iterator->new( | ||||||||||||||||||
| 320 | _rh => $s->_rh, | ||||||||||||||||||
| 321 | 0 | _next_page => Mojo::URL->new($s->{positions})->query(\%filters), | |||||||||||||||||
| 322 | _class => 'Finance::Robinhood::Equity::Position' | ||||||||||||||||||
| 323 | ); | ||||||||||||||||||
| 324 | } | ||||||||||||||||||
| 325 | |||||||||||||||||||
| 326 | 1 | ▶ | sub _test_positions { | ||||||||||||||||
|
Subroutine
_test_positions: called CC=2 SCAR=11.6
| |||||||||||||||||||
| 327 | 1 | ▶ | t::Utility::stash('ACCT') // skip_all('No account object in stash'); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
MC/DC0%0/2
t::Utility::stash("ACCT") // skip_all("No account object in stash")
t::Utility::stash("ACCT")
skip_all("No account object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("ACCT")B= skip_all("No account object in stash")
| |||||||||||||||||||
| 328 | 0 | my $positions = t::Utility::stash('ACCT')->positions; | |||||||||||||||||
| 329 | 0 | isa_ok($positions, 'Finance::Robinhood::Utilities::Iterator'); | |||||||||||||||||
| 330 | 0 | isa_ok($positions->current, 'Finance::Robinhood::Equity::Position'); | |||||||||||||||||
| 331 | } | ||||||||||||||||||
| 332 | |||||||||||||||||||
| 333 | =head1 LEGAL | ||||||||||||||||||
| 334 | |||||||||||||||||||
| 335 | This is a simple wrapper around the API used in the official apps. The author | ||||||||||||||||||
| 336 | provides no investment, legal, or tax advice and is not responsible for any | ||||||||||||||||||
| 337 | damages incurred while using this software. This software is not affiliated | ||||||||||||||||||
| 338 | with Robinhood Financial LLC in any way. | ||||||||||||||||||
| 339 | |||||||||||||||||||
| 340 | For Robinhood's terms and disclosures, please see their website at | ||||||||||||||||||
| 341 | https://robinhood.com/legal/ | ||||||||||||||||||
| 342 | |||||||||||||||||||
| 343 | =head1 LICENSE | ||||||||||||||||||
| 344 | |||||||||||||||||||
| 345 | Copyright (C) Sanko Robinson. | ||||||||||||||||||
| 346 | |||||||||||||||||||
| 347 | This library is free software; you can redistribute it and/or modify it under | ||||||||||||||||||
| 348 | the terms found in the Artistic License 2. Other copyrights, terms, and | ||||||||||||||||||
| 349 | conditions may apply to data transmitted through this module. Please refer to | ||||||||||||||||||
| 350 | the L<LEGAL> section. | ||||||||||||||||||
| 351 | |||||||||||||||||||
| 352 | =head1 AUTHOR | ||||||||||||||||||
| 353 | |||||||||||||||||||
| 354 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||||||||||||||||||
| 355 | |||||||||||||||||||
| 356 | =cut | ||||||||||||||||||
| 357 | |||||||||||||||||||
| 358 | 1 | 1; | |||||||||||||||||