本文整理汇总了C++中TimeGrid::mandatoryTimes方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeGrid::mandatoryTimes方法的具体用法?C++ TimeGrid::mandatoryTimes怎么用?C++ TimeGrid::mandatoryTimes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeGrid
的用法示例。
在下文中一共展示了TimeGrid::mandatoryTimes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: discountFactors
inline boost::shared_ptr<LongstaffSchwartzMultiPathPricer>
MCAmericanPathEngine<RNG>::lsmPathPricer() const {
boost::shared_ptr<StochasticProcessArray> processArray =
boost::dynamic_pointer_cast<StochasticProcessArray>(this->process_);
QL_REQUIRE(processArray && processArray->size()>0,
"Stochastic process array required");
boost::shared_ptr<GeneralizedBlackScholesProcess> process =
boost::dynamic_pointer_cast<GeneralizedBlackScholesProcess>(
processArray->process(0));
QL_REQUIRE(process, "generalized Black-Scholes process required");
const TimeGrid theTimeGrid = this->timeGrid();
const std::vector<Time> & times = theTimeGrid.mandatoryTimes();
const Size numberOfTimes = times.size();
const std::vector<Date> & fixings = this->arguments_.fixingDates;
QL_REQUIRE(fixings.size() == numberOfTimes, "Invalid dates/times");
std::vector<Size> timePositions(numberOfTimes);
Array discountFactors(numberOfTimes);
std::vector<Handle<YieldTermStructure> > forwardTermStructures(numberOfTimes);
const Handle<YieldTermStructure> & riskFreeRate = process->riskFreeRate();
for (Size i = 0; i < numberOfTimes; ++i) {
timePositions[i] = theTimeGrid.index(times[i]);
discountFactors[i] = riskFreeRate->discount(times[i]);
forwardTermStructures[i] = Handle<YieldTermStructure>(
boost::make_shared<ImpliedTermStructure>(riskFreeRate,
fixings[i]));
}
const Size polynomialOrder = 2;
const LsmBasisSystem::PolynomType polynomType = LsmBasisSystem::Monomial;
return boost::shared_ptr<LongstaffSchwartzMultiPathPricer> (
new LongstaffSchwartzMultiPathPricer(this->arguments_.payoff,
timePositions,
forwardTermStructures,
discountFactors,
polynomialOrder,
polynomType));
}
示例2: discountFactors
inline
boost::shared_ptr<typename MCPathBasketEngine<RNG,S>::path_pricer_type>
MCPathBasketEngine<RNG,S>::pathPricer() const {
boost::shared_ptr<PathPayoff> payoff = arguments_.payoff;
QL_REQUIRE(payoff, "non-basket payoff given");
boost::shared_ptr<GeneralizedBlackScholesProcess> process =
boost::dynamic_pointer_cast<GeneralizedBlackScholesProcess>(
process_->process(0));
QL_REQUIRE(process, "Black-Scholes process required");
const TimeGrid theTimeGrid = timeGrid();
const std::vector<Time> & times = theTimeGrid.mandatoryTimes();
const Size numberOfTimes = times.size();
const std::vector<Date> & fixings = this->arguments_.fixingDates;
QL_REQUIRE(fixings.size() == numberOfTimes, "Invalid dates/times");
std::vector<Size> timePositions(numberOfTimes);
Array discountFactors(numberOfTimes);
std::vector<Handle<YieldTermStructure> > forwardTermStructures(numberOfTimes);
const Handle<YieldTermStructure> & riskFreeRate = process->riskFreeRate();
for (Size i = 0; i < numberOfTimes; ++i) {
timePositions[i] = theTimeGrid.index(times[i]);
discountFactors[i] = riskFreeRate->discount(times[i]);
forwardTermStructures[i] = Handle<YieldTermStructure>(
new ImpliedTermStructure(riskFreeRate, fixings[i]));
}
return boost::shared_ptr<
typename MCPathBasketEngine<RNG,S>::path_pricer_type>(
new EuropeanPathMultiPathPricer(payoff, timePositions,
forwardTermStructures,
discountFactors));
}
示例3: discountFactors
boost::shared_ptr<ELSNotionalProtectedPricer> MCELSNotionalProtectedEngine::pathPricer() const{
/*boost::shared_ptr<GeneralizedBlackScholesProcess> process =
boost::dynamic_pointer_cast<GeneralizedBlackScholesProcess>(
process_->process(0));
QL_REQUIRE(process, "Black-Scholes process required");*/
TimeGrid theTimeGrid = timeGrid();
const std::vector<Time> & times = theTimeGrid.mandatoryTimes();
Size numberOfTimes = times.size();
Size numAssets = process_->size();
Size pastFixingNum=this->arguments_.pastFixingDateNum;
const std::vector<Date> & fixings = this->arguments_.fixingDates;
const std::vector<boost::shared_ptr<StockIndex>>& refIndex=arguments_.refIndex;
DayCounter dayCounter = this->arguments_.dayCounter;
std::vector<Real> initialValues = this->arguments_.initialValues;
std::vector<Real> dividends = this->arguments_.dividends; // 후에 TS로 수정
Real redemCoupon= this->arguments_.redemCoupon;
std::vector<Date> remainfixings;
//오늘일자를 TS에서 가져옴.
Date today = Settings::instance().evaluationDate();
Size numberOfFixings = fixings.size();
for(Size i=0;i<numberOfFixings;++i){
if(fixings[i]>today){
remainfixings.push_back(fixings[i]);
}
}
Size numberOfRemainFixings = remainfixings.size();
additionalStats_.resize(numberOfTimes+pastFixingNum);
underlyingValue_.resize(numAssets);
QL_REQUIRE(numberOfRemainFixings == numberOfTimes, "Invalid dates/times");
std::vector<Size> timePositions(numberOfTimes);
Array discountFactors(numberOfTimes);
for (Size i = 0; i < numberOfTimes; ++i) {
//timePositions[i] = theTimeGrid.index(times[i]);
discountFactors[i] = discountTS_->discount(times[i]);
}
Matrix earlyExValues_Chg(numAssets,numberOfTimes,Null<Real>());
Array x0(numAssets);
Array drift(numAssets);
Array sigma(numAssets);
const std::vector<Real>& earlyExValues = this->arguments_.earlyExTriggers;
for(Size i=0;i<numAssets;++i){
if(process_->process(i)->x0()<0.00001){
x0[i]=std::log((refIndex[i]->fixing(Settings::instance().evaluationDate()))/initialValues[i]);
underlyingValue_[i]=refIndex[i]->fixing(Settings::instance().evaluationDate());
}else{
x0[i]=std::log((process_->process(i)->x0())/initialValues[i]);
underlyingValue_[i]=process_->process(i)->x0();
}
sigma[i]=process_->process(i)->diffusion(times[0],1.0) ; // 변동성 조정 필요
if(process_->process(i)->drift(times[0],1.0)<0.00001){
drift[i]= discountTS_->zeroRate(times.back(),Compounded,Annual,false) - dividends[i]; //discountTS_->zeroRate(times.back(),Compounded,Annual,false);
}else{
drift[i]= process_->process(i)->drift(times[0],1.0) - dividends[i]; //discountTS_->zeroRate(times.back(),Compounded,Annual,false);
}
//drift 이거 dividend 추가해야함.
for(Size j=0;j<numberOfTimes;++j){
earlyExValues_Chg[i][j]=(std::log(earlyExValues[j])-(drift[i]-0.5*sigma[i]*sigma[i])*times[j]);
}
}
return boost::shared_ptr<ELSNotionalProtectedPricer>(
new ELSNotionalProtectedPricer(times,process_,x0,discountFactors,earlyExValues_Chg,
redemCoupon,pastFixingNum,additionalStats_));
}
示例4: discountFactors
boost::shared_ptr<IRDLSCallablePricer>
MCIRDLSLSEngine::lsmPathPricer() const {
boost::shared_ptr<StochasticProcessArray> processArray =
boost::dynamic_pointer_cast<StochasticProcessArray>(this->process_);
QL_REQUIRE(processArray && processArray->size()>0,
"Stochastic process array required");
boost::shared_ptr<PayoffLeg> payoffLeg = arguments_.payoffLeg;
QL_REQUIRE(payoffLeg, "IRDLS payoffLeg given");
//const Handle<YieldTermStructure> &df=arguments_.df;
//Frequency freq = arguments_.freq;
const TimeGrid theTimeGrid = this->timeGrid();
const std::vector<Time> & times = theTimeGrid.mandatoryTimes();
const Size numberOfTimes = times.size();
const std::vector<Date> & fixings = this->arguments_.fixingDates;
std::vector<Date> remainfixings;
Date today = Settings::instance().evaluationDate();
const Size numberOfFixings = fixings.size();
for(Size i=0;i<numberOfFixings;++i){
if(fixings[i]>today){
remainfixings.push_back(fixings[i]);
}
}
const Size numberOfRemainFixings = remainfixings.size();
additionalStats_.resize(numberOfTimes);
QL_REQUIRE(numberOfRemainFixings == numberOfTimes, "Invalid dates/times");
std::vector<Size> timePositions(numberOfTimes);
Array discountFactors(numberOfTimes);
//std::vector<Handle<YieldTermStructure> > forwardTermStructures(numberOfTimes);
//const Handle<YieldTermStructure> & riskFreeRate = process->riskFreeRate();
for (Size i = 0; i < numberOfTimes; ++i){
timePositions[i] = theTimeGrid.index(times[i]);
discountFactors[i] = discountTS_->discount(times[i]);
}
// forwardTermStructures[i] = Handle<YieldTermStructure>(
// new ImpliedTermStructure(riskFreeRate, fixings[i]));
const Size polynomialOrder = 2;
const LsmBasisSystem::PolynomType polynomType = LsmBasisSystem::Monomial;
return boost::shared_ptr<IRDLSCallablePricer> (
new IRDLSCallablePricer(payoffLeg,
timePositions,
process_,
discountFactors,
additionalStats_,
polynomialOrder,
polynomType));
}