lib/Finance/Robinhood/Equity/Prices.pm

filter: Statementstmt 50.0% 22 / 44 Branchbran 0.0% 0 / 12 Conditioncond 50.0% 5 / 10 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 66.6% 10 / 15 Podpod 100% 5 / 5 totaltotal 43.7% 42 / 96 CC 12 SCAR 15.3
CC
12
Cov
41%
_test_ask_source
7.2
_test_bid_source
7.2
_test_source
7.2
CRAP 4.6
« lib/Finance/Robinhood/News.pm ↑ Summary lib/Finance/Robinhood/Equity/Position.pm »
1 package Finance::Robinhood::Equity::Prices;
2  
3 =encoding utf-8
4  
5 =for stopwords watchlist watchlists untradable urls
6  
7 =head1 NAME
8  
9 Finance::Robinhood::Equity::Prices - Represents Basic Price Data for a Single
10 Equity Instrument
11  
12 =head1 SYNOPSIS
13  
14 use Finance::Robinhood;
15 my $rh = Finance::Robinhood->new;
16 my $instrument = $rh->equity_instrument_by_symbol('MSFT');
17  
18 my $price = $instrument->price();
19  
20 =cut
21  
22 1 our $VERSION = '0.92_003';
23 1 ▶use Mojo::Base-base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Mojo::URL;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Time::Moment;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Finance::Robinhood::Equity::Instrument;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 1 ▶sub _test__init {
Subroutine _test__init: called CC=1 SCAR=3.5
29 1 my $rh = t::Utility::rh_instance(1);
30 0 my $price = $rh->equity_instrument_by_symbol('MSFT')->prices();
31 0 isa_ok($price, __PACKAGE__);
32 0 t::Utility::stash('PRICES', $price); # Store it for later
33 }
34 #
35 1 has _rh => undef => weak => 1;
36  
37 =head1 METHODS
38  
39 =head2 C<ask_price( )>
40  
41 The current best ask price.
42  
43 =head2 C<ask_size( )>
44  
45 The current best ask price's depth.
46  
47 =head2 C<bid_price( )>
48  
49 The current best bid price.
50  
51 =head2 C<bid_size( )>
52  
53 The current best bid's depth.
54  
55 =head2 C<price( )>
56  
57 The current last trade price.
58  
59 =head2 C<size( )>
60  
61 Size of the last trade.
62  
63 =cut
64  
65 1 has ['ask_price', 'ask_size', 'bid_price', 'bid_size', 'price', 'size'];
66  
67 =head2 C<ask_source( )>
68  
69 CORE::say $prices->ask_source->name;
70  
71 If available, this returns a Finance::Robinhood::Equity::Market object that
72 represents the source for the C<ask_price( )> and C<ask_size( )>.
73  
74 =cut
75  
76 0 ▶sub ask_source ($s) {
Subroutine ask_source: not called CC=2 SCAR=17.9
Pod documented
77 0 ▶ $s->_rh->equity_market_by_mic($s->{ask_mic}) if defined $s->{ask_mic};
Branch: 1 branch
BranchTrueFalseTotal
if defined $s->{"ask_mic"} 0 0 0
78 }
79  
80 1 ▶sub _test_ask_source {
Subroutine _test_ask_source: called CC=3 SCAR=19.8
81 1 ▶ t::Utility::stash('PRICES') // skip_all();
Condition50%1/2
t::Utility::stash("PRICES") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("PRICES") // skip_all()
t::Utility::stash("PRICES") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("PRICES")B= skip_all()
ABresult
1X1
011
000
82 0 my $source = t::Utility::stash('PRICES')->ask_source();
83 SKIP: {
84 0 ▶ skip('Bad mic', 1) if !$source;
Branch: 1 branch
BranchTrueFalseTotal
unless $source 0 0 0
85 0 isa_ok($source, 'Finance::Robinhood::Equity::Market');
86 }
87 }
88  
89 =head2 C<bid_source( )>
90  
91 CORE::say $prices->bid_source->name;
92  
93 If available, this returns a Finance::Robinhood::Equity::Market object that
94 represents the source for the C<bid_price( )> and C<bid_size( )>.
95  
96 =cut
97  
98 0 ▶sub bid_source ($s) {
Subroutine bid_source: not called CC=2 SCAR=17.9
Pod documented
99 0 ▶ $s->_rh->equity_market_by_mic($s->{bid_mic}) if defined $s->{bid_mic};
Branch: 1 branch
BranchTrueFalseTotal
if defined $s->{"bid_mic"} 0 0 0
100 }
101  
102 1 ▶sub _test_bid_source {
Subroutine _test_bid_source: called CC=3 SCAR=19.8
103 1 ▶ t::Utility::stash('PRICES') // skip_all();
Condition50%1/2
t::Utility::stash("PRICES") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("PRICES") // skip_all()
t::Utility::stash("PRICES") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("PRICES")B= skip_all()
ABresult
1X1
011
000
104 0 my $source = t::Utility::stash('PRICES')->bid_source();
105 SKIP: {
106 0 ▶ skip('Bad mic', 1) if !$source;
Branch: 1 branch
BranchTrueFalseTotal
unless $source 0 0 0
107 0 isa_ok($source, 'Finance::Robinhood::Equity::Market');
108 }
109 }
110  
111 =head2 C<source( )>
112  
113 CORE::say $prices->source->name;
114  
115 If available, this returns a Finance::Robinhood::Equity::Market object that
116 represents the source for the C<price( )> and C<size( )>.
117  
118 =cut
119  
120 0 ▶sub source ($s) {
Subroutine source: not called CC=2 SCAR=17.9
Pod documented
121 0 ▶ $s->_rh->equity_market_by_mic($s->{mic}) if defined $s->{mic};
Branch: 1 branch
BranchTrueFalseTotal
if defined $s->{"mic"} 0 0 0
122 }
123  
124 1 ▶sub _test_source {
Subroutine _test_source: called CC=3 SCAR=19.8
125 1 ▶ t::Utility::stash('PRICES') // skip_all();
Condition50%1/2
t::Utility::stash("PRICES") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("PRICES") // skip_all()
t::Utility::stash("PRICES") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("PRICES")B= skip_all()
ABresult
1X1
011
000
126 0 my $source = t::Utility::stash('PRICES')->source();
127 SKIP: {
128 0 ▶ skip('Bad mic', 1) if !$source;
Branch: 1 branch
BranchTrueFalseTotal
unless $source 0 0 0
129 0 isa_ok($source, 'Finance::Robinhood::Equity::Market');
130 }
131 }
132  
133 =head2 C<updated_at( )>
134  
135 $prices->updated_at();
136  
137 Returns a Time::Moment object.
138  
139 =cut
140  
141 0 ▶sub updated_at ($s) {
Subroutine updated_at: not called CC=1 SCAR=6.9
Pod documented
142 0 Time::Moment->from_string($s->{updated_at});
143 }
144  
145 1 ▶sub _test_updated_at {
Subroutine _test_updated_at: called CC=2 SCAR=9.2
146 1 ▶ t::Utility::stash('PRICES') // skip_all();
Condition50%1/2
t::Utility::stash("PRICES") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("PRICES") // skip_all()
t::Utility::stash("PRICES") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("PRICES")B= skip_all()
ABresult
1X1
011
000
147 0 isa_ok(t::Utility::stash('PRICES')->updated_at(), 'Time::Moment');
148 }
149  
150 =head2 C<instrument( )>
151  
152 my $instrument = $prices->instrument();
153  
154 Loops back to a Finance::Robinhood::Equity::Instrument object.
155  
156 =cut
157  
158 0 ▶sub instrument ($s) {
Subroutine instrument: not called CC=1 SCAR=6.9
Pod documented
159 0 $s->_rh->equity_instrument_by_id($s->{instrument_id});
160 }
161  
162 1 ▶sub _test_instrument {
Subroutine _test_instrument: called CC=2 SCAR=9.2
163 1 ▶ t::Utility::stash('PRICES') // skip_all();
Condition50%1/2
t::Utility::stash("PRICES") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("PRICES") // skip_all()
t::Utility::stash("PRICES") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("PRICES")B= skip_all()
ABresult
1X1
011
000
164 0 isa_ok(t::Utility::stash('PRICES')->instrument(),
165 'Finance::Robinhood::Equity::Instrument');
166 }
167  
168 =head1 LEGAL
169  
170 This is a simple wrapper around the API used in the official apps. The author
171 provides no investment, legal, or tax advice and is not responsible for any
172 damages incurred while using this software. This software is not affiliated
173 with Robinhood Financial LLC in any way.
174  
175 For Robinhood's terms and disclosures, please see their website at
176 https://robinhood.com/legal/
177  
178 =head1 LICENSE
179  
180 Copyright (C) Sanko Robinson.
181  
182 This library is free software; you can redistribute it and/or modify it under
183 the terms found in the Artistic License 2. Other copyrights, terms, and
184 conditions may apply to data transmitted through this module. Please refer to
185 the L<LEGAL> section.
186  
187 =head1 AUTHOR
188  
189 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
190  
191 =cut
192  
193 1 1;
« lib/Finance/Robinhood/News.pm ↑ Summary lib/Finance/Robinhood/Equity/Position.pm »