line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
|
|
|
|
our $VERSION = '0.92_003'; |
25
|
1
|
|
|
1
|
|
9
|
use Mojo::Base-base, -signatures; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
13
|
|
26
|
1
|
|
|
1
|
|
362
|
use Mojo::URL; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _test__init { |
29
|
1
|
|
|
1
|
|
11318
|
my $rh = t::Utility::rh_instance(1); |
30
|
0
|
|
|
|
|
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
|
|
|
|
|
0
|
isa_ok($instrument, __PACKAGE__); |
37
|
0
|
|
|
|
|
0
|
t::Utility::stash('INSTRUMENT', $instrument); # Store it for later |
38
|
|
|
|
|
|
|
} |
39
|
1
|
|
|
1
|
|
190
|
use overload '""' => sub ($s, @) { $s->{url} }, fallback => 1; |
|
1
|
|
|
0
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _test_stringify { |
42
|
1
|
|
50
|
1
|
|
1927
|
t::Utility::stash('INSTRUMENT') // skip_all(); |
43
|
0
|
|
|
|
|
0
|
is(+t::Utility::stash('INSTRUMENT'), |
44
|
|
|
|
|
|
|
'https://api.robinhood.com/options/instruments/' . |
45
|
|
|
|
|
|
|
t::Utility::stash('INSTRUMENT')->id . '/'); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
has _rh => undef => weak => 1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 METHODS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 C |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 C |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 C |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
UUID used to identify this instrument. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 C |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Returns a hash reference with the following keys: |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=over |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item C - Minimum tick size when applicable. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item C - Minimum tick size when applicable. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item C - At this price or more, the C will apply. Below this price, the C is required. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=back |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 C |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Exposes whether or not this instrument can be traded on Robinhood. Either |
79
|
|
|
|
|
|
|
C or C. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 C |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 C |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
The strike of this particular instrument. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 C |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Indicates whether this instrument is being traded in general. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 C |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Indicated whether this is a C or C. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
has ['chain_id', 'chain_symbol', 'id', 'min_ticks', |
100
|
|
|
|
|
|
|
'rhs_tradability', 'state', 'strike_price', 'tradability', |
101
|
|
|
|
|
|
|
'type', |
102
|
|
|
|
|
|
|
]; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 C |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns a Time::Moment object. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
0
|
1
|
0
|
sub expiration_date ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
111
|
0
|
|
|
|
|
0
|
Time::Moment->from_string($s->{expiration_date} . 'T00:00:00Z'); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub _test_expiration_date { |
115
|
1
|
|
50
|
1
|
|
1945
|
t::Utility::stash('INSTRUMENT') // skip_all(); |
116
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('INSTRUMENT')->expiration_date, 'Time::Moment'); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 C |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns a Time::Moment object. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
0
|
1
|
0
|
sub issue_date ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
126
|
0
|
|
|
|
|
0
|
Time::Moment->from_string($s->{issue_date} . 'T00:00:00Z'); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub _test_issue_date { |
130
|
1
|
|
50
|
1
|
|
1864
|
t::Utility::stash('INSTRUMENT') // skip_all(); |
131
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('INSTRUMENT')->issue_date, 'Time::Moment'); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 C |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Returns a Time::Moment object. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
0
|
1
|
0
|
sub created_at ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
141
|
0
|
|
|
|
|
0
|
Time::Moment->from_string($s->{created_at}); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub _test_created_at { |
145
|
1
|
|
50
|
1
|
|
1972
|
t::Utility::stash('INSTRUMENT') // skip_all(); |
146
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('INSTRUMENT')->created_at, 'Time::Moment'); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 C |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Returns a Time::Moment object. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|
155
|
0
|
|
|
0
|
1
|
0
|
sub updated_at ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
156
|
0
|
|
|
|
|
0
|
Time::Moment->from_string($s->{updated_at}); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub _test_updated_at { |
160
|
1
|
|
50
|
1
|
|
1871
|
t::Utility::stash('INSTRUMENT') // skip_all(); |
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 section. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 AUTHOR |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
1; |