blib/lib/Finance/Robinhood/Options/Instrument.pm

filter: Statementstmt 61.1% 22 / 36 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 54.5% 6 / 11 Podpod 50.0% 1 / 2 totaltotal 52.7% 29 / 55 CC 4 SCAR 14.6
CC
4
Cov
52%
historicals
12.0
market_data
6.0
__ANON__
2.0
CRAP 4.3
« blib/lib/Finance/Robinhood/Utils.pm ↑ Summary blib/lib/Finance/Robinhood/ACH/ScheduledDeposit.pm »
1 package Finance::Robinhood::Options::Instrument;
2 3 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use DateTime::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Date::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Finance::Robinhood::Options::MarketData;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Finance::Robinhood::Options::Instrument::Historicals;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 has [qw[tradability strike_price chain_id state type chain_symbol id url]] => ( is => 'ro' );
9 has 'expiration_date' => (
10 is => 'ro',
11 coerce => sub {
12 0 ▶ Date::Tiny->from_string( $_[0] );
Subroutine __ANON__: not called CC=1 SCAR=6.9
13 }
14 3 );
15 has [ 'created_at', 'updated_at' ] => (
16 is => 'ro',
17 coerce => sub {
18 0 ▶ $_[0] =~ s'Z$'';
Subroutine __ANON__: not called CC=1 SCAR=6.9
19  
20 # BUG: DateTime::Tiny cannot handle sub-second values.
21 0 $_[0] =~ s'\..+$'';
22 0 DateTime::Tiny->from_string( $_[0] );
23 }
24 3 );
25 has 'min_ticks' => (
26 is => 'ro',
27 coerce => sub {
28 0 ▶ $_[0]; # { above_tick => "0.10", below_tick => 0.05, cutoff_price => "3.00" }
Subroutine __ANON__: not called CC=1 SCAR=6.9
29 }
30 3 );
31  
32 sub market_data {
33 0 ▶ my ($s) = shift;
Subroutine market_data: not called CC=2 SCAR=17.9
Pod undocumented
34 0 warn sprintf $Finance::Robinhood::Endpoints{'marketdata/options/{id}'}, $s->id;
35 my ( $status, $data )
36 = Finance::Robinhood::Utils::Client->instance->get(
37 0 sprintf $Finance::Robinhood::Endpoints{'marketdata/options/{id}'}, $s->id );
38 0 ▶ $status == 200 ? Finance::Robinhood::Options::MarketData->new($data) : $data;
Branch: 1 branch
BranchTrueFalseTotal
$status == 200 ? : 0 0 0
39 }
40  
41 =head2 C<historicals( ... )>
42  
43 my $ok = $options->historicals();
44  
45 Gather info about all supported options chains. This is returned as a C<Finance::Robinhood::Utils::Paginated> object.
46  
47 my $inst = $rh->options_chains( ids => ['0c0959c2-eb3a-4e3b-8310-04d7eda4b35c'] );
48 my $all = $inst->all;
49  
50 The following arguments are acepted:
51  
52 =over
53  
54 =item C<interval> - C<day>, C<week>, or C<month>
55  
56 =item C<span> - C<year>, C<5year>, or C<10year>
57  
58 =back
59  
60 C<interval> is required.
61  
62 =cut
63  
64 sub historicals {
65 0 ▶ my ( $s, %args ) = @_;
Subroutine historicals: not called CC=3 SCAR=24.8
Pod documented
66 my ( $status, $data ) = Finance::Robinhood::Utils::Client->instance->get(
67 join '?',
68 sprintf( $Finance::Robinhood::Endpoints{'marketdata/options/historicals/{id}/'}, $s->id ), (
69 join '&',
70 map {
71 0 $_ . '=' .
72 0 ▶ ( ref $args{$_} eq 'ARRAY' ? ( join ',', @{ $args{$_} } ) : $args{$_} )
Branch: 1 branch
BranchTrueFalseTotal
ref $args{$_} eq 'ARRAY' ? : 0 0 0
73 } keys %args
74 )
75 );
76 0 ▶ $status == 200 ? Finance::Robinhood::Options::Instrument::Historicals->new($data) : $data;
Branch: 1 branch
BranchTrueFalseTotal
$status == 200 ? : 0 0 0
77 }
78 3 1;
« blib/lib/Finance/Robinhood/Utils.pm ↑ Summary blib/lib/Finance/Robinhood/ACH/ScheduledDeposit.pm »