Math-Business-Lookback
view release on metacpan or search on metacpan
{
"abstract" : "The Black-Scholes formula for Lookback options.",
"author" : [
"binary.com <binary@cpan.org>"
],
"dynamic_config" : 0,
"generated_by" : "Dist::Zilla version 6.024, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
---
abstract: 'The Black-Scholes formula for Lookback options.'
author:
- 'binary.com <binary@cpan.org>'
build_requires:
ExtUtils::MakeMaker: '0'
File::Spec: '0'
Format::Util::Numbers: '0'
IO::Handle: '0'
IPC::Open3: '0'
Test::CheckDeps: '0.010'
Test::Exception: '0'
Makefile.PL view on Meta::CPAN
# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.024.
use strict;
use warnings;
use 5.014000;
use ExtUtils::MakeMaker 7.64;
my %WriteMakefileArgs = (
"ABSTRACT" => "The Black-Scholes formula for Lookback options.",
"AUTHOR" => "binary.com <binary\@cpan.org>",
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => "7.64"
},
"DISTNAME" => "Math-Business-Lookback",
"LICENSE" => "perl",
"MIN_PERL_VERSION" => "5.014000",
"NAME" => "Math::Business::Lookback",
"PREREQ_PM" => {
"List::Util" => 0,
(7/365), # time
0.002, # payout currency interest rate (0.05 = 5%)
0.001, # quanto drift adjustment (0.05 = 5%)
0.11, # volatility (0.3 = 30%)
1.39, # maximum spot
undef # minimum spot
);
DESCRIPTION
Prices lookback options using the GBM model, all closed formulas.
SUBROUTINES
lbfloatcall
USAGE
my $price = lbfloatcall($S, $K, $t, $r_q, $mu, $sigma, $S_max, $S_min)
DESCRIPTION
Price of a Lookback Float Call
lbhighlow
USAGE
my $price = lbhighlow($S, $K, $t, $r_q, $mu, $sigma, $S_max, $S_min)
DESCRIPTION
Price of a Lookback High Low
d1_function
returns the d1 term common to many BlackScholes formulae.
l_max
This is a common function use to calculate the lookbacks options price.
See [1] for details.
l_min
This is a common function use to calculate the lookbacks options price.
See [1] for details.
lib/Math/Business/Lookback.pm view on Meta::CPAN
package Math::Business::Lookback;
use strict;
use warnings;
use List::Util qw(max min);
use Math::CDF qw(pnorm);
use Math::Business::Lookback::Common;
# ABSTRACT: The Black-Scholes formula for Lookback options.
our $VERSION = '0.01';
=head1 NAME
Math::Business::Lookback
=head1 SYNOPSIS
use Math::Business::Lookback;
lib/Math/Business/Lookback.pm view on Meta::CPAN
(7/365), # time
0.002, # payout currency interest rate (0.05 = 5%)
0.001, # quanto drift adjustment (0.05 = 5%)
0.11, # volatility (0.3 = 30%)
1.39, # maximum spot
undef # minimum spot
);
=head1 DESCRIPTION
Prices lookback options using the GBM model, all closed formulas.
=head1 SUBROUTINES
=head2 lbfloatcall
USAGE
my $price = lbfloatcall($S, $K, $t, $r_q, $mu, $sigma, $S_max, $S_min)
DESCRIPTION
Price of a Lookback Float Call
lib/Math/Business/Lookback.pm view on Meta::CPAN
sub lbhighlow {
my ($S, $K, $t, $r_q, $mu, $sigma, $S_max, $S_min) = @_;
my $value = lbfloatcall($S, $S_min, $t, $r_q, $mu, $sigma, $S_max, $S_min) + lbfloatput($S, $S_max, $t, $r_q, $mu, $sigma, $S_max, $S_min);
return $value;
}
=head2 d1_function
returns the d1 term common to many BlackScholes formulae.
=cut
sub d1_function {
my ($S, $K, $t, $r_q, $mu, $sigma) = @_;
my $value = (log($S / $K) + ($mu + $sigma * $sigma * 0.5) * $t) / ($sigma * sqrt($t));
return $value;
}
t/benchmark.t view on Meta::CPAN
my $spot = $args->{spot};
my $discount_rate = $args->{discount_rate};
my $t = $args->{t};
my $mu = $args->{mu};
my $sigma = $args->{vol};
my $s_max = $args->{spot_max};
my $s_min = $args->{spot_min};
my $price;
my $formula = 'Math::Business::Lookback::' . $type;
my $func = \&$formula;
$price = $func->($spot, $strike, $t, $discount_rate, $mu, $sigma, $s_max, $s_min);
my $diff = abs($price - $expected) / $expected;
cmp_ok($diff, '<', 0.08, 'Diff is within permissible range');
}
sub test_greek {
my $args = shift;
t/benchmark.t view on Meta::CPAN
my $spot = $args->{spot};
my $discount_rate = $args->{discount_rate};
my $t = $args->{t};
my $mu = $args->{mu};
my $sigma = $args->{vol};
my $s_max = $args->{spot_max};
my $s_min = $args->{spot_min};
my $price;
my $formula = 'Math::Business::Lookback::Greeks::Delta::' . $type;
my $func = \&$formula;
$price = $func->($spot, $strike, $t, $discount_rate, $mu, $sigma, $s_max, $s_min);
my $diff = abs($price - $expected) / $expected;
cmp_ok($diff, '<', 0.12, 'Diff is within permissible range');
}
done_testing;
my $spot = $args->{spot};
my $discount_rate = $args->{discount_rate};
my $t = $args->{t};
my $mu = $args->{mu};
my $sigma = $args->{vol};
my $s_max = $args->{spot_max};
my $s_min = $args->{spot_min};
my $price;
my $formula = 'Math::Business::Lookback::Greeks::Delta::' . $type;
my $func = \&$formula;
$price = $func->($spot, $strike, $t, $discount_rate, $mu, $sigma, $s_max, $s_min);
is roundnear(0.00001, $price), roundnear(0.00001, $expected), "correct delta for " . $type;
}
done_testing;
t/price_test.t view on Meta::CPAN
my $spot = $args->{spot};
my $discount_rate = $args->{discount_rate};
my $t = $args->{t};
my $mu = $args->{mu};
my $sigma = $args->{vol};
my $s_max = $args->{spot_max};
my $s_min = $args->{spot_min};
my $price;
my $formula = 'Math::Business::Lookback::' . $type;
my $func = \&$formula;
$price = $func->($spot, $strike, $t, $discount_rate, $mu, $sigma, $s_max, $s_min);
is roundnear(0.00001, $price), roundnear(0.00001, $expected), "correct price for " . $type;
}
done_testing;
( run in 0.747 second using v1.01-cache-2.11-cpan-26ccb49234f )