lib/Finance/Robinhood/User/Profile.pm

filter: Statementstmt 57.1% 16 / 28 Branchbran 0.0% 0 / 4 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 75.0% 6 / 8 Podpod 100% 2 / 2 totaltotal 52.0% 26 / 50 CC 5 SCAR 14.8
CC
5
Cov
50%
user
12.0
_test_updated_at
2.5
_test_user
2.5
CRAP 4.4
« lib/Finance/Robinhood/User/Employment.pm ↑ Summary lib/Finance/Robinhood/Equity/Earnings/Call.pm »
1 package Finance::Robinhood::User::Profile;
2  
3 =encoding utf-8
4  
5 =for stopwords watchlist watchlists untradable urls
6  
7 =head1 NAME
8  
9 Finance::Robinhood::User::Profile - Represents the User's Investment Profile
10 User
11  
12 =head1 SYNOPSIS
13  
14 use Finance::Robinhood;
15 my $rh = Finance::Robinhood->new;
16
17 my $user = $rh->user;
18 my $info = $user->profile;
19  
20 CORE::say 'User is' . ($info->interested_in_options?'':' not') . ' interested in options';
21  
22 =cut
23  
24 1 our $VERSION = '0.92_003';
25  
26 1 ▶sub _test__init {
Subroutine _test__init: called CC=1 SCAR=4.9
27 1 my $rh = t::Utility::rh_instance(1);
28 0 my $user = $rh->user;
29 0 isa_ok($user, 'Finance::Robinhood::User');
30 0 t::Utility::stash('USER', $user); # Store it for later
31 0 my $profile = $user->profile();
32 0 isa_ok($profile, __PACKAGE__);
33 0 t::Utility::stash('USER_INV_INFO', $profile);
34 }
35 1 ▶use Mojo::Base-base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 1 ▶use Mojo::URL;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 #
38 1 ▶use Time::Moment;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 #
40 1 has _rh => undef => weak => 1;
41  
42 =head1 METHODS
43  
44 =head2 C<annual_income( )>
45  
46 One of the following categories:
47  
48 =over
49  
50 =item C<0_24999>
51  
52 =item C<25000_39999>
53  
54 =item C<40000_49999>
55  
56 =item C<50000_74999>
57  
58 =item C<75000_99999>
59  
60 =item C<100000_199999>
61  
62 =item C<200000_299999>
63  
64 =item C<300000_499999>
65  
66 =item C<500000_1199999>
67  
68 =item C<1200000_inf>
69  
70 =back
71  
72 =head2 C<interested_in_options( )>
73  
74 Returns a boolean value.
75  
76 =head2 C<investment_experience( )>
77  
78 One of the following options:
79  
80 =over
81  
82 =item C<good_investment_exp>
83  
84 =item C<extensive_investment_exp>
85  
86 =item C<limited_investment_exp>
87  
88 =back
89  
90 =head2 C<investment_experience_collected( )>
91  
92 Returns a boolean value.
93  
94 =head2 C<investment_objective( )>
95  
96 One of the following:
97  
98 =over
99  
100 =item C<growth_invest_obj>
101
102 =item C<income_invest_obj>
103
104 =item C<other_invest_obj>
105
106 =item C<cap_preserve_invest_obj>
107  
108 =item C<speculation_invest_obj>
109  
110 =back
111  
112 =head2 C<liquid_net_worth( )>
113  
114 One of the following:
115  
116 =over
117  
118 =item C<0_24999>
119  
120 =item C<25000_39999>
121  
122 =item C<40000_49999>
123  
124 =item C<50000_99999>
125  
126 =item C<100000_199999>
127  
128 =item C<200000_249999>
129  
130 =item C<250000_499999>
131  
132 =item C<500000_999999>
133  
134 =item C<1000000_4999999>
135  
136 =item C<5000000_inf>
137  
138 =item C<1000000_inf>
139  
140 =back
141  
142 =head2 C<liquidity_needs( )>
143  
144 One of the following:
145  
146 =over
147  
148 =item C<not_important_liq_need>
149  
150 =item C<somewhat_important_liq_need>
151  
152 =item C<very_important_liq_need>
153  
154 =back
155  
156 =head2 C<option_trading_experience( )>
157  
158 One of the following:
159  
160 =over
161  
162 =item C<no_option_exp>
163  
164 =item C<one_to_two_years_option_exp>
165  
166 =item C<three_years_plus_option_exp>
167  
168 =back
169  
170 =head2 C<professional_trader( )>
171  
172 Returns a boolean value. True if the user is a paid professional.
173  
174 =head2 C<risk_tolerance( )>
175  
176 One of the following:
177  
178 =over
179  
180 =item C<high_risk_toleranceL>
181  
182 =item C<med_risk_tolerance>
183  
184 =item C<low_risk_tolerance>
185  
186 =back
187  
188 =head2 C<source_of_funds( )>
189  
190 One of the following:
191  
192 =over
193  
194 =item C<gift>
195  
196 =item C<inheritance>
197  
198 =item C<insurance_payout>
199  
200 =item C<savings_personal_income>
201  
202 =item C<sale_business_or_property>
203  
204 =item C<pension_retirement>
205  
206 =item C<other>
207  
208 =back
209  
210 =head2 C<suitability_verified( )>
211  
212 Returns a boolean value.
213  
214 =head2 C<tax_bracket( )>
215  
216 One of the following:
217  
218 =over
219  
220 =item C<10_pct>
221  
222 =item C<20_pct>
223  
224 =item C<25_pct>
225  
226 =item C<28_pct>
227  
228 =item C<33_pct>
229
230 =item C<35_pct>
231
232 =item C<39_6_pct>
233  
234 =back
235  
236 =head2 C<time_horizon( )>
237  
238 One of the following:
239  
240 =over
241  
242 =item C<long_time_horizon>
243  
244 =item C<med_time_horizon>
245
246 =item C<short_time_horizon>
247  
248 =back
249  
250 =head2 C<total_net_worth( )>
251  
252 One of the following:
253  
254 =over
255  
256 =item C<0_24999>
257  
258 =item C<25000_49999>
259  
260 =item C<50000_64999>
261  
262 =item C<65000_99999>
263
264 =item C<1000000_4999999>
265
266 =item C<100000_149999>
267
268 =item C<150000_199999>
269
270 =item C<200000_249999>
271
272 =item C<250000_499999>
273
274 =item C<500000_999999>
275
276 =item C<1000000_inf>
277  
278 =item C<5000000_inf>
279  
280 =back
281  
282 =head2 C<understand_option_spreads( )>
283  
284 Returns a boolean value.
285  
286 =cut
287  
288 1 has ['annual_income', 'interested_in_options',
289 'investment_experience_collected', 'investment_experience_collected',
290 'investment_objective', 'liquid_net_worth',
291 'liquidity_needs', 'option_trading_experience',
292 'professional_trader', 'risk_tolerance',
293 'source_of_funds', 'suitability_verified',
294 'tax_bracket', 'time_horizon',
295 'total_net_worth', 'understand_option_spreads'
296 ];
297  
298 =head2 C<updated_at( )>
299  
300 $user->updated_at();
301  
302 Returns a Time::Moment object.
303  
304 =cut
305  
306 0 ▶sub updated_at ($s) {
Subroutine updated_at: not called CC=1 SCAR=6.9
Pod documented
307 0 Time::Moment->from_string($s->{updated_at});
308 }
309  
310 1 ▶sub _test_updated_at {
Subroutine _test_updated_at: called CC=2 SCAR=9.2
311 1 ▶ t::Utility::stash('USER_INV_INFO') // skip_all();
Condition50%1/2
t::Utility::stash("USER_INV_INFO") // skip_all()
l!l
01
MC/DC0%0/2
t::Utility::stash("USER_INV_INFO") // skip_all()
t::Utility::stash("USER_INV_INFO") skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("USER_INV_INFO")B= skip_all()
ABresult
1X1
011
000
312 0 isa_ok(t::Utility::stash('USER_INV_INFO')->updated_at(), 'Time::Moment');
313 }
314  
315 =head2 C<user( )>
316  
317 $order->user();
318  
319 Reloads the data for this order from the API server.
320  
321 Use this if you think the status or some other info might have changed.
322  
323 =cut
324  
325 0 ▶sub user($s) {
Subroutine user: not called CC=3 SCAR=24.8
Pod documented
326 0 my $res = $s->_rh->_get($s->{user});
327 $_[0]
328 = $res->is_success
329 0 ▶ ? Finance::Robinhood::User->new(_rh => $s->_rh, %{$res->json})
Branch: 2 branches
BranchTrueFalseTotal
$res->is_success ? : 0 0 0
$res->is_server_error ? : 0 0 0
330 : Finance::Robinhood::Error->new(
331 $res->is_server_error ? (details => $res->message) : $res->json);
332 }
333  
334 1 ▶sub _test_user {
Subroutine _test_user: called CC=2 SCAR=9.2
335 1 ▶ t::Utility::stash('USER_INV_INFO')
Condition50%1/2
t::Utility::stash("USER_INV_INFO") // skip_all("No user id data object in stash")
l!l
01
MC/DC0%0/2
t::Utility::stash("USER_INV_INFO") // skip_all("No user id data object in stash")
t::Utility::stash("USER_INV_INFO") skip_all("No user id data object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("USER_INV_INFO")B= skip_all("No user id data object in stash")
ABresult
1X1
011
000
336 // skip_all('No user id data object in stash');
337 0 isa_ok(t::Utility::stash('USER_INV_INFO')->user(),
338 'Finance::Robinhood::User');
339 }
340  
341 =head1 LEGAL
342  
343 This is a simple wrapper around the API used in the official apps. The author
344 provides no investment, legal, or tax advice and is not responsible for any
345 damages incurred while using this software. This software is not affiliated
346 with Robinhood Financial LLC in any way.
347  
348 For Robinhood's terms and disclosures, please see their website at
349 https://robinhood.com/legal/
350  
351 =head1 LICENSE
352  
353 Copyright (C) Sanko Robinson.
354  
355 This library is free software; you can redistribute it and/or modify it under
356 the terms found in the Artistic License 2. Other copyrights, terms, and
357 conditions may apply to data transmitted through this module. Please refer to
358 the L<LEGAL> section.
359  
360 =head1 AUTHOR
361  
362 Sanko Robinson E<lt>sanko@cpan.orgE<gt>
363  
364 =cut
365  
366 1 1;
« lib/Finance/Robinhood/User/Employment.pm ↑ Summary lib/Finance/Robinhood/Equity/Earnings/Call.pm »