line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Robinhood::Forex::Watchlist; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=for stopwords watchlist watchlists untradable urls |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Finance::Robinhood::Forex::Watchlist - Represents a Single Forex/Crypto |
10
|
|
|
|
|
|
|
Watchlist |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Finance::Robinhood; |
15
|
|
|
|
|
|
|
my $rh = Finance::Robinhood->new; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# TODO |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.92_002'; |
22
|
1
|
|
|
1
|
|
4005
|
use Mojo::Base-base, -signatures; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
23
|
1
|
|
|
1
|
|
297
|
use Mojo::URL; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
24
|
1
|
|
|
1
|
|
28
|
use Time::Moment; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
153
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _test__init { |
27
|
1
|
|
|
1
|
|
8121
|
my $rh = t::Utility::rh_instance(1); |
28
|
0
|
|
|
|
|
0
|
my $watchlist = $rh->forex_watchlists->current; |
29
|
0
|
|
|
|
|
0
|
isa_ok( $watchlist, __PACKAGE__ ); |
30
|
0
|
|
|
|
|
0
|
t::Utility::stash( 'WATCHLIST', $watchlist ); # Store it for later |
31
|
|
|
|
|
|
|
} |
32
|
1
|
|
|
1
|
|
9
|
use overload '""' => sub ( $s, @ ) { $s->{id} }, fallback => 1; |
|
1
|
|
|
0
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _test_stringify { |
35
|
1
|
|
50
|
1
|
|
1874
|
t::Utility::stash('WATCHLIST') // skip_all(); |
36
|
0
|
|
|
|
|
0
|
like( |
37
|
|
|
|
|
|
|
+t::Utility::stash('WATCHLIST'), |
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
|
|
|
|
|
|
|
=head2 C |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Returns a Time::Moment object. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 C |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Returns a UUID. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 C |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 C |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Returns a Time::Moment object. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has [ 'id', 'name' ]; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
0
|
1
|
0
|
sub created_at ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
67
|
0
|
|
|
|
|
0
|
Time::Moment->from_string( $s->{created_at} ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _test_created_at { |
71
|
1
|
|
50
|
1
|
|
2018
|
t::Utility::stash('WATCHLIST') // skip_all(); |
72
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('WATCHLIST')->created_at, 'Time::Moment' ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
1
|
0
|
sub updated_at ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
76
|
0
|
|
|
|
|
0
|
Time::Moment->from_string( $s->{updated_at} ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _test_updated_at { |
80
|
1
|
|
50
|
1
|
|
1822
|
t::Utility::stash('WATCHLIST') // skip_all(); |
81
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('WATCHLIST')->updated_at, 'Time::Moment' ); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 C |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
$watchlist->pair_ids( ) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns a list of UUIDs. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
$watchlist->pair_ids( |
91
|
|
|
|
|
|
|
"76637d50-c702-4ed1-bcb5-5b0732a81f48", |
92
|
|
|
|
|
|
|
"3d961844-d360-45fc-989b-f6fca761d511" ); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Updates the watchlist with a list of currency pairs. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
0
|
1
|
0
|
sub pair_ids ( $s, @ids ) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
99
|
0
|
0
|
|
|
|
0
|
return $s->{pair_ids} if !@ids; |
100
|
|
|
|
|
|
|
my $res = $s->_rh->_patch( |
101
|
0
|
|
|
|
|
0
|
'https://nummus.robinhood.com/watchlists/' . $s->{id} . '/', |
102
|
|
|
|
|
|
|
pair_ids => @ids |
103
|
|
|
|
|
|
|
); |
104
|
0
|
0
|
|
|
|
0
|
return $_[0] = Finance::Robinhood::Forex::Watchlist->new( _rh => $s->_rh, %{ $res->json } ) |
|
0
|
|
|
|
|
0
|
|
105
|
|
|
|
|
|
|
if $res->is_success; |
106
|
0
|
0
|
|
|
|
0
|
Finance::Robinhood::Error->new( |
107
|
|
|
|
|
|
|
$res->is_server_error ? ( details => $res->message ) : $res->json ); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub _test_pair_ids { |
111
|
1
|
|
50
|
1
|
|
1816
|
t::Utility::stash('WATCHLIST') // skip_all(); |
112
|
0
|
|
|
|
|
|
my @ids = t::Utility::stash('WATCHLIST')->pair_ids; |
113
|
0
|
|
|
|
|
|
ok( t::Utility::stash('WATCHLIST')->pair_ids( reverse @ids ) ); |
114
|
0
|
|
|
|
|
|
is( t::Utility::stash('WATCHLIST')->pair_ids(), reverse @ids ); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 LEGAL |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This is a simple wrapper around the API used in the official apps. The author |
120
|
|
|
|
|
|
|
provides no investment, legal, or tax advice and is not responsible for any |
121
|
|
|
|
|
|
|
damages incurred while using this software. This software is not affiliated |
122
|
|
|
|
|
|
|
with Robinhood Financial LLC in any way. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
For Robinhood's terms and disclosures, please see their website at |
125
|
|
|
|
|
|
|
https://robinhood.com/legal/ |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 LICENSE |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Copyright (C) Sanko Robinson. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
132
|
|
|
|
|
|
|
the terms found in the Artistic License 2. Other copyrights, terms, and |
133
|
|
|
|
|
|
|
conditions may apply to data transmitted through this module. Please refer to |
134
|
|
|
|
|
|
|
the L section. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 AUTHOR |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
1; |