| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Finance::Robinhood::Equity::Watchlist::Element; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=for stopwords watchlist watchlists untradable urls |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Finance::Robinhood::Equity::Watchlist - Represents a Single Robinhood Watchlist |
|
10
|
|
|
|
|
|
|
Element |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Finance::Robinhood; |
|
15
|
|
|
|
|
|
|
my $rh = Finance::Robinhood->new->login('user', 'pass'); |
|
16
|
|
|
|
|
|
|
my $watchlist = $rh->watchlists->current(); |
|
17
|
|
|
|
|
|
|
warn $watchlist->current->instrument->symbol; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# TODO |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.92_002'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _test__init { |
|
26
|
1
|
|
|
1
|
|
13186
|
my $rh = t::Utility::rh_instance(1); |
|
27
|
0
|
|
|
|
|
0
|
my $element = $rh->equity_watchlist_by_name('Default')->current; |
|
28
|
0
|
|
|
|
|
0
|
isa_ok( $element, __PACKAGE__ ); |
|
29
|
0
|
|
|
|
|
0
|
t::Utility::stash( 'ELEMENT', $element ); # Store it for later |
|
30
|
|
|
|
|
|
|
} |
|
31
|
1
|
|
|
1
|
|
7
|
use Mojo::Base-base, -signatures; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
9
|
|
|
32
|
1
|
|
|
1
|
|
201
|
use Mojo::URL; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
33
|
1
|
|
|
1
|
|
31
|
use Time::Moment; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
70
|
|
|
34
|
1
|
|
|
1
|
|
6
|
use overload '""' => sub ( $s, @ ) { $s->{url} }, fallback => 1; |
|
|
1
|
|
|
0
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
35
|
1
|
|
|
1
|
|
79
|
use Finance::Robinhood::Equity::Instrument; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
9
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _test_stringify { |
|
38
|
1
|
|
50
|
1
|
|
2233
|
t::Utility::stash('ELEMENT') // skip_all(); |
|
39
|
0
|
|
|
|
|
0
|
like( +t::Utility::stash('ELEMENT'), qr'^https://api.robinhood.com/watchlists/Default/.+$' ); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
# |
|
42
|
|
|
|
|
|
|
has _rh => undef => weak => 1; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 METHODS |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 C |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$element->created_at(); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Returns a Time::Moment object representing the time this element was added to |
|
51
|
|
|
|
|
|
|
the watchlist. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
1
|
0
|
sub created_at ($s) { |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
56
|
0
|
|
|
|
|
0
|
Time::Moment->from_string( $s->{created_at} ); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _test_created_at { |
|
60
|
1
|
|
50
|
1
|
|
2010
|
t::Utility::stash('ELEMENT') // skip_all(); |
|
61
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('ELEMENT')->created_at(), 'Time::Moment' ); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 C |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$element->delete(); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Removes a instrument from the parent watchlist. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
0
|
1
|
0
|
sub delete ($s) { |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
73
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_delete( $s->{url} ); |
|
74
|
0
|
|
0
|
|
|
0
|
return $res->is_success || Finance::Robinhood::Error->new( %{ $res->json } ); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _test_delete { |
|
78
|
1
|
|
50
|
1
|
|
1938
|
t::Utility::stash('ELEMENT') // skip_all(); |
|
79
|
0
|
|
|
0
|
|
0
|
todo( "Add something and remove it and check watchlist" => sub { pass('ugh') } ); |
|
|
0
|
|
|
|
|
0
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# isa_ok( t::Utility::stash('ELEMENT')->instrument, 'Finance::Robinhood::Equity::Instrument' ); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 C |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
$element->instrument(); |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns a Finance::Robinhood::Equity::Instrument object. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
0
|
1
|
0
|
sub instrument ($s) { |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
93
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get( $s->{instrument} ); |
|
94
|
|
|
|
|
|
|
return $res->is_success |
|
95
|
0
|
|
|
|
|
0
|
? Finance::Robinhood::Equity::Instrument->new( _rh => $s->_rh, %{ $res->json } ) |
|
96
|
0
|
0
|
|
|
|
0
|
: Finance::Robinhood::Error->new( %{ $res->json } ); |
|
|
0
|
|
|
|
|
0
|
|
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub _test_instrument { |
|
100
|
1
|
|
50
|
1
|
|
1863
|
t::Utility::stash('ELEMENT') // skip_all(); |
|
101
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('ELEMENT')->instrument, 'Finance::Robinhood::Equity::Instrument' ); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 C |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
$element->id(); |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Returns the UUID of the equity instrument. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
|
|
112
|
0
|
|
|
0
|
1
|
0
|
sub id ($s) { |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
113
|
0
|
|
|
|
|
0
|
$s->{instrument} =~ qr[/([0-9a-f]{8}(?:\-[0-9a-f]{4}){3}\-[0-9a-f]{12})/$]i; |
|
114
|
0
|
|
|
|
|
0
|
$1; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub _test_id { |
|
118
|
1
|
|
50
|
1
|
|
1872
|
t::Utility::stash('ELEMENT') // skip_all(); |
|
119
|
0
|
|
|
|
|
0
|
like( t::Utility::stash('ELEMENT')->id, qr[^[0-9a-f]{8}(?:\-[0-9a-f]{4}){3}\-[0-9a-f]{12}$]i ); |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 C |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$element->watchlist(); |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Returns a Finance::Robinhood::Equity::Instrument object. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
|
129
|
|
|
|
|
|
|
|
|
130
|
0
|
|
|
0
|
1
|
0
|
sub watchlist ($s) { |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
131
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get( $s->{watchlist} ); |
|
132
|
|
|
|
|
|
|
return $res->is_success |
|
133
|
0
|
0
|
|
|
|
0
|
? Finance::Robinhood::Equity::Watchlist->new( _rh => $s->_rh, %{ $res->json } ) |
|
|
0
|
0
|
|
|
|
0
|
|
|
134
|
|
|
|
|
|
|
: Finance::Robinhood::Error->new( |
|
135
|
|
|
|
|
|
|
$res->is_server_error ? ( details => $res->message ) : $res->json ); |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub _test_watchlist { |
|
139
|
1
|
|
50
|
1
|
|
1867
|
t::Utility::stash('ELEMENT') // skip_all(); |
|
140
|
0
|
|
|
|
|
|
my $watchlist = t::Utility::stash('ELEMENT')->watchlist; |
|
141
|
0
|
|
|
|
|
|
isa_ok( $watchlist, 'Finance::Robinhood::Equity::Watchlist' ); |
|
142
|
0
|
|
|
|
|
|
is( $watchlist->name, 'Default' ); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 LEGAL |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This is a simple wrapper around the API used in the official apps. The author |
|
148
|
|
|
|
|
|
|
provides no investment, legal, or tax advice and is not responsible for any |
|
149
|
|
|
|
|
|
|
damages incurred while using this software. This software is not affiliated |
|
150
|
|
|
|
|
|
|
with Robinhood Financial LLC in any way. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
For Robinhood's terms and disclosures, please see their website at |
|
153
|
|
|
|
|
|
|
https://robinhood.com/legal/ |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 LICENSE |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Copyright (C) Sanko Robinson. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
|
160
|
|
|
|
|
|
|
the terms found in the Artistic License 2. Other copyrights, terms, and |
|
161
|
|
|
|
|
|
|
conditions may apply to data transmitted through this module. Please refer to |
|
162
|
|
|
|
|
|
|
the L section. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 AUTHOR |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
1; |