line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Robinhood::Equity::Account::Portfolio; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=for stopwords watchlist watchlists untradable urls |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Finance::Robinhood::Equity::Account::Portfolio - Represents a Single Portfolio |
10
|
|
|
|
|
|
|
attached to a Robinhood Account |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Finance::Robinhood; |
15
|
|
|
|
|
|
|
my $rh = Finance::Robinhood->new->login('user', 'pass'); |
16
|
|
|
|
|
|
|
my $portfolios = $rh->equity_portfolios->current(); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
for my $portfolio ($portfolios->all) { |
19
|
|
|
|
|
|
|
CORE::say $portfolio->equity; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '0.92_003'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _test__init { |
27
|
1
|
|
|
1
|
|
12080
|
my $rh = t::Utility::rh_instance(1); |
28
|
0
|
|
|
|
|
0
|
my $acct = $rh->equity_accounts->current; |
29
|
0
|
|
|
|
|
0
|
my $portfolio = $acct->portfolio; |
30
|
0
|
|
|
|
|
0
|
isa_ok($portfolio, __PACKAGE__); |
31
|
0
|
|
|
|
|
0
|
t::Utility::stash('PORTFOLIO', $portfolio); # Store it for later |
32
|
|
|
|
|
|
|
} |
33
|
1
|
|
|
1
|
|
6
|
use Mojo::Base-base, -signatures; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
34
|
1
|
|
|
1
|
|
164
|
use Mojo::URL; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
35
|
1
|
|
|
1
|
|
66
|
use overload '""' => sub ($s, @) { $s->{url} }, fallback => 1; |
|
1
|
|
|
0
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
36
|
1
|
|
|
1
|
|
59
|
use Finance::Robinhood::Equity::Instrument; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _test_stringify { |
39
|
1
|
|
50
|
1
|
|
1867
|
t::Utility::stash('PORTFOLIO') // skip_all(); |
40
|
0
|
|
|
|
|
0
|
like(+t::Utility::stash('PORTFOLIO'), |
41
|
|
|
|
|
|
|
qr'https://api.robinhood.com/portfolios/.+/'); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 METHODS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has _rh => undef => weak => 1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 C |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 C |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 C |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 C |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 C |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 C |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 C |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 C |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 C |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 C |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 C |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 C |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 C |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 C |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 C |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
has ['adjusted_equity_previous_close', 'equity', |
84
|
|
|
|
|
|
|
'equity_previous_close', 'excess_maintenance', |
85
|
|
|
|
|
|
|
'excess_maintenance_with_uncleared_deposits', 'excess_margin', |
86
|
|
|
|
|
|
|
'excess_margin_with_uncleared_deposits', 'extended_hours_equity', |
87
|
|
|
|
|
|
|
'extended_hours_market_value', 'last_core_equity', |
88
|
|
|
|
|
|
|
'last_core_market_value', 'market_value', |
89
|
|
|
|
|
|
|
'unwithdrawable_deposits', 'unwithdrawable_grants', |
90
|
|
|
|
|
|
|
'withdrawable_amount' |
91
|
|
|
|
|
|
|
]; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 C |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Returns a Time::Moment object. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
0
|
1
|
0
|
sub start_date ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
100
|
0
|
|
|
|
|
0
|
Time::Moment->from_string($s->{start_date} . 'T00:00:00Z'); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub _test_start_date { |
104
|
1
|
|
50
|
1
|
|
1909
|
t::Utility::stash('PORTFOLIO') |
105
|
|
|
|
|
|
|
// skip_all('No portfolio object in stash'); |
106
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('PORTFOLIO')->start_date, 'Time::Moment'); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 C |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Returns the related Finance::Robinhood::Equity::Account object. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
0
|
1
|
0
|
sub account ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
116
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get($s->{account}); |
117
|
|
|
|
|
|
|
return $res->is_success |
118
|
|
|
|
|
|
|
? Finance::Robinhood::Equity::Account->new(_rh => $s->_rh, |
119
|
0
|
0
|
|
|
|
0
|
%{$res->json}) |
|
0
|
0
|
|
|
|
0
|
|
120
|
|
|
|
|
|
|
: Finance::Robinhood::Error->new( |
121
|
|
|
|
|
|
|
$res->is_server_error ? (details => $res->message) : $res->json); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub _test_account { |
125
|
1
|
|
50
|
1
|
|
1985
|
t::Utility::stash('POSITION') // skip_all('No position object in stash'); |
126
|
0
|
|
|
|
|
|
isa_ok(t::Utility::stash('POSITION')->account, |
127
|
|
|
|
|
|
|
'Finance::Robinhood::Equity::Account'); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 LEGAL |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This is a simple wrapper around the API used in the official apps. The author |
133
|
|
|
|
|
|
|
provides no investment, legal, or tax advice and is not responsible for any |
134
|
|
|
|
|
|
|
damages incurred while using this software. This software is not affiliated |
135
|
|
|
|
|
|
|
with Robinhood Financial LLC in any way. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
For Robinhood's terms and disclosures, please see their website at |
138
|
|
|
|
|
|
|
https://robinhood.com/legal/ |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 LICENSE |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Copyright (C) Sanko Robinson. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
145
|
|
|
|
|
|
|
the terms found in the Artistic License 2. Other copyrights, terms, and |
146
|
|
|
|
|
|
|
conditions may apply to data transmitted through this module. Please refer to |
147
|
|
|
|
|
|
|
the L section. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
1; |