« lib/Finance/Robinhood/Equity/Mover.pm
↑ Summary
lib/Finance/Robinhood/Equity/Account/MarginBalances.pm »
| 1 | package Finance::Robinhood::Equity::Order::Execution; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | =encoding utf-8 | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | =for stopwords watchlist watchlists untradable urls | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | Finance::Robinhood::Equity::Order::Execution - Represents a Single Execution of | ||||||||||||||||||||
| 10 | an Equity Order | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | use Finance::Robinhood; | ||||||||||||||||||||
| 15 | my $rh = Finance::Robinhood->new->login('user', 'pass'); | ||||||||||||||||||||
| 16 | my $orders = $rh->equity_orders(); | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | for my $order ($orders->all) { | ||||||||||||||||||||
| 19 | grep{ CORE::say( $_->settlement_date) } @{$order->executions} and if $order->state eq 'filled'; | ||||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | =head1 METHOD | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | =cut | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 1 | our $VERSION = '0.92_003'; | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 1 | ▶ | sub _test__init { | ||||||||||||||||||
|
Subroutine
_test__init: called CC=3 SCAR=23.3
| |||||||||||||||||||||
| 29 | 1 | my $rh = t::Utility::rh_instance(1); | |||||||||||||||||||
| 30 | 0 | my $orders = $rh->equity_orders; | |||||||||||||||||||
| 31 | 0 | my $order; | |||||||||||||||||||
| 32 | 0 | ▶ | do { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | 0 | $order = $orders->next; | |||||||||||||||||||
| 34 | } while $order->state ne 'filled'; | ||||||||||||||||||||
| 35 | 0 | ▶ | $order // skip_all('Failed to fine executied equity order'); | ||||||||||||||||||
|
Condition0%0/3
$order // skip_all("Failed to fine executied equity order")
MC/DC0%0/2
$order // skip_all("Failed to fine executied equity order")
$order
skip_all("Failed to fine executied equity order")
Truth table0%0/3
A // B
A= $orderB= skip_all("Failed to fine executied equity order")
| |||||||||||||||||||||
| 36 | 0 | my ($execution) = $order->executions; | |||||||||||||||||||
| 37 | 0 | isa_ok($execution, __PACKAGE__); | |||||||||||||||||||
| 38 | 0 | t::Utility::stash('ORDER', $order); # Store it for later | |||||||||||||||||||
| 39 | 0 | t::Utility::stash('EXECUTION', $execution); # Store it for later | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | 1 | ▶ | use Mojo::Base-base, -signatures; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 42 | 1 | ▶ | use Mojo::URL; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 43 | 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
| |||||||||||||||||||||
| 44 | 1 | ▶ | use Finance::Robinhood::Equity::Account; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 45 | 1 | ▶ | use Finance::Robinhood::Error; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 46 | 1 | ▶ | use Finance::Robinhood::Equity::Position; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 1 | ▶ | sub _test_stringify { | ||||||||||||||||||
|
Subroutine
_test_stringify: called CC=2 SCAR=9.2
| |||||||||||||||||||||
| 49 | 1 | ▶ | t::Utility::stash('ORDER') // skip_all(); | ||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("ORDER") // skip_all()
MC/DC0%0/2
t::Utility::stash("ORDER") // skip_all()
t::Utility::stash("ORDER")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("ORDER")B= skip_all()
| |||||||||||||||||||||
| 50 | 0 | like(+t::Utility::stash('ORDER'), | |||||||||||||||||||
| 51 | qr'https://api.robinhood.com/orders/.+/'); | ||||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | # | ||||||||||||||||||||
| 54 | 1 | has _rh => undef => weak => 1; | |||||||||||||||||||
| 55 | 1 | has ['id', 'price', 'quantity']; | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | =head2 C<id( )> | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | UUID used to identify this particular execution. | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | =head2 C<price( )> | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | The price for this particular execution. | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | =head2 C<quantity( )> | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | Number of shares for this particular execution. | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | =head2 C<timestamp( )> | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | Returns a Time::Moment object. | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | =cut | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 0 | ▶ | sub timestamp ($s) { | ||||||||||||||||||
|
Subroutine
timestamp: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 76 | 0 | Time::Moment->from_string($s->{timestamp}); | |||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 1 | ▶ | sub _test_timestamp { | ||||||||||||||||||
|
Subroutine
_test_timestamp: called CC=2 SCAR=9.2
| |||||||||||||||||||||
| 80 | 1 | ▶ | t::Utility::stash('EXECUTION') | ||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("EXECUTION") // skip_all("No order execution object in stash")
MC/DC0%0/2
t::Utility::stash("EXECUTION") // skip_all("No order execution object in stash")
t::Utility::stash("EXECUTION")
skip_all("No order execution object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("EXECUTION")B= skip_all("No order execution object in stash")
| |||||||||||||||||||||
| 81 | // skip_all('No order execution object in stash'); | ||||||||||||||||||||
| 82 | 0 | isa_ok(t::Utility::stash('EXECUTION')->timestamp, 'Time::Moment'); | |||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | =head2 C<settlement_date( )> | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | Returns a Time::Moment object. | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | =cut | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 0 | ▶ | sub settlement_date($s) { | ||||||||||||||||||
|
Subroutine
settlement_date: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 92 | 0 | Time::Moment->from_string($s->{settlement_date} . 'T00:00:00Z'); | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | 1 | ▶ | sub _test_settlement_date { | ||||||||||||||||||
|
Subroutine
_test_settlement_date: called CC=2 SCAR=9.2
| |||||||||||||||||||||
| 96 | 1 | ▶ | t::Utility::stash('EXECUTION') | ||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("EXECUTION") // skip_all("No order execution object in stash")
MC/DC0%0/2
t::Utility::stash("EXECUTION") // skip_all("No order execution object in stash")
t::Utility::stash("EXECUTION")
skip_all("No order execution object in stash")
Truth table33%1/3
A // B
A= t::Utility::stash("EXECUTION")B= skip_all("No order execution object in stash")
| |||||||||||||||||||||
| 97 | // skip_all('No order execution object in stash'); | ||||||||||||||||||||
| 98 | 0 | isa_ok(t::Utility::stash('EXECUTION')->settlement_date, 'Time::Moment'); | |||||||||||||||||||
| 99 | } | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | =head1 LEGAL | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | This is a simple wrapper around the API used in the official apps. The author | ||||||||||||||||||||
| 104 | provides no investment, legal, or tax advice and is not responsible for any | ||||||||||||||||||||
| 105 | damages incurred while using this software. This software is not affiliated | ||||||||||||||||||||
| 106 | with Robinhood Financial LLC in any way. | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | For Robinhood's terms and disclosures, please see their website at | ||||||||||||||||||||
| 109 | https://robinhood.com/legal/ | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | =head1 LICENSE | ||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | Copyright (C) Sanko Robinson. | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | This library is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 116 | the terms found in the Artistic License 2. Other copyrights, terms, and | ||||||||||||||||||||
| 117 | conditions may apply to data transmitted through this module. Please refer to | ||||||||||||||||||||
| 118 | the L<LEGAL> section. | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | =head1 AUTHOR | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | =cut | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | 1 | 1; | |||||||||||||||||||