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