line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Robinhood::Forex::Holding; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=for stopwords watchlist watchlists untradable urls forex |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Finance::Robinhood::Forex::Holding - Represents a Single Forex Currency Holding |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Finance::Robinhood; |
14
|
|
|
|
|
|
|
my $rh = Finance::Robinhood->new; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# TODO |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.92_003'; |
21
|
1
|
|
|
1
|
|
3762
|
use Mojo::Base-base, -signatures; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
22
|
1
|
|
|
1
|
|
249
|
use Mojo::URL; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
23
|
1
|
|
|
1
|
|
31
|
use Finance::Robinhood::Forex::Currency; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
24
|
1
|
|
|
1
|
|
26
|
use Finance::Robinhood::Forex::Cost; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
25
|
1
|
|
|
1
|
|
40
|
use Time::Moment; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
157
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _test__init { |
28
|
1
|
|
|
1
|
|
8331
|
my $rh = t::Utility::rh_instance(1); |
29
|
0
|
|
|
|
|
0
|
my $holding = $rh->forex_holdings->current; |
30
|
0
|
|
|
|
|
0
|
isa_ok($holding, __PACKAGE__); |
31
|
0
|
|
|
|
|
0
|
t::Utility::stash('HOLDING', $holding); # Store it for later |
32
|
|
|
|
|
|
|
} |
33
|
1
|
|
|
1
|
|
8
|
use overload '""' => sub ($s, @) { $s->{id} }, fallback => 1; |
|
1
|
|
|
0
|
|
4
|
|
|
1
|
|
|
|
|
11
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _test_stringify { |
36
|
1
|
|
50
|
1
|
|
1933
|
t::Utility::stash('HOLDING') // skip_all(); |
37
|
0
|
|
|
|
|
0
|
like(+t::Utility::stash('HOLDING'), |
38
|
|
|
|
|
|
|
qr'^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'i |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
# |
42
|
|
|
|
|
|
|
has _rh => undef => weak => 1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 METHODS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 C |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Returns a UUID. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 C |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Total asset size. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 C |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Amount not being held for outstanding orders. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 C |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Amount being held for outstanding buy orders. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 C |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Amount being held for outstanding sell orders. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has ['id', 'quantity', |
70
|
|
|
|
|
|
|
'quantity_available', 'quantity_held_for_buy', |
71
|
|
|
|
|
|
|
'quantity_held_for_sell' |
72
|
|
|
|
|
|
|
]; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 C |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Returns a Finance::Robinhood::Forex::Currency object. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
0
|
1
|
0
|
sub currency ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
81
|
|
|
|
|
|
|
Finance::Robinhood::Forex::Currency->new(_rh => $s->_rh, |
82
|
0
|
|
|
|
|
0
|
%{$s->{currency}}); |
|
0
|
|
|
|
|
0
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _test_currency { |
86
|
1
|
|
50
|
1
|
|
1874
|
t::Utility::stash('HOLDING') // skip_all(); |
87
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('HOLDING')->currency, |
88
|
|
|
|
|
|
|
'Finance::Robinhood::Forex::Currency'); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 C |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Returns a Time::Moment object. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
0
|
1
|
0
|
sub created_at ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
98
|
0
|
|
|
|
|
0
|
Time::Moment->from_string($s->{created_at}); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub _test_created_at { |
102
|
1
|
|
50
|
1
|
|
1853
|
t::Utility::stash('HOLDING') // skip_all(); |
103
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('HOLDING')->created_at, 'Time::Moment'); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 C |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Returns a Time::Moment object. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
0
|
1
|
0
|
sub updated_at ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
113
|
0
|
|
|
|
|
0
|
Time::Moment->from_string($s->{updated_at}); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub _test_updated_at { |
117
|
1
|
|
50
|
1
|
|
1894
|
t::Utility::stash('PAIR') // skip_all(); |
118
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('PAIR')->updated_at, 'Time::Moment'); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 C |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
my $acct = $holding->account(); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Returns a Finance::Robinhood::Forex::Account object. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
0
|
1
|
0
|
sub account ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
130
|
0
|
|
|
|
|
0
|
$s->_rh->forex_account_by_id($s->{account_id}); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub _test_account { |
134
|
1
|
|
50
|
1
|
|
2086
|
t::Utility::stash('HOLDING') // skip_all(); |
135
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('HOLDING')->account(), |
136
|
|
|
|
|
|
|
'Finance::Robinhood::Forex::Account'); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 C |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Returns a list of Finance::Robinhood::Forex::Holding::Cost objects. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
0
|
1
|
0
|
sub cost_bases ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
146
|
0
|
|
|
|
|
0
|
map { Finance::Robinhood::Forex::Cost->new(_rh => $s->_rh, %{$_}); } |
|
0
|
|
|
|
|
0
|
|
147
|
0
|
|
|
|
|
0
|
@{$s->{cost_bases}}; |
|
0
|
|
|
|
|
0
|
|
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub _test_cost_bases { |
151
|
1
|
|
50
|
1
|
|
1831
|
t::Utility::stash('HOLDING') // skip_all(); |
152
|
0
|
|
|
|
|
|
my ($cost_base) = t::Utility::stash('HOLDING')->cost_bases(); |
153
|
0
|
0
|
|
|
|
|
$cost_base || skip_all('No currency holdings with defined cost bases.'); |
154
|
0
|
|
|
|
|
|
isa_ok($cost_base, 'Finance::Robinhood::Forex::Cost'); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 LEGAL |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This is a simple wrapper around the API used in the official apps. The author |
160
|
|
|
|
|
|
|
provides no investment, legal, or tax advice and is not responsible for any |
161
|
|
|
|
|
|
|
damages incurred while using this software. This software is not affiliated |
162
|
|
|
|
|
|
|
with Robinhood Financial LLC in any way. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
For Robinhood's terms and disclosures, please see their website at |
165
|
|
|
|
|
|
|
https://robinhood.com/legal/ |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 LICENSE |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Copyright (C) Sanko Robinson. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
172
|
|
|
|
|
|
|
the terms found in the Artistic License 2. Other copyrights, terms, and |
173
|
|
|
|
|
|
|
conditions may apply to data transmitted through this module. Please refer to |
174
|
|
|
|
|
|
|
the L section. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 AUTHOR |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
1; |