lib/Finance/Robinhood/Options/Instrument.pm

filter: Statementstmt 59.3% 19 / 32 Branchbran n/a Conditioncond 50.0% 5 / 10 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 64.2% 9 / 14 Podpod 100% 4 / 4 totaltotal 52.8% 37 / 70 CC 6 SCAR 7.1
CC
6
Cov
57%
_test_stringify
2.5
_test_expiration_date
2.5
_test_issue_date
2.5
CRAP 2.0
« lib/Finance/Robinhood/Equity/Market.pm ↑ Summary lib/Finance/Robinhood/Search.pm »
1 package Finance::Robinhood::Options::Instrument;
2  
3 =encoding utf-8
4  
5 =for stopwords watchlist watchlists untradable urls
6  
7 =head1 NAME
8  
9 Finance::Robinhood::Options::Instrument - Represents a Single Options
10 Instrument
11  
12 =head1 SYNOPSIS
13  
14 use Finance::Robinhood;
15 my $rh = Finance::Robinhood->new;
16 my $instruments = $rh->options_instruments();
17  
18 for my $instrument ($instruments->all) {
19 CORE::say $instrument->chain_symbol;
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  
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 $instrument =
31 $rh->options_instruments(
32 chain_id =>
33 $rh->equity_instrument_by_symbol('MSFT')->tradable_chain_id,
34 tradability => 'tradable'
35 )->current;
36 0 isa_ok($instrument, __PACKAGE__);
37 0 t::Utility::stash('INSTRUMENT', $instrument); # Store it for later
38 }
39 0 ▶use overload '""' => sub ($s, @) { $s->{url} }, fallback => 1;
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine __ANON__: not called CC=1 SCAR=0.2
40  
41 1 ▶sub _test_stringify {
Subroutine _test_stringify: called CC=2 SCAR=9.2
42 1 ▶ t::Utility::stash('INSTRUMENT') // skip_all();
Condition50%1/2
t::Utility::stash("INSTRUMENT") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("INSTRUMENT") // skip_all()
t::Utility::stash("INSTRUMENT") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("INSTRUMENT")B= skip_all()
ABresult
1X1
011
000
43 0 is(+t::Utility::stash('INSTRUMENT'),
44 'https://api.robinhood.com/options/instruments/' .
45 t::Utility::stash('INSTRUMENT')->id . '/');
46 }
47 #
48 1 has _rh => undef => weak => 1;
49  
50 =head1 METHODS
51  
52 =head2 C<chain_id()>
53  
54  
55 =head2 C<chain_symbol()>
56  
57  
58 =head2 C<id( )>
59  
60 UUID used to identify this instrument.
61  
62 =head2 C<min_ticks( )>
63  
64 Returns a hash reference with the following keys:
65  
66 =over
67  
68 =item C<above_tick> - Minimum tick size when applicable.
69  
70 =item C<below_tick> - Minimum tick size when applicable.
71  
72 =item C<cutoff_price> - At this price or more, the C<above_tick> will apply. Below this price, the C<below_tick> is required.
73  
74 =back
75  
76 =head2 C<rhs_tradability( )>
77  
78 Exposes whether or not this instrument can be traded on Robinhood. Either
79 C<tradable> or C<untradable>.
80  
81 =head2 C<state( )>
82  
83  
84  
85 =head2 C<strike_price( )>
86  
87 The strike of this particular instrument.
88  
89 =head2 C<tradability( )>
90  
91 Indicates whether this instrument is being traded in general.
92  
93 =head2 C<type( )>
94  
95 Indicated whether this is a C<call> or C<put>.
96  
97 =cut
98  
99 1 has ['chain_id', 'chain_symbol', 'id', 'min_ticks',
100 'rhs_tradability', 'state', 'strike_price', 'tradability',
101 'type',
102 ];
103  
104 =head2 C<expiration_date( )>
105  
106 Returns a Time::Moment object.
107  
108 =cut
109  
110 0 ▶sub expiration_date ($s) {
Subroutine expiration_date: not called CC=1 SCAR=6.9
Pod documented
111 0 Time::Moment->from_string($s->{expiration_date} . 'T00:00:00Z');
112 }
113  
114 1 ▶sub _test_expiration_date {
Subroutine _test_expiration_date: called CC=2 SCAR=9.2
115 1 ▶ t::Utility::stash('INSTRUMENT') // skip_all();
Condition50%1/2
t::Utility::stash("INSTRUMENT") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("INSTRUMENT") // skip_all()
t::Utility::stash("INSTRUMENT") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("INSTRUMENT")B= skip_all()
ABresult
1X1
011
000
116 0 isa_ok(t::Utility::stash('INSTRUMENT')->expiration_date, 'Time::Moment');
117 }
118  
119 =head2 C<issue_date( )>
120  
121 Returns a Time::Moment object.
122  
123 =cut
124  
125 0 ▶sub issue_date ($s) {
Subroutine issue_date: not called CC=1 SCAR=6.9
Pod documented
126 0 Time::Moment->from_string($s->{issue_date} . 'T00:00:00Z');
127 }
128  
129 1 ▶sub _test_issue_date {
Subroutine _test_issue_date: called CC=2 SCAR=9.2
130 1 ▶ t::Utility::stash('INSTRUMENT') // skip_all();
Condition50%1/2
t::Utility::stash("INSTRUMENT") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("INSTRUMENT") // skip_all()
t::Utility::stash("INSTRUMENT") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("INSTRUMENT")B= skip_all()
ABresult
1X1
011
000
131 0 isa_ok(t::Utility::stash('INSTRUMENT')->issue_date, 'Time::Moment');
132 }
133  
134 =head2 C<created_at( )>
135  
136 Returns a Time::Moment object.
137  
138 =cut
139  
140 0 ▶sub created_at ($s) {
Subroutine created_at: not called CC=1 SCAR=6.9
Pod documented
141 0 Time::Moment->from_string($s->{created_at});
142 }
143  
144 1 ▶sub _test_created_at {
Subroutine _test_created_at: called CC=2 SCAR=9.2
145 1 ▶ t::Utility::stash('INSTRUMENT') // skip_all();
Condition50%1/2
t::Utility::stash("INSTRUMENT") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("INSTRUMENT") // skip_all()
t::Utility::stash("INSTRUMENT") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("INSTRUMENT")B= skip_all()
ABresult
1X1
011
000
146 0 isa_ok(t::Utility::stash('INSTRUMENT')->created_at, 'Time::Moment');
147 }
148  
149 =head2 C<updated_at( )>
150  
151 Returns a Time::Moment object.
152  
153 =cut
154  
155 0 ▶sub updated_at ($s) {
Subroutine updated_at: not called CC=1 SCAR=6.9
Pod documented
156 0 Time::Moment->from_string($s->{updated_at});
157 }
158  
159 1 ▶sub _test_updated_at {
Subroutine _test_updated_at: called CC=2 SCAR=9.2
160 1 ▶ t::Utility::stash('INSTRUMENT') // skip_all();
Condition50%1/2
t::Utility::stash("INSTRUMENT") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("INSTRUMENT") // skip_all()
t::Utility::stash("INSTRUMENT") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("INSTRUMENT")B= skip_all()
ABresult
1X1
011
000
161 0 isa_ok(t::Utility::stash('INSTRUMENT')->updated_at, 'Time::Moment');
162 }
163  
164 =head1 LEGAL
165  
166 This is a simple wrapper around the API used in the official apps. The author
167 provides no investment, legal, or tax advice and is not responsible for any
168 damages incurred while using this software. This software is not affiliated
169 with Robinhood Financial LLC in any way.
170  
171 For Robinhood's terms and disclosures, please see their website at
172 https://robinhood.com/legal/
173  
174 =head1 LICENSE
175  
176 Copyright (C) Sanko Robinson.
177  
178 This library is free software; you can redistribute it and/or modify it under
179 the terms found in the Artistic License 2. Other copyrights, terms, and
180 conditions may apply to data transmitted through this module. Please refer to
181 the L<LEGAL> section.
182  
183 =head1 AUTHOR
184  
185 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
186  
187 =cut
188  
189 1 1;
« lib/Finance/Robinhood/Equity/Market.pm ↑ Summary lib/Finance/Robinhood/Search.pm »