| 1 | package Finance::Robinhood::ACATS::Transfer::Position; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | =encoding utf-8 | ||||||||||||||||||
| 4 | |||||||||||||||||||
| 5 | =for stopwords watchlist watchlists untradable urls | ||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | Finance::Robinhood::ACATS::Transfer::Position - Represents a Single Position in | ||||||||||||||||||
| 10 | an ACATS Transfer | ||||||||||||||||||
| 11 | |||||||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | use Finance::Robinhood; | ||||||||||||||||||
| 15 | my $rh = Finance::Robinhood->new; | ||||||||||||||||||
| 16 | |||||||||||||||||||
| 17 | ... | ||||||||||||||||||
| 18 | CORE::say $_->instrument->symbol for @{$transfer->equity_positions}; | ||||||||||||||||||
| 19 | |||||||||||||||||||
| 20 | =cut | ||||||||||||||||||
| 21 | |||||||||||||||||||
| 22 | 1 | our $VERSION = '0.92_003'; | |||||||||||||||||
| 23 | 1 | ▶ | use Mojo::Base-base, -signatures; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 24 | 1 | ▶ | use Mojo::URL; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 25 | 1 | ▶ | use Time::Moment; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 26 | |||||||||||||||||||
| 27 | 1 | ▶ | sub _test__init { | ||||||||||||||||
|
Subroutine
_test__init: called CC=2 SCAR=15.1
| |||||||||||||||||||
| 28 | 1 | my $rh = t::Utility::rh_instance(1); | |||||||||||||||||
| 29 | 0 | my $transfer = $rh->acats_transfers->current; | |||||||||||||||||
| 30 | 0 | ▶ | skip_all('No ACATS transfers found') if !defined $transfer; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 31 | 0 | isa_ok($transfer->equity_positions->[0], __PACKAGE__); | |||||||||||||||||
| 32 | 0 | t::Utility::stash('POSITION', $transfer->equity_positions->[0]) | |||||||||||||||||
| 33 | ; # Store it for later | ||||||||||||||||||
| 34 | } | ||||||||||||||||||
| 35 | # | ||||||||||||||||||
| 36 | 1 | has _rh => undef => weak => 1; | |||||||||||||||||
| 37 | |||||||||||||||||||
| 38 | =head1 METHODS | ||||||||||||||||||
| 39 | |||||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | =head2 C<price( )> | ||||||||||||||||||
| 42 | |||||||||||||||||||
| 43 | Average price for this position. | ||||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | =head2 C<quantity( )> | ||||||||||||||||||
| 46 | |||||||||||||||||||
| 47 | Number of shares in this position | ||||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | =cut | ||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | 1 | has ['price', 'quantity']; | |||||||||||||||||
| 52 | |||||||||||||||||||
| 53 | =head2 C<instrument( )> | ||||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | my $instrument = $position->instrument(); | ||||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | Loops back to a Finance::Robinhood::Equity::Instrument object. | ||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | =cut | ||||||||||||||||||
| 60 | |||||||||||||||||||
| 61 | 0 | ▶ | sub instrument ($s) { | ||||||||||||||||
|
Subroutine
instrument: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||
| 62 | 0 | my $res = $s->_rh->_get($s->{instrument}); | |||||||||||||||||
| 63 | $res->is_success | ||||||||||||||||||
| 64 | ? Finance::Robinhood::Equity::Instrument->new(_rh => $s->_rh, | ||||||||||||||||||
| 65 | 0 | ▶ | %{$res->json}) | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 66 | : Finance::Robinhood::Error->new( | ||||||||||||||||||
| 67 | $res->is_server_error ? (details => $res->message) : $res->json); | ||||||||||||||||||
| 68 | } | ||||||||||||||||||
| 69 | |||||||||||||||||||
| 70 | 1 | ▶ | sub _test_instrument { | ||||||||||||||||
|
Subroutine
_test_instrument: called CC=2 SCAR=9.2
| |||||||||||||||||||
| 71 | 1 | ▶ | t::Utility::stash('POSITION') // skip_all(); | ||||||||||||||||
|
Condition50%1/2
t::Utility::stash("POSITION") // skip_all()
MC/DC0%0/2
t::Utility::stash("POSITION") // skip_all()
t::Utility::stash("POSITION")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("POSITION")B= skip_all()
| |||||||||||||||||||
| 72 | 0 | isa_ok(t::Utility::stash('POSITION')->instrument, | |||||||||||||||||
| 73 | 'Finance::Robinhood::Equity::Instrument'); | ||||||||||||||||||
| 74 | } | ||||||||||||||||||
| 75 | |||||||||||||||||||
| 76 | =head1 LEGAL | ||||||||||||||||||
| 77 | |||||||||||||||||||
| 78 | This is a simple wrapper around the API used in the official apps. The author | ||||||||||||||||||
| 79 | provides no investment, legal, or tax advice and is not responsible for any | ||||||||||||||||||
| 80 | damages incurred while using this software. This software is not affiliated | ||||||||||||||||||
| 81 | with Robinhood Financial LLC in any way. | ||||||||||||||||||
| 82 | |||||||||||||||||||
| 83 | For Robinhood's terms and disclosures, please see their website at | ||||||||||||||||||
| 84 | https://robinhood.com/legal/ | ||||||||||||||||||
| 85 | |||||||||||||||||||
| 86 | =head1 LICENSE | ||||||||||||||||||
| 87 | |||||||||||||||||||
| 88 | Copyright (C) Sanko Robinson. | ||||||||||||||||||
| 89 | |||||||||||||||||||
| 90 | This library is free software; you can redistribute it and/or modify it under | ||||||||||||||||||
| 91 | the terms found in the Artistic License 2. Other copyrights, terms, and | ||||||||||||||||||
| 92 | conditions may apply to data transmitted through this module. Please refer to | ||||||||||||||||||
| 93 | the L<LEGAL> section. | ||||||||||||||||||
| 94 | |||||||||||||||||||
| 95 | =head1 AUTHOR | ||||||||||||||||||
| 96 | |||||||||||||||||||
| 97 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||||||||||||||||||
| 98 | |||||||||||||||||||
| 99 | =cut | ||||||||||||||||||
| 100 | |||||||||||||||||||
| 101 | 1 | 1; | |||||||||||||||||