📄 pathdependentasiangeometric.cpp
字号:
#include "PathDependentAsianGeometric.h"
PathDependentAsianGeometric::PathDependentAsianGeometric(const MJArray& LookAtTimes_,
double DeliveryTime_,
const PayOffBridge& ThePayOff_)
:
PathDependent(LookAtTimes_),
DeliveryTime(DeliveryTime_),
ThePayOff(ThePayOff_),
NumberOfTimes(LookAtTimes_.size())
{
}
unsigned long PathDependentAsianGeometric::MaxNumberOfCashFlows() const
{
return 1UL;
}
MJArray PathDependentAsianGeometric::PossibleCashFlowTimes() const
{
MJArray tmp(1UL);
tmp[0] = DeliveryTime;
return tmp;
}
unsigned long PathDependentAsianGeometric::CashFlows(const MJArray& SpotValues,
std::vector<CashFlow>& GeneratedFlows) const
{
long double sum =1;
for (size_t i=0; i<SpotValues.size();i++)
sum=sum*SpotValues[i];
long double M=1.0/NumberOfTimes;
long double mean = pow(sum,M);
GeneratedFlows[0].TimeIndex = 0UL;
GeneratedFlows[0].Amount = ThePayOff(mean);
return 1UL;
}
PathDependent* PathDependentAsianGeometric::clone() const
{
return new PathDependentAsianGeometric(*this);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -