Framework/Spot/OHLC.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 26 CC 1 SCAR 6.9
CC
1
Cov
0%
invert_values
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Quant::Framework::Spot::OHLC;
2  
3 =head1 NAME
4  
5 Quant::Framework::Spot::OHLC
6  
7 =head1 SYNOPSYS
8  
9 my $ohlc = Quant::Framework::Spot::OHLC->new({
10 epoch => 1340871449,
11 open => 2.1,
12 high => 2.2,
13 low => 2.1,
14 close => 2.2,
15 });
16  
17 =head1 DESCRIPTION
18  
19 This class represents OHLC data
20  
21 =head1 ATTRIBUTES
22  
23 =cut
24  
25 use Moose;
26 use MooseX::StrictConstructor;
27 use namespace::autoclean;
28  
29 =head2 epoch
30  
31 represent starting time in epoch of the OHLC interval
32  
33 =cut
34  
35 has 'epoch' => (
36 is => 'ro',
37 required => 1,
38 isa => 'Int',
39 );
40  
41 =head2 open
42  
43 represents the value of the underying at the open of the interval
44  
45 =head2 high
46  
47 represents the highest value of the underying in interval
48  
49 =head2 low
50  
51 represents the lowest value of the underying in interval
52  
53 =head2 close
54  
55 represents the value of the underying at the close of the interval
56  
57 =cut
58  
59 has [qw(open high low close)] => (
60 is => 'rw',
61 required => 1,
62 isa => 'Num',
63 );
64  
65 has 'official' => (
66 is => 'ro',
67 isa => 'Bool',
68 default => undef,
69 );
70  
71 =head2 invert_values
72  
73 Invert values of OHL and C in-place.
74  
75 =cut
76  
77 sub invert_values {
78 my $self = shift;
79  
80 my $high = $self->high;
81 $self->open(1 / $self->open);
82 $self->close(1 / $self->close);
83 $self->high(1 / $self->low);
84 $self->low(1 / $high);
85  
86 return $self;
87 }
88  
89 __PACKAGE__->meta->make_immutable;
90  
91 1;
92  
93