| 1 | package Quant::Framework::Utils::Rates; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | extends 'Quant::Framework::Utils::MarketData'; | ||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use Date::Utility; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | has rates => ( | ||||||||||
| 9 | is => 'ro', | ||||||||||
| 10 | lazy_build => 1, | ||||||||||
| 11 | ); | ||||||||||
| 12 | |||||||||||
| 13 | sub _build_rates { | ||||||||||
| 14 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_build_rates: not called CC=2 SCAR=17.9
| |||||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | die 'No rates found for ' . $self->symbol if not defined $self->document; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | |||||||||||
| 18 | 0 | my $result = $self->document->{rates}; | |||||||||
| 19 | |||||||||||
| 20 | 0 | return $result; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | =head2 rate_for | ||||||||||
| 24 | |||||||||||
| 25 | Returns the rate for a particular timeinyears for symbol. | ||||||||||
| 26 | ->rate_for(7/365) | ||||||||||
| 27 | |||||||||||
| 28 | =cut | ||||||||||
| 29 | |||||||||||
| 30 | sub rate_for { | ||||||||||
| 31 | 0 | ▶ | my ($self, $tiy) = @_; | ||||||||
|
Subroutine
rate_for: not called CC=2 SCAR=17.9
| |||||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | die "No rates found for " . $self->symbol if not defined $self->rates; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | 0 | my $interp = Math::Function::Interpolator->new(points => $self->rates); | |||||||||
| 36 | 0 | return $interp->linear($tiy * 365) / 100; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 2 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 40 | __PACKAGE__->meta->make_immutable; | ||||||||||
| 41 | 1; | ||||||||||