File Coverage

lib/Finance/Robinhood/ACATS/Transfer/Position.pm
Criterion Covered Total %
statement 11 22 50.0
branch 0 6 0.0
condition 1 2 50.0
subroutine 5 6 83.3
pod 1 1 100.0
total 18 37 48.6


line stmt bran cond sub pod time code
1             package Finance::Robinhood::ACATS::Transfer::Position;
2              
3             =encoding utf-8
4              
5             =for stopwords watchlist watchlists untradable urls
6              
7             =head1 NAME
8              
9             Finance::Robinhood::ACATS::Transfer::Position - Represents a Single Position in
10             an ACATS Transfer
11              
12             =head1 SYNOPSIS
13              
14             use Finance::Robinhood;
15             my $rh = Finance::Robinhood->new;
16            
17             ...
18             CORE::say $_->instrument->symbol for @{$transfer->equity_positions};
19              
20             =cut
21              
22             our $VERSION = '0.92_003';
23 1     1   8 use Mojo::Base-base, -signatures;
  1         3  
  1         7  
24 1     1   190 use Mojo::URL;
  1         3  
  1         5  
25 1     1   26 use Time::Moment;
  1         3  
  1         318  
26              
27             sub _test__init {
28 1     1   11398 my $rh = t::Utility::rh_instance(1);
29 0         0 my $transfer = $rh->acats_transfers->current;
30 0 0       0 skip_all('No ACATS transfers found') if !defined $transfer;
31 0         0 isa_ok($transfer->equity_positions->[0], __PACKAGE__);
32 0         0 t::Utility::stash('POSITION', $transfer->equity_positions->[0])
33             ; # Store it for later
34             }
35             #
36             has _rh => undef => weak => 1;
37              
38             =head1 METHODS
39              
40            
41             =head2 C
42              
43             Average price for this position.
44              
45             =head2 C
46              
47             Number of shares in this position
48              
49             =cut
50              
51             has ['price', 'quantity'];
52              
53             =head2 C
54              
55             my $instrument = $position->instrument();
56              
57             Loops back to a Finance::Robinhood::Equity::Instrument object.
58              
59             =cut
60              
61 0     0 1 0 sub instrument ($s) {
  0         0  
  0         0  
62 0         0 my $res = $s->_rh->_get($s->{instrument});
63             $res->is_success
64             ? Finance::Robinhood::Equity::Instrument->new(_rh => $s->_rh,
65 0 0       0 %{$res->json})
  0 0       0  
66             : Finance::Robinhood::Error->new(
67             $res->is_server_error ? (details => $res->message) : $res->json);
68             }
69              
70             sub _test_instrument {
71 1   50 1   2073 t::Utility::stash('POSITION') // skip_all();
72 0           isa_ok(t::Utility::stash('POSITION')->instrument,
73             'Finance::Robinhood::Equity::Instrument');
74             }
75              
76             =head1 LEGAL
77              
78             This is a simple wrapper around the API used in the official apps. The author
79             provides no investment, legal, or tax advice and is not responsible for any
80             damages incurred while using this software. This software is not affiliated
81             with Robinhood Financial LLC in any way.
82              
83             For Robinhood's terms and disclosures, please see their website at
84             https://robinhood.com/legal/
85              
86             =head1 LICENSE
87              
88             Copyright (C) Sanko Robinson.
89              
90             This library is free software; you can redistribute it and/or modify it under
91             the terms found in the Artistic License 2. Other copyrights, terms, and
92             conditions may apply to data transmitted through this module. Please refer to
93             the L section.
94              
95             =head1 AUTHOR
96              
97             Sanko Robinson Esanko@cpan.orgE
98              
99             =cut
100              
101             1;