| 1 | package Finance::Robinhood::Forex::Order::Execution; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | =encoding utf-8 | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | =for stopwords watchlist watchlists untradable urls | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | Finance::Robinhood::Forex::Order::Execution - Represents a Single Forex Order | ||||||||||||||||||||
| 10 | Execution | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | use Finance::Robinhood; | ||||||||||||||||||||
| 15 | my $rh = Finance::Robinhood->new; | ||||||||||||||||||||
| 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=4 SCAR=28.7
| |||||||||||||||||||||
| 26 | 1 | my $rh = t::Utility::rh_instance(1); | |||||||||||||||||||
| 27 | 0 | my $orders = $rh->forex_orders; | |||||||||||||||||||
| 28 | 0 | my $order; | |||||||||||||||||||
| 29 | 0 | ▶ | while ($orders->has_next) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | 0 | ▶ | if ($orders->next->state eq 'filled') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 31 | 0 | $order = $orders->current; | |||||||||||||||||||
| 32 | 0 | last; | |||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | 0 | ▶ | $order // skip_all('Cannot find a forex order to test against'); | ||||||||||||||||||
|
Condition0%0/3
$order // skip_all("Cannot find a forex order to test against")
MC/DC0%0/2
$order // skip_all("Cannot find a forex order to test against")
$order
skip_all("Cannot find a forex order to test against")
Truth table0%0/3
A // B
A= $orderB= skip_all("Cannot find a forex order to test against")
| |||||||||||||||||||||
| 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 | 0 | ▶ | use overload '""' => sub ($s, @) { $s->{id} }, fallback => 1; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 1 | ▶ | sub _test_stringify { | ||||||||||||||||||
|
Subroutine
_test_stringify: called CC=2 SCAR=9.2
| |||||||||||||||||||||
| 44 | 1 | ▶ | t::Utility::stash('EXECUTION') // skip_all(); | ||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("EXECUTION") // skip_all()
MC/DC0%0/2
t::Utility::stash("EXECUTION") // skip_all()
t::Utility::stash("EXECUTION")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("EXECUTION")B= skip_all()
| |||||||||||||||||||||
| 45 | 0 | like(+t::Utility::stash('EXECUTION'), | |||||||||||||||||||
| 46 | qr'^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'i | ||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | # | ||||||||||||||||||||
| 50 | 1 | has _rh => undef => weak => 1; | |||||||||||||||||||
| 51 | 1 | has ['effective_price', 'id', 'quantity']; | |||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | =head1 METHODS | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | =head2 C<effective_price( )> | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | Returns a dollar amount. | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | =head2 C<id( )> | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | Returns a UUID. | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | =head2 C<quantity( )> | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | Returns the amount of currency. | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | =cut | ||||||||||||||||||||
| 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 | =head1 LEGAL | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | This is a simple wrapper around the API used in the official apps. The author | ||||||||||||||||||||
| 88 | provides no investment, legal, or tax advice and is not responsible for any | ||||||||||||||||||||
| 89 | damages incurred while using this software. This software is not affiliated | ||||||||||||||||||||
| 90 | with Robinhood Financial LLC in any way. | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | For Robinhood's terms and disclosures, please see their website at | ||||||||||||||||||||
| 93 | https://robinhood.com/legal/ | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | =head1 LICENSE | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | Copyright (C) Sanko Robinson. | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | This library is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 100 | the terms found in the Artistic License 2. Other copyrights, terms, and | ||||||||||||||||||||
| 101 | conditions may apply to data transmitted through this module. Please refer to | ||||||||||||||||||||
| 102 | the L<LEGAL> section. | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =head1 AUTHOR | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | =cut | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | 1 | 1; | |||||||||||||||||||