File Coverage

lib/Finance/Robinhood/Forex/Cost.pm
Criterion Covered Total %
statement 15 29 51.7
branch n/a
condition 2 7 28.5
subroutine 7 9 77.7
pod 1 1 100.0
total 25 46 54.3


line stmt bran cond sub pod time code
1             package Finance::Robinhood::Forex::Cost;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls forex
6              
7             =head1 NAME
8              
9             Finance::Robinhood::Forex::Cost - Represents a Forex Positio's Cost Basis
10              
11             =head1 SYNOPSIS
12              
13             use Finance::Robinhood;
14             my $rh = Finance::Robinhood->new;
15              
16             # TODO
17              
18             =cut
19              
20             our $VERSION = '0.92_003';
21 1     1   4207 use Mojo::Base-base, -signatures;
  1         5  
  1         9  
22 1     1   212 use Mojo::URL;
  1         3  
  1         6  
23 1     1   30 use Finance::Robinhood::Forex::Currency;
  1         2  
  1         8  
24              
25             sub _test__init {
26 1     1   8077 my $rh = t::Utility::rh_instance(1);
27 0         0 my ($cost) = $rh->forex_holdings->current->cost_bases;
28 0   0     0 $cost // skip_all('No cost basis found');
29 0         0 isa_ok($cost, __PACKAGE__);
30 0         0 t::Utility::stash('COST_BASIS', $cost); # Store it for later
31             }
32 1     1   174 use overload '""' => sub ($s, @) { $s->{id} }, fallback => 1;
  1     0   4  
  1         15  
  0         0  
  0         0  
  0         0  
  0         0  
33              
34             sub _test_stringify {
35 1   50 1   1830 t::Utility::stash('COST_BASIS') // skip_all();
36 0         0 like(+t::Utility::stash('COST_BASIS'),
37             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
38             );
39             }
40             #
41             has _rh => undef => weak => 1;
42              
43             =head1 METHODS
44              
45              
46              
47             =head2 C
48              
49              
50              
51             =head2 C
52              
53              
54              
55             =head2 C
56              
57              
58              
59             =head2 C
60              
61              
62              
63             =head2 C
64              
65              
66              
67             =head2 C
68              
69             =cut
70              
71             has ['direct_quantity', 'direct_cost_basis',
72             'intraday_cost_basis', 'intraday_quantity',
73             'marked_quantity', 'marked_cost_basis'
74             ];
75              
76             =head2 C
77              
78             Returns a Finance::Robinhood::Forex::Currency object.
79              
80             =cut
81              
82 0     0 1 0 sub currency ($s) {
  0         0  
  0         0  
83 0         0 $s->_rh->forex_currency_by_id($s->{currency_id});
84             }
85              
86             sub _test_currency {
87 1   50 1   2061 t::Utility::stash('COST_BASIS') // skip_all();
88 0           isa_ok(t::Utility::stash('COST_BASIS')->currency,
89             'Finance::Robinhood::Forex::Currency');
90             }
91              
92             =head1 LEGAL
93              
94             This is a simple wrapper around the API used in the official apps. The author
95             provides no investment, legal, or tax advice and is not responsible for any
96             damages incurred while using this software. This software is not affiliated
97             with Robinhood Financial LLC in any way.
98              
99             For Robinhood's terms and disclosures, please see their website at
100             https://robinhood.com/legal/
101              
102             =head1 LICENSE
103              
104             Copyright (C) Sanko Robinson.
105              
106             This library is free software; you can redistribute it and/or modify it under
107             the terms found in the Artistic License 2. Other copyrights, terms, and
108             conditions may apply to data transmitted through this module. Please refer to
109             the L section.
110              
111             =head1 AUTHOR
112              
113             Sanko Robinson Esanko@cpan.orgE
114              
115             =cut
116              
117             1;