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