« lib/Finance/Robinhood/Equity/Instrument.pm
↑ Summary
lib/Finance/Robinhood/Equity/OrderBuilder.pm »
| 1 | package Finance::Robinhood::Equity::Watchlist; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =encoding utf-8 | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =for stopwords watchlist watchlists untradable urls | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | Finance::Robinhood::Equity::Watchlist - Represents a Single Robinhood Watchlist | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | use Finance::Robinhood; | ||||||||||||||||||||||||||||
| 14 | my $rh = Finance::Robinhood->new->login('user', 'pass'); | ||||||||||||||||||||||||||||
| 15 | my $watchlist = $rh->watchlist_by_name('Default'); | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # TODO | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | our $VERSION = '0.92_003'; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | sub _test__init { | ||||||||||||||||||||||||||
|
Subroutine
_test__init: called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||
| 24 | 1 | my $rh = t::Utility::rh_instance(1); | |||||||||||||||||||||||||||
| 25 | 0 | my $watchlist = $rh->equity_watchlist_by_name('Default'); | |||||||||||||||||||||||||||
| 26 | 0 | isa_ok($watchlist, __PACKAGE__); | |||||||||||||||||||||||||||
| 27 | 0 | t::Utility::stash('WATCHLIST', $watchlist); # Store it for later | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | 1 | ▶ | use Mojo::Base 'Finance::Robinhood::Utilities::Iterator', -signatures; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 1 | ▶ | use Mojo::URL; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | use overload '""' => sub ($s, @) { $s->{_next_page} // $s->{_first_page} }, | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.7
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/3
$s->{"_next_page"} // $s->{"_first_page"}
MC/DC0%0/2
$s->{"_next_page"} // $s->{"_first_page"}
$s->{"_next_page"}
$s->{"_first_page"}
Truth table0%0/3
A // B
A= $s->{"_next_page"}B= $s->{"_first_page"}
| |||||||||||||||||||||||||||||
| 32 | 1 | fallback => 1; | |||||||||||||||||||||||||||
| 33 | 1 | ▶ | use Finance::Robinhood::Equity::Watchlist::Element; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | sub _test_stringify { | ||||||||||||||||||||||||||
|
Subroutine
_test_stringify: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||
| 36 | 1 | ▶ | t::Utility::stash('WATCHLIST') // skip_all(); | ||||||||||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("WATCHLIST") // skip_all()
MC/DC0%0/2
t::Utility::stash("WATCHLIST") // skip_all()
t::Utility::stash("WATCHLIST")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("WATCHLIST")B= skip_all()
| |||||||||||||||||||||||||||||
| 37 | 0 | is(+t::Utility::stash('WATCHLIST'), | |||||||||||||||||||||||||||
| 38 | 'https://api.robinhood.com/watchlists/Default/'); | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =head1 METHODS | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | This is a subclass of Finance::Robinhood::Utilities::Iterator. All the sweet, | ||||||||||||||||||||||||||||
| 44 | sugary goodness from there works here. Note that C<next( )>, C<current( )>, | ||||||||||||||||||||||||||||
| 45 | etc. return Finance::Robinhood::Equity::Watchlist::Element objects. | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | =cut | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | # Inherits _rh from Iterator | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =head2 C<name( )> | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | warn $watchlist->name; | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | Returns the name given to this watchlist. | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =cut | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | has 'name' => sub ($s) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 60 | 0 | $s->{results}->[0]->{watchlist} =~ m[.+\/(\w+)\/$]; | |||||||||||||||||||||||||||
| 61 | 0 | $1; | |||||||||||||||||||||||||||
| 62 | 1 | }; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 1 | ▶ | sub _test_name { | ||||||||||||||||||||||||||
|
Subroutine
_test_name: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||
| 65 | 1 | ▶ | t::Utility::stash('WATCHLIST') // skip_all(); | ||||||||||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("WATCHLIST") // skip_all()
MC/DC0%0/2
t::Utility::stash("WATCHLIST") // skip_all()
t::Utility::stash("WATCHLIST")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("WATCHLIST")B= skip_all()
| |||||||||||||||||||||||||||||
| 66 | 0 | is(t::Utility::stash('WATCHLIST')->name, 'Default'); | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | # Private | ||||||||||||||||||||||||||||
| 70 | 0 | ▶ | has 'url' => sub ($s) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 71 | 0 | sprintf 'https://api.robinhood.com/watchlists/%s/', $s->name; | |||||||||||||||||||||||||||
| 72 | 1 | }; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 1 | ▶ | sub _test_url { | ||||||||||||||||||||||||||
|
Subroutine
_test_url: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||
| 75 | 1 | ▶ | t::Utility::stash('WATCHLIST') // skip_all(); | ||||||||||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("WATCHLIST") // skip_all()
MC/DC0%0/2
t::Utility::stash("WATCHLIST") // skip_all()
t::Utility::stash("WATCHLIST")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("WATCHLIST")B= skip_all()
| |||||||||||||||||||||||||||||
| 76 | 0 | is(t::Utility::stash('WATCHLIST')->url, | |||||||||||||||||||||||||||
| 77 | 'https://api.robinhood.com/watchlists/Default/'); | ||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | # Override methods from Iterator | ||||||||||||||||||||||||||||
| 81 | 0 | ▶ | has _class => sub ($s) {'Finance::Robinhood::Equity::Watchlist::Element'}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | has _next_page => sub ($s) { $s->{url} }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 1 | ▶ | sub _test_current { | ||||||||||||||||||||||||||
|
Subroutine
_test_current: called CC=2 SCAR=10.5
| |||||||||||||||||||||||||||||
| 85 | 1 | ▶ | t::Utility::stash('WATCHLIST') // skip_all(); | ||||||||||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("WATCHLIST") // skip_all()
MC/DC0%0/2
t::Utility::stash("WATCHLIST") // skip_all()
t::Utility::stash("WATCHLIST")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("WATCHLIST")B= skip_all()
| |||||||||||||||||||||||||||||
| 86 | 0 | t::Utility::stash('WATCHLIST')->reset; | |||||||||||||||||||||||||||
| 87 | 0 | isa_ok(t::Utility::stash('WATCHLIST')->current, | |||||||||||||||||||||||||||
| 88 | 'Finance::Robinhood::Equity::Watchlist::Element'); | ||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 1 | ▶ | sub _test_next { | ||||||||||||||||||||||||||
|
Subroutine
_test_next: called CC=2 SCAR=10.5
| |||||||||||||||||||||||||||||
| 92 | 1 | ▶ | t::Utility::stash('WATCHLIST') // skip_all(); | ||||||||||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("WATCHLIST") // skip_all()
MC/DC0%0/2
t::Utility::stash("WATCHLIST") // skip_all()
t::Utility::stash("WATCHLIST")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("WATCHLIST")B= skip_all()
| |||||||||||||||||||||||||||||
| 93 | 0 | t::Utility::stash('WATCHLIST')->reset; | |||||||||||||||||||||||||||
| 94 | 0 | isa_ok(t::Utility::stash('WATCHLIST')->next, | |||||||||||||||||||||||||||
| 95 | 'Finance::Robinhood::Equity::Watchlist::Element'); | ||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =head2 C<populate( ... )> | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | $watchlist->populate('MSFT', 'QQQ', 'BA'); | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | Adds a list of equity instruments in bulk by their ticker symbol and returns a | ||||||||||||||||||||||||||||
| 103 | boolean. | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | =cut | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub populate ($s, @symbols) { | ||||||||||||||||||||||||||
|
Subroutine
populate: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | # Split symbols into groups of 32 to keep URL length down | ||||||||||||||||||||||||||||
| 110 | 0 | my $res; | |||||||||||||||||||||||||||
| 111 | 0 | ▶ | while (@symbols) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | 0 | $res = $s->_rh->_post($s->url . 'bulk_add/', | |||||||||||||||||||||||||||
| 113 | symbols => splice @symbols, | ||||||||||||||||||||||||||||
| 114 | 0, 32 | ||||||||||||||||||||||||||||
| 115 | ); | ||||||||||||||||||||||||||||
| 116 | 0 | ▶ | return Finance::Robinhood::Error->new($res->json) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | if !$res->is_success; | ||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | 0 | ▶ | return $res->is_success || | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->is_success || 'Finance::Robinhood::Error'->new($res->is_server_error ? ('details', $res->message) : $res->json)
MC/DC0%0/2
$res->is_success || 'Finance::Robinhood::Error'->new($res->is_server_error ? ('details', $res->message) : $res->json)
$res->is_success
'Finance::Robinhood::Error'->new($res->is_server_error ? ('details', $res->message) : $res->json)
Truth table0%0/3
A || B
A= $res->is_successB= 'Finance::Robinhood::Error'->new($res->is_server_error ? ('details', $res->message) : $res->json)
| |||||||||||||||||||||||||||||
| 120 | Finance::Robinhood::Error->new( | ||||||||||||||||||||||||||||
| 121 | $res->is_server_error ? (details => $res->message) : $res->json); | ||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 1 | ▶ | sub _test_populate { | ||||||||||||||||||||||||||
|
Subroutine
_test_populate: called CC=2 SCAR=12.4
| |||||||||||||||||||||||||||||
| 125 | 1 | ▶ | t::Utility::stash('WATCHLIST') // skip_all(); | ||||||||||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("WATCHLIST") // skip_all()
MC/DC0%0/2
t::Utility::stash("WATCHLIST") // skip_all()
t::Utility::stash("WATCHLIST")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("WATCHLIST")B= skip_all()
| |||||||||||||||||||||||||||||
| 126 | 0 | t::Utility::stash('WATCHLIST')->reset; | |||||||||||||||||||||||||||
| 127 | 0 | ok(t::Utility::stash('WATCHLIST')->populate('MSFT'), 'adding MSFT'); | |||||||||||||||||||||||||||
| 128 | todo("Test that the instrument was added by checking watchlist size" => | ||||||||||||||||||||||||||||
| 129 | 0 | ▶ | sub { pass('ugh') }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | =head2 C<add_instrument( ... )> | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | $watchlist->add_instrument($msft); | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | Adds an equity instrument. If successful, a | ||||||||||||||||||||||||||||
| 137 | Finance::Robinhood::Equity::Watchlist::Element object is returned. | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =cut | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub add_instrument ($s, $instrument) { | ||||||||||||||||||||||||||
|
Subroutine
add_instrument: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 142 | 0 | my $res = $s->_rh->_post($s->url, instrument => $instrument); | |||||||||||||||||||||||||||
| 143 | return $res->is_success | ||||||||||||||||||||||||||||
| 144 | ? Finance::Robinhood::Equity::Watchlist::Element->new(_rh => $s->_rh, | ||||||||||||||||||||||||||||
| 145 | 0 | ▶ | %{$res->json}) | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 146 | : Finance::Robinhood::Error->new( | ||||||||||||||||||||||||||||
| 147 | $res->is_server_error ? (details => $res->message) : $res->json); | ||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 1 | ▶ | sub _test_add_instrument { | ||||||||||||||||||||||||||
|
Subroutine
_test_add_instrument: called CC=3 SCAR=19.2
| |||||||||||||||||||||||||||||
| 151 | 1 | ▶ | t::Utility::stash('WATCHLIST') // skip_all(); | ||||||||||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("WATCHLIST") // skip_all()
MC/DC0%0/2
t::Utility::stash("WATCHLIST") // skip_all()
t::Utility::stash("WATCHLIST")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("WATCHLIST")B= skip_all()
| |||||||||||||||||||||||||||||
| 152 | 0 | t::Utility::stash('WATCHLIST')->reset; | |||||||||||||||||||||||||||
| 153 | 0 | my $result | |||||||||||||||||||||||||||
| 154 | = t::Utility::stash('WATCHLIST') | ||||||||||||||||||||||||||||
| 155 | ->add_instrument(t::Utility::stash('WATCHLIST') | ||||||||||||||||||||||||||||
| 156 | ->_rh->equity_instrument_by_symbol('MSFT')); | ||||||||||||||||||||||||||||
| 157 | 0 | ▶ | isa_ok($result, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | $result | ||||||||||||||||||||||||||||
| 159 | ? 'Finance::Robinhood::Equity::Watchlist::Element' | ||||||||||||||||||||||||||||
| 160 | : 'Finance::Robinhood::Error' | ||||||||||||||||||||||||||||
| 161 | ); | ||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | =head2 C<instruments( )> | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | my @instruments = $watchlist->instruments(); | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | This method makes a call to grab data for every equity instrument on the | ||||||||||||||||||||||||||||
| 169 | watchlist and returns them as a list. | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | =cut | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 0 | ▶ | sub instruments ($s) { | ||||||||||||||||||||||||||
|
Subroutine
instruments: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 174 | 0 | $s->_rh->equity_instruments_by_id(map { $_->id } $s->all); | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 1 | ▶ | sub _test_instruments { | ||||||||||||||||||||||||||
|
Subroutine
_test_instruments: called CC=3 SCAR=17.3
| |||||||||||||||||||||||||||||
| 178 | 1 | ▶ | t::Utility::stash('WATCHLIST') // skip_all(); | ||||||||||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("WATCHLIST") // skip_all()
MC/DC0%0/2
t::Utility::stash("WATCHLIST") // skip_all()
t::Utility::stash("WATCHLIST")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("WATCHLIST")B= skip_all()
| |||||||||||||||||||||||||||||
| 179 | 0 | t::Utility::stash('WATCHLIST')->reset; | |||||||||||||||||||||||||||
| 180 | 0 | my @instruments = t::Utility::stash('WATCHLIST')->instruments; | |||||||||||||||||||||||||||
| 181 | 0 | isa_ok($_, 'Finance::Robinhood::Equity::Instrument') for @instruments; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | =head2 C<ids( )> | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | my @ids = $watchlist->ids(); | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | Returns the instrument id for all equity instruments as a list. | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | =cut | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sub ids ($s) { | ||||||||||||||||||||||||||
|
Subroutine
ids: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 193 | 0 | map { $_->id } $s->all; | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 1 | ▶ | sub _test_ids { | ||||||||||||||||||||||||||
|
Subroutine
_test_ids: called CC=3 SCAR=17.3
| |||||||||||||||||||||||||||||
| 197 | 1 | ▶ | t::Utility::stash('WATCHLIST') // skip_all(); | ||||||||||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("WATCHLIST") // skip_all()
MC/DC0%0/2
t::Utility::stash("WATCHLIST") // skip_all()
t::Utility::stash("WATCHLIST")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("WATCHLIST")B= skip_all()
| |||||||||||||||||||||||||||||
| 198 | 0 | t::Utility::stash('WATCHLIST')->reset; | |||||||||||||||||||||||||||
| 199 | 0 | my @ids = t::Utility::stash('WATCHLIST')->ids; | |||||||||||||||||||||||||||
| 200 | like($_, qr[^[0-9a-f]{8}(?:\-[0-9a-f]{4}){3}\-[0-9a-f]{12}$]i, $_) | ||||||||||||||||||||||||||||
| 201 | 0 | for @ids; | |||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | =head2 C<reorder( ... )> | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | $watchlist->reorder( @ids ); | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | This method moves items of the watchlist around. | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | =cut | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 0 | ▶ | sub reorder ($s, @ids) { | ||||||||||||||||||||||||||
|
Subroutine
reorder: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 213 | 0 | my $res = $s->_rh->_post($s->url . 'reorder/', uuids => join ',', @ids); | |||||||||||||||||||||||||||
| 214 | 0 | ▶ | return $res->is_success || Finance::Robinhood::Error->new(%{$res->json}); | ||||||||||||||||||||||||||
|
Condition0%0/3
$res->is_success || 'Finance::Robinhood::Error'->new(%{$res->json;})
MC/DC0%0/2
$res->is_success || 'Finance::Robinhood::Error'->new(%{$res->json;})
$res->is_success
'Finance::Robinhood::Error'->new(%{$res->json;})
Truth table0%0/3
A || B
A= $res->is_successB= 'Finance::Robinhood::Error'->new(%{$res->json;})
| |||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 1 | ▶ | sub _test_reorder { | ||||||||||||||||||||||||||
|
Subroutine
_test_reorder: called CC=2 SCAR=13.6
| |||||||||||||||||||||||||||||
| 218 | 1 | ▶ | t::Utility::stash('WATCHLIST') // skip_all(); | ||||||||||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("WATCHLIST") // skip_all()
MC/DC0%0/2
t::Utility::stash("WATCHLIST") // skip_all()
t::Utility::stash("WATCHLIST")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("WATCHLIST")B= skip_all()
| |||||||||||||||||||||||||||||
| 219 | 0 | t::Utility::stash('WATCHLIST')->reset; | |||||||||||||||||||||||||||
| 220 | 0 | my @ids = t::Utility::stash('WATCHLIST')->ids; | |||||||||||||||||||||||||||
| 221 | 0 | ok(t::Utility::stash('WATCHLIST')->reorder(reverse @ids), 'reorder(...)'); | |||||||||||||||||||||||||||
| 222 | 0 | t::Utility::stash('WATCHLIST')->reset; | |||||||||||||||||||||||||||
| 223 | 0 | my @reordered = t::Utility::stash('WATCHLIST')->ids; | |||||||||||||||||||||||||||
| 224 | 0 | is([reverse @ids], \@reordered); | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | =head1 LEGAL | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | This is a simple wrapper around the API used in the official apps. The author | ||||||||||||||||||||||||||||
| 230 | provides no investment, legal, or tax advice and is not responsible for any | ||||||||||||||||||||||||||||
| 231 | damages incurred while using this software. This software is not affiliated | ||||||||||||||||||||||||||||
| 232 | with Robinhood Financial LLC in any way. | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | For Robinhood's terms and disclosures, please see their website at | ||||||||||||||||||||||||||||
| 235 | https://robinhood.com/legal/ | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | Copyright (C) Sanko Robinson. | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | This library is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 242 | the terms found in the Artistic License 2. Other copyrights, terms, and | ||||||||||||||||||||||||||||
| 243 | conditions may apply to data transmitted through this module. Please refer to | ||||||||||||||||||||||||||||
| 244 | the L<LEGAL> section. | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | =cut | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 1 | 1; | |||||||||||||||||||||||||||