Instrument/FuturesContract.pm

filter: Statementstmt 96.8% 62 / 64 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 15 / 15 Podpod n/a totaltotal 95.4% 83 / 87 CC 7 SCAR 7.2
CC
7
Cov
94%
BUILDARGS
4.0
__ANON__
4.0
BEGIN
1.0
CRAP 2.0
« Instrument.pm ↑ Summary Instrument/Option.pm »
1 package Finance::Instrument::FuturesContract;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use 5.008_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 our $VERSION = '0.01';
6  
7 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use methods;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use DateTime::Format::Strptime;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 extends 'Finance::Instrument';
12  
13 4 has futures => (is => "rw", isa => "Finance::Instrument::Futures",
14 handles => [qw(name exchange tick_size multiplier time_zone currency session
15 override_since attr)]);
16  
17 4 has expiry_year => (is => "rw", isa => "Int");
18 4 has expiry_month => (is => "rw", isa => "Int");
19  
20 4 has last_trading_day => (is => "rw", isa => 'DateTime');
21  
22 4 has first_trading_day => (is => "rw", isa => "DateTime");
23  
24  
25 5 ▶method BUILDARGS {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BUILDARGS: called CC=4 SCAR=13.9
Subroutine __ANON__: called CC=4 SCAR=13.9
26 3 my %args = @_;
27 my $strp = DateTime::Format::Strptime->new(
28 pattern => '%F',
29 3 time_zone => $args{futures}->time_zone);
30 3 for (qw(last_trading_day first_trading_day)) {
31 6 ▶ if ($args{$_}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($args{$_}) 2 4 6
if ($args{$_}) 1 1 2
32 $args{$_} = $strp->parse_datetime($args{$_})
33 2 ▶ unless ref $args{$_};
Branch: 2 branches
BranchTrueFalseTotal
unless ref $args{$_} 2 0 2
unless ref $args{$_} 1 0 1
34 }
35 }
36 3 return \%args;
37 4 }
38  
39 5 ▶method expiry { sprintf("%04d%02d", $self->expiry_year, $self->expiry_month) }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine expiry: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
40  
41 0 ▶method code { $self->futures->code.'_'.$self->expiry }
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine code: called CC=1 SCAR=0.2
42  
43 5 ▶method previous_contract {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine previous_contract: called CC=1 SCAR=0.0
44 1 $self->futures->previous_contract($self->expiry_year, $self->expiry_month);
45 4 }
46  
47  
48  
49 4 1;
50 __END__
« Instrument.pm ↑ Summary Instrument/Option.pm »