| 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 | 1 | our $VERSION = '0.92_003'; | |||||||||||||||||
| 22 | 1 | ▶ | use Mojo::Base-base, -signatures; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 23 | 1 | ▶ | use Mojo::URL; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | 1 | ▶ | sub _test__init { | ||||||||||||||||
|
Subroutine
_test__init: called CC=1 SCAR=3.5
| |||||||||||||||||||
| 26 | 1 | my $rh = t::Utility::rh_instance(1); | |||||||||||||||||
| 27 | 0 | my $historicals = $rh->forex_pair_by_id( | |||||||||||||||||
| 28 | '3d961844-d360-45fc-989b-f6fca761d511') # BTC-USD | ||||||||||||||||||
| 29 | ->historicals(interval => '5minute'); | ||||||||||||||||||
| 30 | 0 | isa_ok($historicals, __PACKAGE__); | |||||||||||||||||
| 31 | 0 | t::Utility::stash('HISTORICALS', $historicals); # Store it for later | |||||||||||||||||
| 32 | } | ||||||||||||||||||
| 33 | ## | ||||||||||||||||||
| 34 | |||||||||||||||||||
| 35 | =head1 METHODS | ||||||||||||||||||
| 36 | |||||||||||||||||||
| 37 | =cut | ||||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | 1 | has _rh => undef => weak => 1; | |||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | =head2 C<bounds( )> | ||||||||||||||||||
| 42 | |||||||||||||||||||
| 43 | |||||||||||||||||||
| 44 | =head2 C<data_points( )> | ||||||||||||||||||
| 45 | |||||||||||||||||||
| 46 | Returns a list of Finance::Robinhood::Forex::Historicals::DataPoint object. | ||||||||||||||||||
| 47 | |||||||||||||||||||
| 48 | =head2 C<interval( )> | ||||||||||||||||||
| 49 | |||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | |||||||||||||||||||
| 52 | =head2 C<open_price( )> | ||||||||||||||||||
| 53 | |||||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | =head2 C<open_time( )> | ||||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | Returns a Time::Moment object. | ||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | =head2 C<previous_close_price( )> | ||||||||||||||||||
| 60 | |||||||||||||||||||
| 61 | |||||||||||||||||||
| 62 | =head2 C<previous_close_time( )> | ||||||||||||||||||
| 63 | |||||||||||||||||||
| 64 | Returns a Time::Moment object. | ||||||||||||||||||
| 65 | |||||||||||||||||||
| 66 | =head2 C<span( )> | ||||||||||||||||||
| 67 | |||||||||||||||||||
| 68 | |||||||||||||||||||
| 69 | =head2 C<symbol( )> | ||||||||||||||||||
| 70 | |||||||||||||||||||
| 71 | =cut | ||||||||||||||||||
| 72 | |||||||||||||||||||
| 73 | 1 | has ['bounds', 'interval', | |||||||||||||||||
| 74 | 'open_price', 'previous_close_price', | ||||||||||||||||||
| 75 | 'span', 'symbol' | ||||||||||||||||||
| 76 | ]; | ||||||||||||||||||
| 77 | |||||||||||||||||||
| 78 | 0 | ▶ | sub data_points ($s) { | ||||||||||||||||
|
Subroutine
data_points: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 79 | 0 | require Finance::Robinhood::Forex::Historicals::Datapoint; | |||||||||||||||||
| 80 | map { | ||||||||||||||||||
| 81 | Finance::Robinhood::Forex::Historicals::Datapoint->new(_rh => $s->_rh, | ||||||||||||||||||
| 82 | 0 | %{$_}) | |||||||||||||||||
| 83 | 0 | } @{$s->{data_points}}; | |||||||||||||||||
| 84 | } | ||||||||||||||||||
| 85 | |||||||||||||||||||
| 86 | 1 | ▶ | sub _test_data_points { | ||||||||||||||||
|
Subroutine
_test_data_points: called CC=2 SCAR=10.5
| |||||||||||||||||||
| 87 | 1 | ▶ | t::Utility::stash('HISTORICALS') | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("HISTORICALS") // skip_all("No historicals object in stash")
MC/DC0%0/2
t::Utility::stash("HISTORICALS") // skip_all("No historicals object in stash")
t::Utility::stash("HISTORICALS")
skip_all("No historicals object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("HISTORICALS")B= skip_all("No historicals object in stash")
| |||||||||||||||||||
| 88 | // skip_all('No historicals object in stash'); | ||||||||||||||||||
| 89 | 0 | my ($datapoint) = t::Utility::stash('HISTORICALS')->data_points; | |||||||||||||||||
| 90 | 0 | isa_ok($datapoint, 'Finance::Robinhood::Forex::Historicals::Datapoint'); | |||||||||||||||||
| 91 | } | ||||||||||||||||||
| 92 | |||||||||||||||||||
| 93 | 0 | ▶ | sub open_time ($s) { | ||||||||||||||||
|
Subroutine
open_time: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 94 | 0 | Time::Moment->from_string($s->{open_time}); | |||||||||||||||||
| 95 | } | ||||||||||||||||||
| 96 | |||||||||||||||||||
| 97 | 1 | ▶ | sub _test_open_time { | ||||||||||||||||
|
Subroutine
_test_open_time: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 98 | 1 | ▶ | t::Utility::stash('HISTORICALS') | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("HISTORICALS") // skip_all("No historicals object in stash")
MC/DC0%0/2
t::Utility::stash("HISTORICALS") // skip_all("No historicals object in stash")
t::Utility::stash("HISTORICALS")
skip_all("No historicals object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("HISTORICALS")B= skip_all("No historicals object in stash")
| |||||||||||||||||||
| 99 | // skip_all('No historicals object in stash'); | ||||||||||||||||||
| 100 | 0 | isa_ok(t::Utility::stash('HISTORICALS')->open_time, 'Time::Moment'); | |||||||||||||||||
| 101 | } | ||||||||||||||||||
| 102 | |||||||||||||||||||
| 103 | =head2 C<previous_close_time( )> | ||||||||||||||||||
| 104 | |||||||||||||||||||
| 105 | Returns a Time::Moment object. | ||||||||||||||||||
| 106 | |||||||||||||||||||
| 107 | =cut | ||||||||||||||||||
| 108 | |||||||||||||||||||
| 109 | 0 | ▶ | sub previous_close_time ($s) { | ||||||||||||||||
|
Subroutine
previous_close_time: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 110 | 0 | Time::Moment->from_string($s->{previous_close_time}); | |||||||||||||||||
| 111 | } | ||||||||||||||||||
| 112 | |||||||||||||||||||
| 113 | 1 | ▶ | sub _test_previous_close_time { | ||||||||||||||||
|
Subroutine
_test_previous_close_time: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 114 | 1 | ▶ | t::Utility::stash('HISTORICALS') | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("HISTORICALS") // skip_all("No historicals object in stash")
MC/DC0%0/2
t::Utility::stash("HISTORICALS") // skip_all("No historicals object in stash")
t::Utility::stash("HISTORICALS")
skip_all("No historicals object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("HISTORICALS")B= skip_all("No historicals object in stash")
| |||||||||||||||||||
| 115 | // skip_all('No historicals object in stash'); | ||||||||||||||||||
| 116 | 0 | isa_ok(t::Utility::stash('HISTORICALS')->previous_close_time, | |||||||||||||||||
| 117 | 'Time::Moment'); | ||||||||||||||||||
| 118 | } | ||||||||||||||||||
| 119 | |||||||||||||||||||
| 120 | =head2 C<pair( )> | ||||||||||||||||||
| 121 | |||||||||||||||||||
| 122 | Returns the related Finance::Robinhood::Forex::Pair object. | ||||||||||||||||||
| 123 | |||||||||||||||||||
| 124 | =cut | ||||||||||||||||||
| 125 | |||||||||||||||||||
| 126 | 0 | ▶ | sub pair ($s) { | ||||||||||||||||
|
Subroutine
pair: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 127 | 0 | $s->_rh->forex_pair_by_id($s->{id}); | |||||||||||||||||
| 128 | } | ||||||||||||||||||
| 129 | |||||||||||||||||||
| 130 | 1 | ▶ | sub _test_instrument { | ||||||||||||||||
|
Subroutine
_test_instrument: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 131 | 1 | ▶ | t::Utility::stash('HISTORICALS') | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("HISTORICALS") // skip_all("No historicals object in stash")
MC/DC0%0/2
t::Utility::stash("HISTORICALS") // skip_all("No historicals object in stash")
t::Utility::stash("HISTORICALS")
skip_all("No historicals object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("HISTORICALS")B= skip_all("No historicals object in stash")
| |||||||||||||||||||
| 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<LEGAL> section. | ||||||||||||||||||
| 155 | |||||||||||||||||||
| 156 | =head1 AUTHOR | ||||||||||||||||||
| 157 | |||||||||||||||||||
| 158 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||||||||||||||||||
| 159 | |||||||||||||||||||
| 160 | =cut | ||||||||||||||||||
| 161 | |||||||||||||||||||
| 162 | 1 | 1; | |||||||||||||||||