« lib/Finance/Robinhood/Equity/Watchlist/Element.pm
↑ Summary
lib/Finance/Robinhood/Equity/Account/InstantEligibility.pm »
| 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 | 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 | 1 | ▶ | use Time::Moment; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 25 | 1 | ▶ | use Finance::Robinhood::Equity::Market::Hours; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 26 | |||||||||||||||||||
| 27 | 1 | ▶ | sub _test__init { | ||||||||||||||||
|
Subroutine
_test__init: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 28 | 1 | my $rh = t::Utility::rh_instance(0); | |||||||||||||||||
| 29 | 1 | my $split = $rh->equity_instrument_by_symbol('JNUG')->splits->current; | |||||||||||||||||
| 30 | 1 | isa_ok($split, __PACKAGE__); | |||||||||||||||||
| 31 | 1 | t::Utility::stash('SPLIT', $split); # Store it for later | |||||||||||||||||
| 32 | } | ||||||||||||||||||
| 33 | 0 | ▶ | use overload '""' => sub ($s, @) { $s->{url} }, fallback => 1; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||
| 34 | |||||||||||||||||||
| 35 | 1 | ▶ | sub _test_stringify { | ||||||||||||||||
|
Subroutine
_test_stringify: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 36 | 1 | ▶ | t::Utility::stash('SPLIT') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("SPLIT") // skip_all()
MC/DC0%0/2
t::Utility::stash("SPLIT") // skip_all()
t::Utility::stash("SPLIT")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("SPLIT")B= skip_all()
| |||||||||||||||||||
| 37 | 0 | like(+t::Utility::stash('SPLIT'), | |||||||||||||||||
| 38 | qr'^https://api.robinhood.com/instruments/66ec1551-e033-4f9a-a46f-2b73aa529977/splits/.+/$' | ||||||||||||||||||
| 39 | ); | ||||||||||||||||||
| 40 | } | ||||||||||||||||||
| 41 | # | ||||||||||||||||||
| 42 | 1 | has _rh => undef => weak => 1; | |||||||||||||||||
| 43 | |||||||||||||||||||
| 44 | =head1 METHODS | ||||||||||||||||||
| 45 | |||||||||||||||||||
| 46 | =head2 C<divisor( )> | ||||||||||||||||||
| 47 | |||||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | |||||||||||||||||||
| 50 | =head2 C<multiplier( )> | ||||||||||||||||||
| 51 | |||||||||||||||||||
| 52 | |||||||||||||||||||
| 53 | =cut | ||||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | 1 | has ['divisor', 'multiplier']; | |||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | =head2 C<execution_date()> | ||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | Returns a Time::Moment object. | ||||||||||||||||||
| 60 | |||||||||||||||||||
| 61 | =cut | ||||||||||||||||||
| 62 | |||||||||||||||||||
| 63 | 0 | ▶ | sub execution_date ($s) { | ||||||||||||||||
|
Subroutine
execution_date: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 64 | 0 | Time::Moment->from_string($s->{execution_date} . 'T00:00:00Z'); | |||||||||||||||||
| 65 | } | ||||||||||||||||||
| 66 | |||||||||||||||||||
| 67 | 1 | ▶ | sub _test_website { | ||||||||||||||||
|
Subroutine
_test_website: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 68 | 1 | ▶ | t::Utility::stash('SPLIT') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("SPLIT") // skip_all()
MC/DC0%0/2
t::Utility::stash("SPLIT") // skip_all()
t::Utility::stash("SPLIT")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("SPLIT")B= skip_all()
| |||||||||||||||||||
| 69 | 0 | isa_ok(t::Utility::stash('SPLIT')->execution_date, 'Time::Moment'); | |||||||||||||||||
| 70 | } | ||||||||||||||||||
| 71 | |||||||||||||||||||
| 72 | =head2 C<instrument( )> | ||||||||||||||||||
| 73 | |||||||||||||||||||
| 74 | my $jnug = $split->instrument( ); | ||||||||||||||||||
| 75 | |||||||||||||||||||
| 76 | Returns the related Finance::Robinhood::Equity::Instrument object. | ||||||||||||||||||
| 77 | |||||||||||||||||||
| 78 | =cut | ||||||||||||||||||
| 79 | |||||||||||||||||||
| 80 | 0 | ▶ | sub instrument ( $s ) { | ||||||||||||||||
|
Subroutine
instrument: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||
| 81 | 0 | my $res = $s->_rh->_get($s->{instrument}); | |||||||||||||||||
| 82 | $res->is_success | ||||||||||||||||||
| 83 | ? Finance::Robinhood::Equity::Instrument->new(_rh => $s->_rh, | ||||||||||||||||||
| 84 | 0 | ▶ | %{$res->json}) | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 85 | : Finance::Robinhood::Error->new( | ||||||||||||||||||
| 86 | $res->is_server_error ? (details => $res->message) : $res->json); | ||||||||||||||||||
| 87 | } | ||||||||||||||||||
| 88 | |||||||||||||||||||
| 89 | 1 | ▶ | sub _test_instrument { | ||||||||||||||||
|
Subroutine
_test_instrument: called CC=2 SCAR=10.5
| |||||||||||||||||||
| 90 | 1 | ▶ | t::Utility::stash('SPLIT') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("SPLIT") // skip_all()
MC/DC0%0/2
t::Utility::stash("SPLIT") // skip_all()
t::Utility::stash("SPLIT")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("SPLIT")B= skip_all()
| |||||||||||||||||||
| 91 | 0 | my $inst = t::Utility::stash('SPLIT')->instrument(); | |||||||||||||||||
| 92 | 0 | 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<LEGAL> section. | ||||||||||||||||||
| 113 | |||||||||||||||||||
| 114 | =head1 AUTHOR | ||||||||||||||||||
| 115 | |||||||||||||||||||
| 116 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||||||||||||||||||
| 117 | |||||||||||||||||||
| 118 | =cut | ||||||||||||||||||
| 119 | |||||||||||||||||||
| 120 | 1 | 1; | |||||||||||||||||