File Coverage

lib/Finance/Robinhood/Equity/Split.pm
Criterion Covered Total %
statement 40 40 100.0
branch 1 4 25.0
condition 3 6 50.0
subroutine 12 12 100.0
pod 2 2 100.0
total 58 64 90.6


line stmt bran cond sub pod time code
1             package Finance::Robinhood::Equity::Split;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls
6              
7             =head1 NAME
8              
9             Finance::Robinhood::Equity::Split - Represents a Single Equity Instrument Split
10              
11             =head1 SYNOPSIS
12              
13             use Finance::Robinhood;
14             my $rh = Finance::Robinhood->new;
15             my $msft = $rh->equity_instrument_by_symbol('JNUG');
16              
17             # TODO
18              
19             =cut
20              
21             our $VERSION = '0.92_001';
22 1     1   8 use Mojo::Base-base, -signatures;
  1         2  
  1         10  
23 1     1   282 use Mojo::URL;
  1         1  
  1         7  
24 1     1   29 use Time::Moment;
  1         2  
  1         22  
25 1     1   6 use Finance::Robinhood::Equity::Market::Hours;
  1         1  
  1         9  
26              
27             sub _test__init {
28 1     1   12383 my $rh = t::Utility::rh_instance(0);
29 1         13 my $split = $rh->equity_instrument_by_symbol('JNUG')->splits->current;
30 1         83 isa_ok( $split, __PACKAGE__ );
31 1         740 t::Utility::stash( 'SPLIT', $split ); # Store it for later
32             }
33 1     1   151 use overload '""' => sub ( $s, @ ) { $s->{url} }, fallback => 1;
  1     4   2  
  1         11  
  4         6  
  4         30  
  4         364  
  4         8  
34              
35             sub _test_stringify {
36 1   50 1   2484 t::Utility::stash('SPLIT') // skip_all();
37 1         4 like(
38             +t::Utility::stash('SPLIT'),
39             qr'^https://api.robinhood.com/instruments/66ec1551-e033-4f9a-a46f-2b73aa529977/splits/.+/$'
40             );
41             }
42             #
43             has _rh => undef => weak => 1;
44              
45             =head1 METHODS
46              
47             =head2 C
48              
49              
50              
51             =head2 C
52              
53              
54             =cut
55              
56             has [ 'divisor', 'multiplier' ];
57              
58             =head2 C
59              
60             Returns a Time::Moment object.
61              
62             =cut
63              
64 1     1 1 10 sub execution_date ($s) {
  1         2  
  1         2  
65 1         16 Time::Moment->from_string( $s->{execution_date} . 'T00:00:00Z' );
66             }
67              
68             sub _test_website {
69 1   50 1   2137 t::Utility::stash('SPLIT') // skip_all();
70 1         4 isa_ok( t::Utility::stash('SPLIT')->execution_date, 'Time::Moment' );
71             }
72              
73             =head2 C
74              
75             my $jnug = $split->instrument( );
76              
77             Returns the related Finance::Robinhood::Equity::Instrument object.
78              
79             =cut
80              
81 1     1 1 11 sub instrument ( $s ) {
  1         1  
  1         2  
82 1         5 my $res = $s->_rh->_get( $s->{instrument} );
83             $res->is_success
84 1 0       30 ? Finance::Robinhood::Equity::Instrument->new( _rh => $s->_rh, %{ $res->json } )
  1 50       30  
85             : Finance::Robinhood::Error->new(
86             $res->is_server_error ? ( details => $res->message ) : $res->json );
87             }
88              
89             sub _test_instrument {
90 1   50 1   2096 t::Utility::stash('SPLIT') // skip_all();
91 1         4 my $inst = t::Utility::stash('SPLIT')->instrument();
92 1         1140 isa_ok( $inst, 'Finance::Robinhood::Equity::Instrument' );
93             }
94              
95             =head1 LEGAL
96              
97             This is a simple wrapper around the API used in the official apps. The author
98             provides no investment, legal, or tax advice and is not responsible for any
99             damages incurred while using this software. This software is not affiliated
100             with Robinhood Financial LLC in any way.
101              
102             For Robinhood's terms and disclosures, please see their website at
103             https://robinhood.com/legal/
104              
105             =head1 LICENSE
106              
107             Copyright (C) Sanko Robinson.
108              
109             This library is free software; you can redistribute it and/or modify it under
110             the terms found in the Artistic License 2. Other copyrights, terms, and
111             conditions may apply to data transmitted through this module. Please refer to
112             the L section.
113              
114             =head1 AUTHOR
115              
116             Sanko Robinson Esanko@cpan.orgE
117              
118             =cut
119              
120             1;