line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Robinhood::Equity::Account::MarginBalances; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=for stopwords watchlist watchlists untradable urls |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Finance::Robinhood::Equity::Account - Robinhood Account's Instant or Gold |
10
|
|
|
|
|
|
|
Margin Account Balances |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Finance::Robinhood; |
15
|
|
|
|
|
|
|
my $rh = Finance::Robinhood->new->login('user', 'pass'); |
16
|
|
|
|
|
|
|
my $account = $rh->equity_accounts->current(); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
CORE::say 'How much can I borrow? ' . $account->margin_balances->margin_limit; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.92_003'; |
23
|
1
|
|
|
1
|
|
6
|
use Mojo::Base-base, -signatures; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
24
|
1
|
|
|
1
|
|
151
|
use Mojo::URL; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _test__init { |
27
|
1
|
|
|
1
|
|
11586
|
my $rh = t::Utility::rh_instance(1); |
28
|
0
|
|
|
|
|
0
|
my $acct = $rh->equity_accounts->current; |
29
|
0
|
|
|
|
|
0
|
my $margin_balances = $acct->margin_balances; |
30
|
0
|
|
|
|
|
0
|
isa_ok($margin_balances, __PACKAGE__); |
31
|
0
|
|
|
|
|
0
|
t::Utility::stash('MARGIN', $margin_balances); # Store it for later |
32
|
|
|
|
|
|
|
} |
33
|
1
|
|
|
1
|
|
133
|
use overload '""' => sub ($s, @) { +$s->{created_at} }, fallback => 1; |
|
1
|
|
|
0
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _test_stringify { |
36
|
1
|
|
50
|
1
|
|
1879
|
t::Utility::stash('MARGIN') // skip_all(); |
37
|
0
|
|
|
|
|
0
|
like(+t::Utility::stash('MARGIN'), |
38
|
|
|
|
|
|
|
qr'^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d\.\d+Z$'); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 METHODS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has _rh => undef => weak => 1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 C |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 C |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 C |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 C |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 C |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 C |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 C |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 C |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 C |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 C |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 C |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 C |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 C |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 C |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 C |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 C |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 C |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 C |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 C |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 C |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 C |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 C |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 C |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 C |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
has ['cash', |
102
|
|
|
|
|
|
|
'cash_available_for_withdrawal', |
103
|
|
|
|
|
|
|
'cash_held_for_dividends', |
104
|
|
|
|
|
|
|
'cash_held_for_nummus_restrictions', |
105
|
|
|
|
|
|
|
'cash_held_for_options_collateral', |
106
|
|
|
|
|
|
|
'cash_held_for_orders', |
107
|
|
|
|
|
|
|
'cash_pending_from_options_events', |
108
|
|
|
|
|
|
|
'day_trade_buying_power', |
109
|
|
|
|
|
|
|
'day_trade_buying_power_held_for_orders', |
110
|
|
|
|
|
|
|
'day_trade_ratio', |
111
|
|
|
|
|
|
|
'gold_equity_requirement', |
112
|
|
|
|
|
|
|
'margin_limit', |
113
|
|
|
|
|
|
|
'outstanding_interest', |
114
|
|
|
|
|
|
|
'overnight_buying_power', |
115
|
|
|
|
|
|
|
'overnight_buying_power_held_for_orders', |
116
|
|
|
|
|
|
|
'overnight_ratio', |
117
|
|
|
|
|
|
|
'sma', |
118
|
|
|
|
|
|
|
'start_of_day_dtbp', |
119
|
|
|
|
|
|
|
'start_of_day_overnight_buying_power', |
120
|
|
|
|
|
|
|
'unallocated_margin_cash', |
121
|
|
|
|
|
|
|
'uncleared_deposits', |
122
|
|
|
|
|
|
|
'uncleared_nummus_deposits', |
123
|
|
|
|
|
|
|
'unsettled_debit', |
124
|
|
|
|
|
|
|
'unsettled_funds', |
125
|
|
|
|
|
|
|
]; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 C |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Returns a Time::Moment object if applicable. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
0
|
1
|
0
|
sub marked_pattern_day_trader_date ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
134
|
|
|
|
|
|
|
defined $s->{marked_pattern_day_trader_date} |
135
|
|
|
|
|
|
|
? Time::Moment->from_string($s->{marked_pattern_day_trader_date}) |
136
|
0
|
0
|
|
|
|
0
|
: (); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub _test_marked_pattern_day_trader_date { |
140
|
1
|
|
50
|
1
|
|
1856
|
t::Utility::stash('MARGIN') |
141
|
|
|
|
|
|
|
// skip_all('No margin balances object in stash'); |
142
|
0
|
0
|
|
|
|
0
|
skip_all('Not marked as a PDT') |
143
|
|
|
|
|
|
|
if ! |
144
|
|
|
|
|
|
|
defined t::Utility::stash('MARGIN')->marked_pattern_day_trader_date; |
145
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('MARGIN')->marked_pattern_day_trader_date, |
146
|
|
|
|
|
|
|
'Time::Moment'); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 C |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Returns a Time::Moment object. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|
155
|
0
|
|
|
0
|
1
|
0
|
sub created_at ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
156
|
0
|
|
|
|
|
0
|
Time::Moment->from_string($s->{created_at}); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub _test_created_at { |
160
|
1
|
|
50
|
1
|
|
1972
|
t::Utility::stash('MARGIN') |
161
|
|
|
|
|
|
|
// skip_all('No margin balances object in stash'); |
162
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('MARGIN')->created_at, 'Time::Moment'); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 C |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Returns a Time::Moment object if applicable. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
170
|
|
|
|
|
|
|
|
171
|
0
|
|
|
0
|
1
|
0
|
sub updated_at ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
172
|
0
|
|
|
|
|
0
|
Time::Moment->from_string($s->{updated_at}); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub _test_updated_at { |
176
|
1
|
|
50
|
1
|
|
1845
|
t::Utility::stash('MARGIN') |
177
|
|
|
|
|
|
|
// skip_all('No margin balances object in stash'); |
178
|
0
|
|
|
|
|
|
isa_ok(t::Utility::stash('MARGIN')->updated_at, 'Time::Moment'); |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 LEGAL |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This is a simple wrapper around the API used in the official apps. The author |
184
|
|
|
|
|
|
|
provides no investment, legal, or tax advice and is not responsible for any |
185
|
|
|
|
|
|
|
damages incurred while using this software. This software is not affiliated |
186
|
|
|
|
|
|
|
with Robinhood Financial LLC in any way. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
For Robinhood's terms and disclosures, please see their website at |
189
|
|
|
|
|
|
|
https://robinhood.com/legal/ |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 LICENSE |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Copyright (C) Sanko Robinson. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
196
|
|
|
|
|
|
|
the terms found in the Artistic License 2. Other copyrights, terms, and |
197
|
|
|
|
|
|
|
conditions may apply to data transmitted through this module. Please refer to |
198
|
|
|
|
|
|
|
the L section. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 AUTHOR |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
1; |