« lib/Finance/Robinhood/Equity/Account/InstantEligibility.pm
↑ Summary
lib/Finance/Robinhood/Equity/Order/Execution.pm »
| 1 | package Finance::Robinhood::Equity::Mover; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | =encoding utf-8 | ||||||||||||||||||
| 4 | |||||||||||||||||||
| 5 | =for stopwords watchlist watchlists untradable urls | ||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | Finance::Robinhood::Equity::Mover - Represents a Top Moving Equity Instrument | ||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | use Text::Wrap qw[wrap]; | ||||||||||||||||||
| 14 | use Finance::Robinhood; | ||||||||||||||||||
| 15 | my $rh = Finance::Robinhood->new; | ||||||||||||||||||
| 16 | my $movers = $rh->top_movers(direction => 'up'); | ||||||||||||||||||
| 17 | |||||||||||||||||||
| 18 | for my $mover ($movers->all) { | ||||||||||||||||||
| 19 | CORE::say $mover->instrument->name; | ||||||||||||||||||
| 20 | } | ||||||||||||||||||
| 21 | |||||||||||||||||||
| 22 | =head1 METHODS | ||||||||||||||||||
| 23 | |||||||||||||||||||
| 24 | =cut | ||||||||||||||||||
| 25 | |||||||||||||||||||
| 26 | 1 | our $VERSION = '0.92_003'; | |||||||||||||||||
| 27 | 1 | ▶ | use Mojo::Base-base, -signatures; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 28 | 1 | ▶ | use Mojo::URL; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 29 | 1 | ▶ | use Time::Moment; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 30 | 1 | ▶ | use Finance::Robinhood::Equity::PriceMovement; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 31 | |||||||||||||||||||
| 32 | 1 | ▶ | sub _test__init { | ||||||||||||||||
|
Subroutine
_test__init: called CC=1 SCAR=3.5
| |||||||||||||||||||
| 33 | 1 | my $rh = t::Utility::rh_instance(1); | |||||||||||||||||
| 34 | 0 | my $top = $rh->top_movers(direction => 'up')->current; | |||||||||||||||||
| 35 | 0 | isa_ok($top, __PACKAGE__); | |||||||||||||||||
| 36 | 0 | t::Utility::stash('MOVER', $top); # Store it for later | |||||||||||||||||
| 37 | } | ||||||||||||||||||
| 38 | 0 | ▶ | use overload '""' => sub ($s, @) { $s->{instrument_url} }, fallback => 1; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||
| 39 | |||||||||||||||||||
| 40 | 1 | ▶ | sub _test_stringify { | ||||||||||||||||
|
Subroutine
_test_stringify: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 41 | 1 | ▶ | t::Utility::stash('MOVER') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("MOVER") // skip_all()
MC/DC0%0/2
t::Utility::stash("MOVER") // skip_all()
t::Utility::stash("MOVER")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("MOVER")B= skip_all()
| |||||||||||||||||||
| 42 | 0 | like(+t::Utility::stash('MOVER'), | |||||||||||||||||
| 43 | qr'https://api.robinhood.com/instruments/.+/',); | ||||||||||||||||||
| 44 | } | ||||||||||||||||||
| 45 | # | ||||||||||||||||||
| 46 | 1 | has _rh => undef => weak => 1; | |||||||||||||||||
| 47 | |||||||||||||||||||
| 48 | =head2 C<description( )> | ||||||||||||||||||
| 49 | |||||||||||||||||||
| 50 | Returns a full text description suited for display. | ||||||||||||||||||
| 51 | |||||||||||||||||||
| 52 | =head2 C<symbol( )> | ||||||||||||||||||
| 53 | |||||||||||||||||||
| 54 | Returns the ticker symbol of the instrument. | ||||||||||||||||||
| 55 | |||||||||||||||||||
| 56 | =cut | ||||||||||||||||||
| 57 | |||||||||||||||||||
| 58 | 1 | has ['description', 'symbol']; | |||||||||||||||||
| 59 | |||||||||||||||||||
| 60 | =head2 C<updated_at( )> | ||||||||||||||||||
| 61 | |||||||||||||||||||
| 62 | $article->updated_at->to_string; | ||||||||||||||||||
| 63 | |||||||||||||||||||
| 64 | Returns the time the article was published or last updated as a Time::Moment | ||||||||||||||||||
| 65 | object. | ||||||||||||||||||
| 66 | |||||||||||||||||||
| 67 | =cut | ||||||||||||||||||
| 68 | |||||||||||||||||||
| 69 | 0 | ▶ | sub updated_at($s) { | ||||||||||||||||
|
Subroutine
updated_at: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 70 | 0 | Time::Moment->from_string($s->{updated_at}); | |||||||||||||||||
| 71 | } | ||||||||||||||||||
| 72 | |||||||||||||||||||
| 73 | 1 | ▶ | sub _test_updated_at { | ||||||||||||||||
|
Subroutine
_test_updated_at: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 74 | 1 | ▶ | t::Utility::stash('MOVER') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("MOVER") // skip_all()
MC/DC0%0/2
t::Utility::stash("MOVER") // skip_all()
t::Utility::stash("MOVER")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("MOVER")B= skip_all()
| |||||||||||||||||||
| 75 | 0 | isa_ok(t::Utility::stash('MOVER')->updated_at, 'Time::Moment'); | |||||||||||||||||
| 76 | } | ||||||||||||||||||
| 77 | |||||||||||||||||||
| 78 | =head2 C<instrument( )> | ||||||||||||||||||
| 79 | |||||||||||||||||||
| 80 | my $instrument = $mover->instrument(); | ||||||||||||||||||
| 81 | |||||||||||||||||||
| 82 | Builds a Finance::Robinhood::Equity::Instrument object. | ||||||||||||||||||
| 83 | |||||||||||||||||||
| 84 | =cut | ||||||||||||||||||
| 85 | |||||||||||||||||||
| 86 | 0 | ▶ | sub instrument ($s) { | ||||||||||||||||
|
Subroutine
instrument: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||
| 87 | 0 | my $res = $s->_rh->_get($s->{instrument_url}); | |||||||||||||||||
| 88 | $res->is_success | ||||||||||||||||||
| 89 | ? Finance::Robinhood::Equity::Instrument->new(_rh => $s->_rh, | ||||||||||||||||||
| 90 | 0 | ▶ | %{$res->json}) | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 91 | : Finance::Robinhood::Error->new( | ||||||||||||||||||
| 92 | $res->is_server_error ? (details => $res->message) : $res->json); | ||||||||||||||||||
| 93 | } | ||||||||||||||||||
| 94 | |||||||||||||||||||
| 95 | 1 | ▶ | sub _test_instrument { | ||||||||||||||||
|
Subroutine
_test_instrument: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 96 | 1 | ▶ | t::Utility::stash('MOVER') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("MOVER") // skip_all()
MC/DC0%0/2
t::Utility::stash("MOVER") // skip_all()
t::Utility::stash("MOVER")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("MOVER")B= skip_all()
| |||||||||||||||||||
| 97 | 0 | isa_ok(t::Utility::stash('MOVER')->instrument(), | |||||||||||||||||
| 98 | 'Finance::Robinhood::Equity::Instrument'); | ||||||||||||||||||
| 99 | } | ||||||||||||||||||
| 100 | |||||||||||||||||||
| 101 | =head2 C<price_movement( )> | ||||||||||||||||||
| 102 | |||||||||||||||||||
| 103 | my $price_movement = $mover->price_movement(); | ||||||||||||||||||
| 104 | |||||||||||||||||||
| 105 | Builds a Finance::Robinhood::Equity::PriceMovement object. | ||||||||||||||||||
| 106 | |||||||||||||||||||
| 107 | =cut | ||||||||||||||||||
| 108 | |||||||||||||||||||
| 109 | 0 | ▶ | sub price_movement ($s) { | ||||||||||||||||
|
Subroutine
price_movement: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 110 | Finance::Robinhood::Equity::PriceMovement->new(_rh => $s->_rh, | ||||||||||||||||||
| 111 | 0 | %{$s->{price_movement}}); | |||||||||||||||||
| 112 | } | ||||||||||||||||||
| 113 | |||||||||||||||||||
| 114 | 1 | ▶ | sub _test_price_movement { | ||||||||||||||||
|
Subroutine
_test_price_movement: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 115 | 1 | ▶ | t::Utility::stash('MOVER') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("MOVER") // skip_all()
MC/DC0%0/2
t::Utility::stash("MOVER") // skip_all()
t::Utility::stash("MOVER")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("MOVER")B= skip_all()
| |||||||||||||||||||
| 116 | 0 | isa_ok(t::Utility::stash('MOVER')->price_movement(), | |||||||||||||||||
| 117 | 'Finance::Robinhood::Equity::PriceMovement'); | ||||||||||||||||||
| 118 | } | ||||||||||||||||||
| 119 | |||||||||||||||||||
| 120 | =head1 LEGAL | ||||||||||||||||||
| 121 | |||||||||||||||||||
| 122 | This is a simple wrapper around the API used in the official apps. The author | ||||||||||||||||||
| 123 | provides no investment, legal, or tax advice and is not responsible for any | ||||||||||||||||||
| 124 | damages incurred while using this software. This software is not affiliated | ||||||||||||||||||
| 125 | with Robinhood Financial LLC in any way. | ||||||||||||||||||
| 126 | |||||||||||||||||||
| 127 | For Robinhood's terms and disclosures, please see their website at | ||||||||||||||||||
| 128 | https://robinhood.com/legal/ | ||||||||||||||||||
| 129 | |||||||||||||||||||
| 130 | =head1 LICENSE | ||||||||||||||||||
| 131 | |||||||||||||||||||
| 132 | Copyright (C) Sanko Robinson. | ||||||||||||||||||
| 133 | |||||||||||||||||||
| 134 | This library is free software; you can redistribute it and/or modify it under | ||||||||||||||||||
| 135 | the terms found in the Artistic License 2. Other copyrights, terms, and | ||||||||||||||||||
| 136 | conditions may apply to data transmitted through this module. Please refer to | ||||||||||||||||||
| 137 | the L<LEGAL> section. | ||||||||||||||||||
| 138 | |||||||||||||||||||
| 139 | =head1 AUTHOR | ||||||||||||||||||
| 140 | |||||||||||||||||||
| 141 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||||||||||||||||||
| 142 | |||||||||||||||||||
| 143 | =cut | ||||||||||||||||||
| 144 | |||||||||||||||||||
| 145 | 1 | 1; | |||||||||||||||||