| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Finance::Robinhood::Options::Chain; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=for stopwords watchlist watchlists untradable urls |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Finance::Robinhood::Options::Chain - Represents a Single Options Chain |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Finance::Robinhood; |
|
14
|
|
|
|
|
|
|
my $rh = Finance::Robinhood->new->login('user', 'pass'); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# TODO |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 METHODS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.92_003'; |
|
23
|
1
|
|
|
1
|
|
9
|
use Mojo::Base-base, -signatures; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
12
|
|
|
24
|
1
|
|
|
1
|
|
328
|
use Mojo::URL; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
8
|
|
|
25
|
1
|
|
|
1
|
|
35
|
use Time::Moment; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
26
|
1
|
|
|
1
|
|
416
|
use Finance::Robinhood::Options::Chain::Ticks; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
6
|
|
|
27
|
1
|
|
|
1
|
|
444
|
use Finance::Robinhood::Options::Chain::Underlying; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
5
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _test__init { |
|
30
|
1
|
|
|
1
|
|
12090
|
my $rh = t::Utility::rh_instance(0); |
|
31
|
1
|
|
|
|
|
13
|
my $chains = $rh->options_chains; |
|
32
|
1
|
|
|
|
|
234
|
my $chain; |
|
33
|
1
|
|
|
|
|
6
|
while ($chains->has_next) { |
|
34
|
1
|
|
|
|
|
17
|
my @dates = $chains->next->expiration_dates; |
|
35
|
1
|
50
|
|
|
|
6
|
if (@dates) { |
|
36
|
1
|
|
|
|
|
5
|
$chain = $chains->current; |
|
37
|
1
|
|
|
|
|
8
|
last; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
} |
|
40
|
1
|
|
|
|
|
7
|
isa_ok($chain, __PACKAGE__); |
|
41
|
1
|
|
|
|
|
416
|
t::Utility::stash('CHAIN', $chain); # Store it for later |
|
42
|
|
|
|
|
|
|
} |
|
43
|
8
|
|
|
8
|
|
11
|
use overload '""' => sub ($s, @) { |
|
|
8
|
|
|
|
|
414
|
|
|
|
8
|
|
|
|
|
17
|
|
|
44
|
8
|
|
|
|
|
64
|
'https://api.robinhood.com/options/chains/' . $s->{id} . '/'; |
|
45
|
|
|
|
|
|
|
}, |
|
46
|
1
|
|
|
1
|
|
198
|
fallback => 1; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _test_stringify { |
|
49
|
1
|
|
50
|
1
|
|
2075
|
t::Utility::stash('CHAIN') // skip_all(); |
|
50
|
1
|
|
|
|
|
5
|
like(+t::Utility::stash('CHAIN'), |
|
51
|
|
|
|
|
|
|
qr'^https://api.robinhood.com/options/chains/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/$'i |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
has _rh => undef => weak => 1; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 C |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Returns a boolean value. True if you may open a new position. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 C |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
If defined, a dollar amount. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 C |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Returns a UUID. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 C |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Chain's ticker symbol. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 C |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
has ['can_open_position', 'cash_component', |
|
79
|
|
|
|
|
|
|
'id', 'symbol', |
|
80
|
|
|
|
|
|
|
'trade_value_multiplier' |
|
81
|
|
|
|
|
|
|
]; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 C |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Returns a list of Time::Moment objects. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
|
88
|
|
|
|
|
|
|
|
|
89
|
2
|
|
|
2
|
1
|
12
|
sub expiration_dates($s) { |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
4
|
|
|
90
|
8
|
|
|
|
|
53
|
map { Time::Moment->from_string($_ . 'T00:00:00Z') } |
|
91
|
2
|
|
|
|
|
4
|
@{$s->{expiration_dates}}; |
|
|
2
|
|
|
|
|
8
|
|
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _test_expiration_dates { |
|
95
|
1
|
|
50
|
1
|
|
2863
|
t::Utility::stash('CHAIN') // skip_all(); |
|
96
|
1
|
|
|
|
|
6
|
my ($date) = t::Utility::stash('CHAIN')->expiration_dates; |
|
97
|
1
|
|
|
|
|
5
|
isa_ok($date, 'Time::Moment'); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 C |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns a list of Finance::Robinhood::Options::Chain::Underlying objects. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
1
|
|
|
1
|
1
|
12
|
sub underlying_instruments($s) { |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
2
|
|
|
107
|
|
|
|
|
|
|
map { |
|
108
|
1
|
|
|
|
|
4
|
Finance::Robinhood::Options::Chain::Underlying->new(_rh => $s->_rh, |
|
109
|
|
|
|
|
|
|
%$_) |
|
110
|
1
|
|
|
|
|
2
|
} @{$s->{underlying_instruments}}; |
|
|
1
|
|
|
|
|
4
|
|
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub _test_underlying_instruments { |
|
114
|
1
|
|
50
|
1
|
|
2089
|
t::Utility::stash('CHAIN') // skip_all(); |
|
115
|
1
|
|
|
|
|
9
|
my ($underlying) = t::Utility::stash('CHAIN')->underlying_instruments; |
|
116
|
1
|
|
|
|
|
104
|
isa_ok($underlying, 'Finance::Robinhood::Options::Chain::Underlying'); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 C |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns a Finance::Robinhood::Options::Chain::Ticks object. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
|
124
|
|
|
|
|
|
|
|
|
125
|
2
|
|
|
2
|
1
|
20
|
sub min_ticks ($s) { |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
3
|
|
|
126
|
|
|
|
|
|
|
Finance::Robinhood::Options::Chain::Ticks->new(_rh => $s->_rh, |
|
127
|
2
|
|
|
|
|
10
|
%{$s->{min_ticks}}); |
|
|
2
|
|
|
|
|
43
|
|
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub _test_min_ticks { |
|
131
|
1
|
|
50
|
1
|
|
2104
|
t::Utility::stash('CHAIN') // skip_all(); |
|
132
|
1
|
|
|
|
|
4
|
isa_ok(t::Utility::stash('CHAIN')->min_ticks, |
|
133
|
|
|
|
|
|
|
'Finance::Robinhood::Options::Chain::Ticks'); |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 LEGAL |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This is a simple wrapper around the API used in the official apps. The author |
|
139
|
|
|
|
|
|
|
provides no investment, legal, or tax advice and is not responsible for any |
|
140
|
|
|
|
|
|
|
damages incurred while using this software. This software is not affiliated |
|
141
|
|
|
|
|
|
|
with Robinhood Financial LLC in any way. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
For Robinhood's terms and disclosures, please see their website at |
|
144
|
|
|
|
|
|
|
https://robinhood.com/legal/ |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 LICENSE |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Copyright (C) Sanko Robinson. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
|
151
|
|
|
|
|
|
|
the terms found in the Artistic License 2. Other copyrights, terms, and |
|
152
|
|
|
|
|
|
|
conditions may apply to data transmitted through this module. Please refer to |
|
153
|
|
|
|
|
|
|
the L section. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 AUTHOR |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; |