line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Instrument::FuturesContract; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
28
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
185
|
|
4
|
5
|
|
|
5
|
|
128
|
use 5.008_001; |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
274
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
27
|
use Moose; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
37
|
|
8
|
5
|
|
|
5
|
|
34357
|
use methods; |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
46
|
|
9
|
5
|
|
|
5
|
|
14210
|
use DateTime::Format::Strptime; |
|
5
|
|
|
|
|
165561
|
|
|
5
|
|
|
|
|
911
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends 'Finance::Instrument'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
has expiry_year => (is => "rw", isa => "Int"); |
18
|
|
|
|
|
|
|
has expiry_month => (is => "rw", isa => "Int"); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has last_trading_day => (is => "rw", isa => 'DateTime'); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has first_trading_day => (is => "rw", isa => "DateTime"); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
5
|
|
|
5
|
|
1963
|
method BUILDARGS { |
|
4
|
|
|
4
|
|
47
|
|
|
4
|
|
|
|
|
7
|
|
26
|
4
|
|
|
|
|
28
|
my %args = @_; |
27
|
4
|
|
|
|
|
192
|
my $strp = DateTime::Format::Strptime->new( |
28
|
|
|
|
|
|
|
pattern => '%F', |
29
|
|
|
|
|
|
|
time_zone => $args{futures}->time_zone); |
30
|
4
|
|
|
|
|
24809
|
for (qw(last_trading_day first_trading_day)) { |
31
|
8
|
100
|
|
|
|
3920
|
if ($args{$_}) { |
32
|
3
|
50
|
|
|
|
28
|
$args{$_} = $strp->parse_datetime($args{$_}) |
33
|
|
|
|
|
|
|
unless ref $args{$_}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
4
|
|
|
|
|
44
|
return \%args; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
5
|
|
2149
|
method expiry { sprintf("%04d%02d", $self->expiry_year, $self->expiry_month) } |
|
7
|
|
|
7
|
|
71
|
|
|
7
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
328
|
|
40
|
|
|
|
|
|
|
|
41
|
5
|
|
|
5
|
|
1700
|
method code { $self->futures->code.'_'.$self->expiry } |
|
4
|
|
|
4
|
|
11
|
|
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
175
|
|
42
|
|
|
|
|
|
|
|
43
|
5
|
|
|
5
|
|
1672
|
method previous_contract { |
|
1
|
|
|
1
|
|
545
|
|
|
1
|
|
|
|
|
2
|
|
44
|
1
|
|
|
|
|
59
|
$self->futures->previous_contract($self->expiry_year, $self->expiry_month); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
__END__ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=encoding utf-8 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=for stopwords |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Finance::Instrument - |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SYNOPSIS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
use Finance::Instrument; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 DESCRIPTION |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Finance::Instrument is |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 AUTHOR |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Chia-liang Kao E<lt>clkao@clkao.orgE<gt> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 LICENSE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
75
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SEE ALSO |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |