File Coverage

lib/Finance/Robinhood/Forex/Historicals.pm
Criterion Covered Total %
statement 11 39 28.2
branch n/a
condition 4 8 50.0
subroutine 7 11 63.6
pod 4 4 100.0
total 26 62 41.9


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