File Coverage

lib/Finance/Robinhood/Forex/Order/Execution.pm
Criterion Covered Total %
statement 12 33 36.3
branch 0 2 0.0
condition 2 7 28.5
subroutine 6 8 75.0
pod 1 1 100.0
total 21 51 41.1


line stmt bran cond sub pod time code
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             our $VERSION = '0.92_001';
22 1     1   6 use Mojo::Base-base, -signatures;
  1         2  
  1         8  
23 1     1   193 use Mojo::URL;
  1         2  
  1         7  
24              
25             sub _test__init {
26 1     1   12776 my $rh = t::Utility::rh_instance(1);
27 0         0 my $orders = $rh->forex_orders;
28 0         0 my $order;
29 0         0 while ( $orders->has_next ) {
30 0 0       0 if ( $orders->next->state eq 'filled' ) {
31 0         0 $order = $orders->current;
32 0         0 last;
33             }
34             }
35 0   0     0 $order // skip_all('Cannot find a forex order to test against');
36 0         0 my ($execution) = $order->executions;
37 0         0 isa_ok( $execution, __PACKAGE__ );
38 0         0 t::Utility::stash( 'ORDER', $order ); # Store it for later
39 0         0 t::Utility::stash( 'EXECUTION', $execution ); # Store it for later
40             }
41 1     1   250 use overload '""' => sub ( $s, @ ) { $s->{id} }, fallback => 1;
  1     0   2  
  1         8  
  0         0  
  0         0  
  0         0  
  0         0  
42              
43             sub _test_stringify {
44 1   50 1   1971 t::Utility::stash('EXECUTION') // skip_all();
45 0         0 like(
46             +t::Utility::stash('EXECUTION'),
47             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
48             );
49             }
50             #
51             has _rh => undef => weak => 1;
52             has [ 'effective_price', 'id', 'quantity' ];
53              
54             =head1 METHODS
55            
56             =head2 C
57              
58             Returns a dollar amount.
59              
60             =head2 C
61              
62             Returns a UUID.
63              
64             =head2 C
65              
66             Returns the amount of currency.
67              
68             =cut
69              
70             =head2 C
71              
72             Returns a Time::Moment object.
73              
74             =cut
75              
76 0     0 1 0 sub timestamp ($s) {
  0         0  
  0         0  
77 0         0 Time::Moment->from_string( $s->{timestamp} );
78             }
79              
80             sub _test_timestamp {
81 1   50 1   1819 t::Utility::stash('EXECUTION') // 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 section.
103              
104             =head1 AUTHOR
105              
106             Sanko Robinson Esanko@cpan.orgE
107              
108             =cut
109              
110             1;