Exemplo n.º 1
0
void DepositFileSource::insertRateIntoMap(std::string tenorStr, double liborRate, Market market, map<long, double>* depositRateMap, map<long, double>* overnightRateMap){
	date startDate = dateUtil::dayRollAdjust(dateUtil::getToday(),enums::Following,market.getMarketEnum());	
	char tenorUnit = *tenorStr.rbegin();
	int tenorNum = std::stoi(tenorStr.substr(0,tenorStr.size()-1)); // 2
	if (tenorUnit != 'D')
		startDate = dateUtil::getBizDateOffSet(startDate,market.getBusinessDaysAfterSpot(enums::SWAP),market.getMarketEnum()); // day after spot adjust

	long JDN = dateUtil::getEndDate(startDate,tenorNum, market.getDayRollCashConvention(), market.getMarketEnum(), dateUtil::getDateUnit(tenorUnit)).getJudianDayNumber();
	if (tenorUnit == 'D'){
		overnightRateMap->insert(pair<long, double>(tenorNum, liborRate));
		cout << market.getNameString()<< " -> tenor[" << tenorStr <<"], accrual start["<<startDate.toString()<<"], duration ["
			<<tenorNum <<"], deposit rate["<< liborRate << "]"<<endl;
	}else{
		date accrualEndDate(JDN);
		depositRateMap->insert(pair<long, double>(JDN, liborRate));
		cout << market.getNameString()<< " -> tenor[" << tenorStr<<"], accrual start["<<startDate.toString()<<"], accrual end["
			<<accrualEndDate.toString() <<"], deposit rate["<< liborRate << "]"<<endl;
	}
}
Exemplo n.º 2
0
Swap::Swap(date tradeDate, int tenorNumOfMonths, double notional, double couponRate, DiscountCurve* yc, Market fixLegCurr, Market floatingLegCurr, int paymentFreqFixLeg, int paymentFreqFloatingLeg, bool rollAccuralDates) {
	
	setTradeDate(tradeDate);
	setMaturityDate(dateUtil::getEndDate(tradeDate,tenorNumOfMonths,fixLegCurr.getDayRollSwapConvention(),fixLegCurr.getMarketEnum(),dateUtil::MONTH));

	BuilderCashFlowLeg* fixLegs = new BuilderCashFlowLeg(enums::SWAP,tradeDate, tenorNumOfMonths,couponRate,notional, paymentFreqFixLeg, fixLegCurr.getMarketEnum());
	BuilderCashFlowLeg* floatLegs= new BuilderCashFlowLeg(enums::SWAP,tradeDate, tenorNumOfMonths,yc,notional, paymentFreqFloatingLeg, floatingLegCurr.getMarketEnum());

	_fixCashflowLeg=fixLegs->getCashFlowLeg();
	_floatingCashflowLeg=floatLegs->getCashFlowLeg();
	_yc=yc;
	_fixLegCurr=fixLegCurr;
	_floatingLegCurr=floatingLegCurr;
	_paymentFreqFixLeg=paymentFreqFixLeg;
	_paymentFreqFloatingLeg=paymentFreqFloatingLeg;
	_tenorNumOfMonths=tenorNumOfMonths;	
}
Exemplo n.º 3
0
Swap::Swap(date tradeDate, date maturityDate, int tenorNumOfMonths, double notional, double couponRate, DiscountCurve* yc, Market fixLegCurr, Market floatingLegCurr, int paymentFreqFixLeg, int paymentFreqFloatingLeg, bool rollAccuralDates, int buildDirection) {

	setTradeDate(tradeDate);
	setMaturityDate(maturityDate);

	BuilderCashFlowLeg* fixLegs = new BuilderCashFlowLeg(enums::SWAP, tradeDate, maturityDate, tenorNumOfMonths, couponRate, notional, paymentFreqFixLeg, fixLegCurr.getMarketEnum(), buildDirection);
	BuilderCashFlowLeg* floatLegs = new BuilderCashFlowLeg(enums::SWAP, tradeDate, maturityDate, tenorNumOfMonths, yc ,notional, paymentFreqFloatingLeg, floatingLegCurr.getMarketEnum(), buildDirection);

	_fixCashflowLeg=fixLegs->getCashFlowLeg();
	_floatingCashflowLeg=floatLegs->getCashFlowLeg();
	_yc=yc;
	_fixLegCurr=fixLegCurr;
	_floatingLegCurr=floatingLegCurr;
	_paymentFreqFixLeg=paymentFreqFixLeg;
	_paymentFreqFloatingLeg=paymentFreqFloatingLeg;
}