« lib/Finance/Robinhood/Utilities/Iterator.pm
↑ Summary
lib/Finance/Robinhood/Equity/Account/Portfolio.pm »
| 1 | package Finance::Robinhood::Equity::Quote; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | =encoding utf-8 | ||||||||||||||||||
| 4 | |||||||||||||||||||
| 5 | =for stopwords watchlist watchlists untradable urls | ||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | Finance::Robinhood::Equity::Quote - Represents Quote Data for a Single Equity | ||||||||||||||||||
| 10 | Instrument | ||||||||||||||||||
| 11 | |||||||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | use Finance::Robinhood; | ||||||||||||||||||
| 15 | my $rh = Finance::Robinhood->new; | ||||||||||||||||||
| 16 | my $instruments = $rh->instruments(); | ||||||||||||||||||
| 17 | |||||||||||||||||||
| 18 | for my $instrument ($instruments->all) { | ||||||||||||||||||
| 19 | CORE::say $instrument->quote->last_trade_price; | ||||||||||||||||||
| 20 | } | ||||||||||||||||||
| 21 | |||||||||||||||||||
| 22 | =cut | ||||||||||||||||||
| 23 | |||||||||||||||||||
| 24 | 1 | our $VERSION = '0.92_003'; | |||||||||||||||||
| 25 | 1 | ▶ | use Mojo::Base-base, -signatures; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 26 | 1 | ▶ | use Mojo::URL; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 27 | 1 | ▶ | use Time::Moment; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 28 | 1 | ▶ | use Finance::Robinhood::Equity::Instrument; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 29 | |||||||||||||||||||
| 30 | 1 | ▶ | sub _test__init { | ||||||||||||||||
|
Subroutine
_test__init: called CC=1 SCAR=3.5
| |||||||||||||||||||
| 31 | 1 | my $rh = t::Utility::rh_instance(1); | |||||||||||||||||
| 32 | 0 | my $quote = $rh->equity_instrument_by_symbol('MSFT')->quote(); | |||||||||||||||||
| 33 | 0 | isa_ok($quote, __PACKAGE__); | |||||||||||||||||
| 34 | 0 | t::Utility::stash('QUOTE', $quote); # Store it for later | |||||||||||||||||
| 35 | } | ||||||||||||||||||
| 36 | # | ||||||||||||||||||
| 37 | 1 | has _rh => undef => weak => 1; | |||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | =head1 METHODS | ||||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | |||||||||||||||||||
| 42 | |||||||||||||||||||
| 43 | =head2 C<adjusted_previous_close( )> | ||||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | |||||||||||||||||||
| 46 | |||||||||||||||||||
| 47 | =head2 C<ask_price( )> | ||||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | Delayed ask price. | ||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | =head2 C<ask_size( )> | ||||||||||||||||||
| 52 | |||||||||||||||||||
| 53 | Delayed ask size. | ||||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | =head2 C<bid_price( )> | ||||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | Delayed bid price. | ||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | =head2 C<bid_size( )> | ||||||||||||||||||
| 60 | |||||||||||||||||||
| 61 | Delayed bid size. | ||||||||||||||||||
| 62 | |||||||||||||||||||
| 63 | =head2 C<has_traded( )> | ||||||||||||||||||
| 64 | |||||||||||||||||||
| 65 | Boolean value... no idea what this means yet. | ||||||||||||||||||
| 66 | |||||||||||||||||||
| 67 | =head2 C<last_extended_hours_trade_price( )> | ||||||||||||||||||
| 68 | |||||||||||||||||||
| 69 | Last pre- or after-hours trading price. | ||||||||||||||||||
| 70 | |||||||||||||||||||
| 71 | =head2 C<last_trade_price( )> | ||||||||||||||||||
| 72 | |||||||||||||||||||
| 73 | =head2 C<last_trade_price_source( )> | ||||||||||||||||||
| 74 | |||||||||||||||||||
| 75 | Which venue provided the last trade price. | ||||||||||||||||||
| 76 | |||||||||||||||||||
| 77 | =head2 C<previous_close( )> | ||||||||||||||||||
| 78 | |||||||||||||||||||
| 79 | The price at the most recent close. | ||||||||||||||||||
| 80 | |||||||||||||||||||
| 81 | =head2 C<symbol( )> | ||||||||||||||||||
| 82 | |||||||||||||||||||
| 83 | The ticker symbol of the instrument related to this quote data. See | ||||||||||||||||||
| 84 | C<instrument( )> to be given the instrument object itself. | ||||||||||||||||||
| 85 | |||||||||||||||||||
| 86 | =head2 C<trading_halted( )> | ||||||||||||||||||
| 87 | |||||||||||||||||||
| 88 | Returns a boolean value; true if trading is halted. | ||||||||||||||||||
| 89 | |||||||||||||||||||
| 90 | =cut | ||||||||||||||||||
| 91 | |||||||||||||||||||
| 92 | 1 | has ['adjusted_previous_close', 'ask_price', | |||||||||||||||||
| 93 | 'ask_size', 'bid_price', | ||||||||||||||||||
| 94 | 'bid_size', 'has_traded', | ||||||||||||||||||
| 95 | 'last_extended_hours_trade_price', 'last_trade_price', | ||||||||||||||||||
| 96 | 'last_trade_price_source', 'previous_close', | ||||||||||||||||||
| 97 | 'symbol', 'trading_halted' | ||||||||||||||||||
| 98 | ]; | ||||||||||||||||||
| 99 | |||||||||||||||||||
| 100 | =head2 C<previous_close_date( )> | ||||||||||||||||||
| 101 | |||||||||||||||||||
| 102 | $quote->previous_close_date(); | ||||||||||||||||||
| 103 | |||||||||||||||||||
| 104 | Returns a Time::Moment object. | ||||||||||||||||||
| 105 | |||||||||||||||||||
| 106 | =cut | ||||||||||||||||||
| 107 | |||||||||||||||||||
| 108 | 0 | ▶ | sub previous_close_date ($s) { | ||||||||||||||||
|
Subroutine
previous_close_date: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 109 | 0 | Time::Moment->from_string($s->{previous_close_date} . 'T16:30:00-05:00'); | |||||||||||||||||
| 110 | } | ||||||||||||||||||
| 111 | |||||||||||||||||||
| 112 | 1 | ▶ | sub _test_previous_close_date { | ||||||||||||||||
|
Subroutine
_test_previous_close_date: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 113 | 1 | ▶ | t::Utility::stash('QUOTE') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("QUOTE") // skip_all()
MC/DC0%0/2
t::Utility::stash("QUOTE") // skip_all()
t::Utility::stash("QUOTE")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("QUOTE")B= skip_all()
| |||||||||||||||||||
| 114 | 0 | isa_ok(t::Utility::stash('QUOTE')->previous_close_date(), 'Time::Moment'); | |||||||||||||||||
| 115 | } | ||||||||||||||||||
| 116 | |||||||||||||||||||
| 117 | =head2 C<updated_at( )> | ||||||||||||||||||
| 118 | |||||||||||||||||||
| 119 | $quote->updated_at(); | ||||||||||||||||||
| 120 | |||||||||||||||||||
| 121 | Returns a Time::Moment object. | ||||||||||||||||||
| 122 | |||||||||||||||||||
| 123 | =cut | ||||||||||||||||||
| 124 | |||||||||||||||||||
| 125 | 0 | ▶ | sub updated_at ($s) { | ||||||||||||||||
|
Subroutine
updated_at: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 126 | 0 | Time::Moment->from_string($s->{updated_at}); | |||||||||||||||||
| 127 | } | ||||||||||||||||||
| 128 | |||||||||||||||||||
| 129 | 1 | ▶ | sub _test_updated_at { | ||||||||||||||||
|
Subroutine
_test_updated_at: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 130 | 1 | ▶ | t::Utility::stash('QUOTE') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("QUOTE") // skip_all()
MC/DC0%0/2
t::Utility::stash("QUOTE") // skip_all()
t::Utility::stash("QUOTE")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("QUOTE")B= skip_all()
| |||||||||||||||||||
| 131 | 0 | isa_ok(t::Utility::stash('QUOTE')->updated_at(), 'Time::Moment'); | |||||||||||||||||
| 132 | } | ||||||||||||||||||
| 133 | |||||||||||||||||||
| 134 | =head2 C<instrument( )> | ||||||||||||||||||
| 135 | |||||||||||||||||||
| 136 | my $instrument = $quote->instrument(); | ||||||||||||||||||
| 137 | |||||||||||||||||||
| 138 | Loops back to a Finance::Robinhood::Equity::Instrument object. | ||||||||||||||||||
| 139 | |||||||||||||||||||
| 140 | =cut | ||||||||||||||||||
| 141 | |||||||||||||||||||
| 142 | 0 | ▶ | sub instrument ($s) { | ||||||||||||||||
|
Subroutine
instrument: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||
| 143 | 0 | my $res = $s->_rh->_get($s->{instrument}); | |||||||||||||||||
| 144 | $res->is_success | ||||||||||||||||||
| 145 | ? Finance::Robinhood::Equity::Instrument->new(_rh => $s->_rh, | ||||||||||||||||||
| 146 | 0 | ▶ | %{$res->json}) | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 147 | : Finance::Robinhood::Error->new( | ||||||||||||||||||
| 148 | $res->is_server_error ? (details => $res->message) : $res->json); | ||||||||||||||||||
| 149 | } | ||||||||||||||||||
| 150 | |||||||||||||||||||
| 151 | 1 | ▶ | sub _test_instrument { | ||||||||||||||||
|
Subroutine
_test_instrument: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 152 | 1 | ▶ | t::Utility::stash('QUOTE') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("QUOTE") // skip_all()
MC/DC0%0/2
t::Utility::stash("QUOTE") // skip_all()
t::Utility::stash("QUOTE")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("QUOTE")B= skip_all()
| |||||||||||||||||||
| 153 | 0 | isa_ok(t::Utility::stash('QUOTE')->instrument(), | |||||||||||||||||
| 154 | 'Finance::Robinhood::Equity::Instrument'); | ||||||||||||||||||
| 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; | |||||||||||||||||