line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Robinhood::Forex::Historicals; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=for stopwords watchlist watchlists untradable urls |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Finance::Robinhood::Forex::Historicals - Represents a Forex Currency's |
10
|
|
|
|
|
|
|
Historical Price Data |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Finance::Robinhood; |
15
|
|
|
|
|
|
|
my $rh = Finance::Robinhood->new->login('user', 'pass'); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# TODO |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.92_003'; |
22
|
1
|
|
|
1
|
|
4108
|
use Mojo::Base-base, -signatures; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
23
|
1
|
|
|
1
|
|
256
|
use Mojo::URL; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _test__init { |
26
|
1
|
|
|
1
|
|
8208
|
my $rh = t::Utility::rh_instance(1); |
27
|
0
|
|
|
|
|
0
|
my $historicals = $rh->forex_pair_by_id( |
28
|
|
|
|
|
|
|
'3d961844-d360-45fc-989b-f6fca761d511') # BTC-USD |
29
|
|
|
|
|
|
|
->historicals(interval => '5minute'); |
30
|
0
|
|
|
|
|
0
|
isa_ok($historicals, __PACKAGE__); |
31
|
0
|
|
|
|
|
0
|
t::Utility::stash('HISTORICALS', $historicals); # Store it for later |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
## |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 METHODS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has _rh => undef => weak => 1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 C |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 C |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Returns a list of Finance::Robinhood::Forex::Historicals::DataPoint object. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 C |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 C |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 C |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Returns a Time::Moment object. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 C |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 C |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Returns a Time::Moment object. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 C |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 C |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
has ['bounds', 'interval', |
74
|
|
|
|
|
|
|
'open_price', 'previous_close_price', |
75
|
|
|
|
|
|
|
'span', 'symbol' |
76
|
|
|
|
|
|
|
]; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
0
|
1
|
0
|
sub data_points ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
79
|
0
|
|
|
|
|
0
|
require Finance::Robinhood::Forex::Historicals::Datapoint; |
80
|
|
|
|
|
|
|
map { |
81
|
|
|
|
|
|
|
Finance::Robinhood::Forex::Historicals::Datapoint->new(_rh => $s->_rh, |
82
|
0
|
|
|
|
|
0
|
%{$_}) |
|
0
|
|
|
|
|
0
|
|
83
|
0
|
|
|
|
|
0
|
} @{$s->{data_points}}; |
|
0
|
|
|
|
|
0
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _test_data_points { |
87
|
1
|
|
50
|
1
|
|
1946
|
t::Utility::stash('HISTORICALS') |
88
|
|
|
|
|
|
|
// skip_all('No historicals object in stash'); |
89
|
0
|
|
|
|
|
0
|
my ($datapoint) = t::Utility::stash('HISTORICALS')->data_points; |
90
|
0
|
|
|
|
|
0
|
isa_ok($datapoint, 'Finance::Robinhood::Forex::Historicals::Datapoint'); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
0
|
1
|
0
|
sub open_time ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
94
|
0
|
|
|
|
|
0
|
Time::Moment->from_string($s->{open_time}); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _test_open_time { |
98
|
1
|
|
50
|
1
|
|
1848
|
t::Utility::stash('HISTORICALS') |
99
|
|
|
|
|
|
|
// skip_all('No historicals object in stash'); |
100
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('HISTORICALS')->open_time, 'Time::Moment'); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 C |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Returns a Time::Moment object. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
0
|
1
|
0
|
sub previous_close_time ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
110
|
0
|
|
|
|
|
0
|
Time::Moment->from_string($s->{previous_close_time}); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub _test_previous_close_time { |
114
|
1
|
|
50
|
1
|
|
1855
|
t::Utility::stash('HISTORICALS') |
115
|
|
|
|
|
|
|
// skip_all('No historicals object in stash'); |
116
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('HISTORICALS')->previous_close_time, |
117
|
|
|
|
|
|
|
'Time::Moment'); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 C |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns the related Finance::Robinhood::Forex::Pair object. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
0
|
1
|
0
|
sub pair ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
127
|
0
|
|
|
|
|
0
|
$s->_rh->forex_pair_by_id($s->{id}); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub _test_instrument { |
131
|
1
|
|
50
|
1
|
|
1898
|
t::Utility::stash('HISTORICALS') |
132
|
|
|
|
|
|
|
// skip_all('No historicals object in stash'); |
133
|
0
|
|
|
|
|
|
isa_ok(t::Utility::stash('HISTORICALS')->pair, |
134
|
|
|
|
|
|
|
'Finance::Robinhood::Forex::Pair'); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 LEGAL |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This is a simple wrapper around the API used in the official apps. The author |
140
|
|
|
|
|
|
|
provides no investment, legal, or tax advice and is not responsible for any |
141
|
|
|
|
|
|
|
damages incurred while using this software. This software is not affiliated |
142
|
|
|
|
|
|
|
with Robinhood Financial LLC in any way. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
For Robinhood's terms and disclosures, please see their website at |
145
|
|
|
|
|
|
|
https://robinhood.com/legal/ |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 LICENSE |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Copyright (C) Sanko Robinson. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
152
|
|
|
|
|
|
|
the terms found in the Artistic License 2. Other copyrights, terms, and |
153
|
|
|
|
|
|
|
conditions may apply to data transmitted through this module. Please refer to |
154
|
|
|
|
|
|
|
the L section. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 AUTHOR |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |