| 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 | 1 | our $VERSION = '0.92_003'; | |||||||||||||||||||
| 21 | 1 | ▶ | use Mojo::Base-base, -signatures; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | 1 | ▶ | use Mojo::URL; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | 1 | ▶ | use Finance::Robinhood::Forex::Currency; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 1 | ▶ | sub _test__init { | ||||||||||||||||||
|
Subroutine
_test__init: called CC=2 SCAR=15.4
| |||||||||||||||||||||
| 26 | 1 | my $rh = t::Utility::rh_instance(1); | |||||||||||||||||||
| 27 | 0 | my ($cost) = $rh->forex_holdings->current->cost_bases; | |||||||||||||||||||
| 28 | 0 | ▶ | $cost // skip_all('No cost basis found'); | ||||||||||||||||||
|
Condition0%0/3
$cost // skip_all("No cost basis found")
MC/DC0%0/2
$cost // skip_all("No cost basis found")
$cost
skip_all("No cost basis found")
Truth table0%0/3
A // B
A= $costB= skip_all("No cost basis found")
| |||||||||||||||||||||
| 29 | 0 | isa_ok($cost, __PACKAGE__); | |||||||||||||||||||
| 30 | 0 | t::Utility::stash('COST_BASIS', $cost); # Store it for later | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | 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
| |||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 1 | ▶ | sub _test_stringify { | ||||||||||||||||||
|
Subroutine
_test_stringify: called CC=2 SCAR=9.2
| |||||||||||||||||||||
| 35 | 1 | ▶ | t::Utility::stash('COST_BASIS') // skip_all(); | ||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("COST_BASIS") // skip_all()
MC/DC0%0/2
t::Utility::stash("COST_BASIS") // skip_all()
t::Utility::stash("COST_BASIS")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("COST_BASIS")B= skip_all()
| |||||||||||||||||||||
| 36 | 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 | 1 | has _rh => undef => weak => 1; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | =head1 METHODS | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | =head2 C<direct_quantity( )> | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | =head2 C<direct_cost_basis( )> | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | =head2 C<intraday_cost_basis( )> | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | =head2 C<intraday_quantity( )> | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | =head2 C<marked_quantity( )> | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | =head2 C<marked_quantity( )> | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | =cut | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 1 | has ['direct_quantity', 'direct_cost_basis', | |||||||||||||||||||
| 72 | 'intraday_cost_basis', 'intraday_quantity', | ||||||||||||||||||||
| 73 | 'marked_quantity', 'marked_cost_basis' | ||||||||||||||||||||
| 74 | ]; | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | =head2 C<currency( )> | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | Returns a Finance::Robinhood::Forex::Currency object. | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | =cut | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 0 | ▶ | sub currency ($s) { | ||||||||||||||||||
|
Subroutine
currency: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 83 | 0 | $s->_rh->forex_currency_by_id($s->{currency_id}); | |||||||||||||||||||
| 84 | } | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 1 | ▶ | sub _test_currency { | ||||||||||||||||||
|
Subroutine
_test_currency: called CC=2 SCAR=9.2
| |||||||||||||||||||||
| 87 | 1 | ▶ | t::Utility::stash('COST_BASIS') // skip_all(); | ||||||||||||||||||
|
Condition50%1/2
t::Utility::stash("COST_BASIS") // skip_all()
MC/DC0%0/2
t::Utility::stash("COST_BASIS") // skip_all()
t::Utility::stash("COST_BASIS")
skip_all()
Truth table33%1/3
A // B
A= t::Utility::stash("COST_BASIS")B= 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<LEGAL> section. | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | =head1 AUTHOR | ||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | =cut | ||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | 1 | 1; | |||||||||||||||||||