Framework/Asset.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 35 CC 1 SCAR 6.9
CC
1
Cov
0%
rate_for
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Quant::Framework::Asset;
2  
3 =head1 NAME
4  
5 Quant::Framework::Asset
6  
7 =head1 DESCRIPTION
8  
9 Assets have a symbol and rates. Example assets are currencies, indices, stocks
10 and commodities.
11  
12 =cut
13  
14 use Moose;
15 use Quant::Framework::Dividend;
16  
17 use Data::Chronicle::Reader;
18 use Data::Chronicle::Writer;
19 use Date::Utility;
20  
21 =head2 symbol
22  
23 Represents symbol of the asset.
24  
25 =cut
26  
27 has symbol => (
28 is => 'ro',
29 isa => 'Str',
30 required => 1,
31 );
32  
33 has for_date => (
34 is => 'ro',
35 isa => 'Maybe[Date::Utility]',
36 default => undef,
37 );
38  
39 =head2 chronicle_reader and chronicle_writer
40  
41 Used to work with Chronicle storage data.
42  
43 =cut
44  
45 has chronicle_reader => (
46 is => 'ro',
47 isa => 'Data::Chronicle::Reader',
48 );
49  
50 has chronicle_writer => (
51 is => 'ro',
52 isa => 'Data::Chronicle::Writer',
53 );
54  
55 =head2 rate_for
56 Returns dividend rates
57 =cut
58  
59 sub rate_for {
60 my ($self, $tiy) = @_;
61  
62 my $dividend = Quant::Framework::Dividend->new(
63 symbol => $self->symbol,
64 for_date => $self->for_date,
65 chronicle_reader => $self->chronicle_reader,
66 chronicle_writer => $self->chronicle_writer,
67 );
68  
69 my $rate = $dividend->rate_for($tiy);
70  
71 return $rate;
72 }
73  
74 no Moose;
75 __PACKAGE__->meta->make_immutable;
76  
77 1;