File Coverage

lib/Finance/Robinhood/Equity/Prices.pm
Criterion Covered Total %
statement 18 55 32.7
branch 0 12 0.0
condition 5 10 50.0
subroutine 10 15 66.6
pod 5 5 100.0
total 38 97 39.1


line stmt bran cond sub pod time code
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             our $VERSION = '0.92_003';
23 1     1   3874 use Mojo::Base-base, -signatures;
  1         3  
  1         11  
24 1     1   292 use Mojo::URL;
  1         2  
  1         8  
25 1     1   28 use Time::Moment;
  1         3  
  1         25  
26 1     1   6 use Finance::Robinhood::Equity::Instrument;
  1         2  
  1         7  
27              
28             sub _test__init {
29 1     1   8082 my $rh = t::Utility::rh_instance(1);
30 0         0 my $price = $rh->equity_instrument_by_symbol('MSFT')->prices();
31 0         0 isa_ok($price, __PACKAGE__);
32 0         0 t::Utility::stash('PRICES', $price); # Store it for later
33             }
34             #
35             has _rh => undef => weak => 1;
36              
37             =head1 METHODS
38              
39             =head2 C
40              
41             The current best ask price.
42              
43             =head2 C
44              
45             The current best ask price's depth.
46              
47             =head2 C
48              
49             The current best bid price.
50              
51             =head2 C
52              
53             The current best bid's depth.
54              
55             =head2 C
56              
57             The current last trade price.
58              
59             =head2 C
60              
61             Size of the last trade.
62              
63             =cut
64              
65             has ['ask_price', 'ask_size', 'bid_price', 'bid_size', 'price', 'size'];
66              
67             =head2 C
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 and C.
73              
74             =cut
75              
76 0     0 1 0 sub ask_source ($s) {
  0         0  
  0         0  
77 0 0       0 $s->_rh->equity_market_by_mic($s->{ask_mic}) if defined $s->{ask_mic};
78             }
79              
80             sub _test_ask_source {
81 1   50 1   2082 t::Utility::stash('PRICES') // skip_all();
82 0         0 my $source = t::Utility::stash('PRICES')->ask_source();
83             SKIP: {
84 0 0       0 skip('Bad mic', 1) if !$source;
  0         0  
85 0         0 isa_ok($source, 'Finance::Robinhood::Equity::Market');
86             }
87             }
88              
89             =head2 C
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 and C.
95              
96             =cut
97              
98 0     0 1 0 sub bid_source ($s) {
  0         0  
  0         0  
99 0 0       0 $s->_rh->equity_market_by_mic($s->{bid_mic}) if defined $s->{bid_mic};
100             }
101              
102             sub _test_bid_source {
103 1   50 1   1854 t::Utility::stash('PRICES') // skip_all();
104 0         0 my $source = t::Utility::stash('PRICES')->bid_source();
105             SKIP: {
106 0 0       0 skip('Bad mic', 1) if !$source;
  0         0  
107 0         0 isa_ok($source, 'Finance::Robinhood::Equity::Market');
108             }
109             }
110              
111             =head2 C
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 and C.
117              
118             =cut
119              
120 0     0 1 0 sub source ($s) {
  0         0  
  0         0  
121 0 0       0 $s->_rh->equity_market_by_mic($s->{mic}) if defined $s->{mic};
122             }
123              
124             sub _test_source {
125 1   50 1   1853 t::Utility::stash('PRICES') // skip_all();
126 0         0 my $source = t::Utility::stash('PRICES')->source();
127             SKIP: {
128 0 0       0 skip('Bad mic', 1) if !$source;
  0         0  
129 0         0 isa_ok($source, 'Finance::Robinhood::Equity::Market');
130             }
131             }
132              
133             =head2 C
134              
135             $prices->updated_at();
136              
137             Returns a Time::Moment object.
138              
139             =cut
140              
141 0     0 1 0 sub updated_at ($s) {
  0         0  
  0         0  
142 0         0 Time::Moment->from_string($s->{updated_at});
143             }
144              
145             sub _test_updated_at {
146 1   50 1   1919 t::Utility::stash('PRICES') // skip_all();
147 0         0 isa_ok(t::Utility::stash('PRICES')->updated_at(), 'Time::Moment');
148             }
149              
150             =head2 C
151              
152             my $instrument = $prices->instrument();
153              
154             Loops back to a Finance::Robinhood::Equity::Instrument object.
155              
156             =cut
157              
158 0     0 1 0 sub instrument ($s) {
  0         0  
  0         0  
159 0         0 $s->_rh->equity_instrument_by_id($s->{instrument_id});
160             }
161              
162             sub _test_instrument {
163 1   50 1   1909 t::Utility::stash('PRICES') // skip_all();
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 section.
186              
187             =head1 AUTHOR
188              
189             Sanko Robinson Esanko@cpan.orgE
190              
191             =cut
192              
193             1;