Calendar Calendar::GetAfterAWeekDay() const { auto AfterAWeekDate = [this](const int AbleToSimpleAddBorderDay) { return this->Day <= AbleToSimpleAddBorderDay ? Calendar(this->Year, this->Month, this->Day + 7) : Calendar(this->Year, Month + 1, this->Day - AbleToSimpleAddBorderDay); }; if (this->Month == 12 && this->Day > 24) return Calendar(this->Year + 1, 1, this->Day - 24); else if (!IsNo31Month(this->Month)) return AfterAWeekDate(24); else if (this->Month != 2) return AfterAWeekDate(23); else return AfterAWeekDate((IsLeapYear(this->Year) ? 22 : 21)); }
// fixed reference date and fixed market data, option dates SwaptionVolatilityMatrix::SwaptionVolatilityMatrix( const Date& today, const std::vector<Date>& optionDates, const std::vector<Period>& swapT, const Matrix& vols, const DayCounter& dc) : SwaptionVolatilityDiscrete(optionDates, swapT, today, Calendar(), Following, dc), volHandles_(vols.rows()), volatilities_(vols.rows(), vols.columns()) { checkInputs(vols.rows(), vols.columns()); // fill dummy handles to allow generic handle-based // computations later on for (Size i=0; i<vols.rows(); ++i) { volHandles_[i].resize(vols.columns()); for (Size j=0; j<vols.columns(); ++j) volHandles_[i][j] = Handle<Quote>(boost::shared_ptr<Quote>(new SimpleQuote(vols[i][j]))); } interpolation_ = BilinearInterpolation(swapLengths_.begin(), swapLengths_.end(), optionTimes_.begin(), optionTimes_.end(), volatilities_); }
FixedRateBond::FixedRateBond(Natural settlementDays, Real faceAmount, const Schedule& schedule, const std::vector<Rate>& coupons, const DayCounter& accrualDayCounter, BusinessDayConvention paymentConvention, Real redemption, const Date& issueDate, const Calendar& paymentCalendar) : Bond(settlementDays, paymentCalendar==Calendar() ? schedule.calendar() : paymentCalendar, issueDate), frequency_(schedule.tenor().frequency()), dayCounter_(accrualDayCounter) { maturityDate_ = schedule.endDate(); cashflows_ = FixedRateLeg(schedule) .withNotionals(faceAmount) .withCouponRates(coupons, accrualDayCounter) .withPaymentCalendar(calendar_) .withPaymentAdjustment(paymentConvention); addRedemptionsToCashflows(std::vector<Real>(1, redemption)); QL_ENSURE(!cashflows().empty(), "bond with no cashflows!"); QL_ENSURE(redemptions_.size() == 1, "multiple redemptions created"); }
FlatHazardRate::FlatHazardRate(const Date& referenceDate, const Handle<Quote>& hazardRate, const DayCounter& dayCounter) : HazardRateStructure(referenceDate, Calendar(), dayCounter), hazardRate_(hazardRate) { registerWith(hazardRate_); }
inline CapletVarianceCurve::CapletVarianceCurve( const Date& referenceDate, const std::vector<Date>& dates, const std::vector<Volatility>& capletVolCurve, const DayCounter& dayCounter) : OptionletVolatilityStructure(referenceDate, Calendar(), Following), blackCurve_(referenceDate, dates, capletVolCurve, dayCounter, false) {}
FixedRateBond::FixedRateBond(Natural settlementDays, const Calendar& calendar, Real faceAmount, const Date& startDate, const Date& maturityDate, const Period& tenor, const std::vector<Rate>& coupons, const DayCounter& accrualDayCounter, BusinessDayConvention accrualConvention, BusinessDayConvention paymentConvention, Real redemption, const Date& issueDate, const Date& stubDate, DateGeneration::Rule rule, bool endOfMonth, const Calendar& paymentCalendar) : Bond(settlementDays, paymentCalendar==Calendar() ? calendar : paymentCalendar, issueDate), frequency_(tenor.frequency()), dayCounter_(accrualDayCounter) { maturityDate_ = maturityDate; Date firstDate, nextToLastDate; switch (rule) { case DateGeneration::Backward: firstDate = Date(); nextToLastDate = stubDate; break; case DateGeneration::Forward: firstDate = stubDate; nextToLastDate = Date(); break; case DateGeneration::Zero: case DateGeneration::ThirdWednesday: case DateGeneration::Twentieth: case DateGeneration::TwentiethIMM: QL_FAIL("stub date (" << stubDate << ") not allowed with " << rule << " DateGeneration::Rule"); default: QL_FAIL("unknown DateGeneration::Rule (" << Integer(rule) << ")"); } Schedule schedule(startDate, maturityDate_, tenor, calendar, accrualConvention, accrualConvention, rule, endOfMonth, firstDate, nextToLastDate); cashflows_ = FixedRateLeg(schedule) .withNotionals(faceAmount) .withCouponRates(coupons, accrualDayCounter) .withPaymentCalendar(calendar_) .withPaymentAdjustment(paymentConvention); addRedemptionsToCashflows(std::vector<Real>(1, redemption)); QL_ENSURE(!cashflows().empty(), "bond with no cashflows!"); QL_ENSURE(redemptions_.size() == 1, "multiple redemptions created"); }
FlatForward::FlatForward(const Date& referenceDate, Rate forward, const DayCounter& dayCounter, Compounding compounding, Frequency frequency) : YieldTermStructure(referenceDate, Calendar(), dayCounter), forward_(ext::shared_ptr<Quote>(new SimpleQuote(forward))), compounding_(compounding), frequency_(frequency) {}
InterpolatedForwardCurve<T>::InterpolatedForwardCurve( const Date& referenceDate, const DayCounter& dayCounter, const std::vector<Handle<Quote> >& jumps, const std::vector<Date>& jumpDates, const T& interpolator) : ForwardRateStructure(referenceDate, Calendar(), dayCounter, jumps, jumpDates), InterpolatedCurve<T>(interpolator) {}
FlatForward::FlatForward(const Date& referenceDate, const Handle<Quote>& forward, const DayCounter& dayCounter, Compounding compounding, Frequency frequency) : YieldTermStructure(referenceDate, Calendar(), dayCounter), forward_(forward), compounding_(compounding), frequency_(frequency) { registerWith(forward_); }
InterpolatedDiscountCurve<T>::InterpolatedDiscountCurve( const std::vector<Date>& dates, const std::vector<DiscountFactor>& discounts, const DayCounter& dayCounter, const T& interpolator) : YieldTermStructure(dates.front(), Calendar(), dayCounter), InterpolatedCurve<T>(std::vector<Time>(), discounts, interpolator), dates_(dates) { initialize(); }
InterpolatedForwardCurve<T>::InterpolatedForwardCurve( const std::vector<Date>& dates, const std::vector<Rate>& forwards, const DayCounter& dayCounter, const T& interpolator) : ForwardRateStructure(dates.at(0), Calendar(), dayCounter), InterpolatedCurve<T>(std::vector<Time>(), forwards, interpolator), dates_(dates) { initialize(); }
InterpolatedDiscountCurve<T>::InterpolatedDiscountCurve( const std::vector<Date>& dates, const std::vector<DiscountFactor>& discounts, const DayCounter& dayCounter, const T& interpolator) //: YieldTermStructure(dates.front(), Calendar(), dayCounter),// Tag :: TS_ReferenceDate_Change : YieldTermStructure(Settings::instance().evaluationDate(), Calendar(), dayCounter), InterpolatedCurve<T>(std::vector<Time>(), discounts, interpolator), dates_(dates) { initialize(); }
CCMSDIntegrator::CCMSDIntegrator(void) : resources((std::vector<IObjectPtr>&) Resource().objects()), cells((std::vector<IObjectPtr>&) Cell().objects()), parts((std::vector<IObjectPtr>&) Part().objects()), processplans((std::vector<IObjectPtr>&) ProcessPlan().objects()), jobs((std::vector<IObjectPtr>&) Job().objects()), distributions((std::vector<IObjectPtr>&) Distribution().objects()), calendars((std::vector<IObjectPtr>&) Calendar().objects()), layouts((std::vector<IObjectPtr>&) Layout().objects()) { }
InterpolatedZeroCurve<T>::InterpolatedZeroCurve( const std::vector<Date>& dates, const std::vector<Rate>& yields, const DayCounter& dayCounter, const T& interpolator, Compounding compounding, Frequency frequency) : ZeroYieldStructure(dates.at(0), Calendar(), dayCounter), InterpolatedCurve<T>(std::vector<Time>(), yields, interpolator), dates_(dates) { initialize(compounding,frequency); }
Calendar Calendar::GetAfterTwoMonthDay() const { if (this->Month == 12) { if (!IsLeapYear(this->Year + 1)) return this->Day >= 28 ? Calendar(this->Year + 1, 2, 28) : Calendar(this->Year + 1, 2, this->Day); else return this->Day >= 29 ? Calendar(this->Year + 1, 2, 29) : Calendar(this->Year + 1, 2, this->Day); } else if (this->Month == 11) return Calendar(this->Year + 1, 1, this->Day); else if (this->Month == 7 && this->Day == 31) return Calendar(this->Year, 9, 30); else return Calendar(this->Year, this->Month + 2, this->Day); }
boost::shared_ptr<GeneralizedBlackScholesProcess> FdmBlackScholesMesher::processHelper(const Handle<Quote>& s0, const Handle<YieldTermStructure>& rTS, const Handle<YieldTermStructure>& qTS, Volatility vol) { return boost::shared_ptr<GeneralizedBlackScholesProcess>( new GeneralizedBlackScholesProcess( s0, qTS, rTS, Handle<BlackVolTermStructure>( boost::shared_ptr<BlackVolTermStructure>( new BlackConstantVol(rTS->referenceDate(), Calendar(), vol, rTS->dayCounter()))))); }
// fixed reference date and fixed market data, option dates SwaptionVolatilityMatrix::SwaptionVolatilityMatrix( const Date& today, const std::vector<Date>& optionDates, const std::vector<Period>& swapT, const Matrix& vols, const DayCounter& dc, const bool flatExtrapolation, const VolatilityType type, const Matrix& shifts) : SwaptionVolatilityDiscrete(optionDates, swapT, today, Calendar(), Following, dc), volHandles_(vols.rows()), shiftValues_(vols.rows()), volatilities_(vols.rows(), vols.columns()), shifts_(shifts.rows(),shifts.columns(),0.0), volatilityType_(type) { checkInputs(vols.rows(), vols.columns(), shifts.rows(), shifts.columns()); // fill dummy handles to allow generic handle-based // computations later on for (Size i=0; i<vols.rows(); ++i) { volHandles_[i].resize(vols.columns()); shiftValues_[i].resize(vols.columns()); for (Size j=0; j<vols.columns(); ++j) { volHandles_[i][j] = Handle<Quote>(boost::shared_ptr<Quote>(new SimpleQuote(vols[i][j]))); shiftValues_[i][j] = shifts.rows() > 0 ? shifts[i][j] : 0.0; } } if (flatExtrapolation) { interpolation_ = FlatExtrapolator2D(boost::make_shared<BilinearInterpolation>( swapLengths_.begin(), swapLengths_.end(), optionTimes_.begin(), optionTimes_.end(), volatilities_)); interpolationShifts_ = FlatExtrapolator2D(boost::make_shared<BilinearInterpolation>( swapLengths_.begin(), swapLengths_.end(), optionTimes_.begin(), optionTimes_.end(), shifts_)); } else { interpolation_ = BilinearInterpolation( swapLengths_.begin(), swapLengths_.end(), optionTimes_.begin(), optionTimes_.end(), volatilities_); interpolationShifts_ = BilinearInterpolation( swapLengths_.begin(), swapLengths_.end(), optionTimes_.begin(), optionTimes_.end(), shifts_); } }
MakeOIS::MakeOIS(const Period& swapTenor, const ext::shared_ptr<OvernightIndex>& overnightIndex, Rate fixedRate, const Period& forwardStart) : swapTenor_(swapTenor), overnightIndex_(overnightIndex), fixedRate_(fixedRate), forwardStart_(forwardStart), settlementDays_(2), calendar_(overnightIndex->fixingCalendar()), paymentFrequency_(Annual), paymentCalendar_(Calendar()), paymentAdjustment_(Following), paymentLag_(0), rule_(DateGeneration::Backward), // any value here for endOfMonth_ would not be actually used isDefaultEOM_(true), type_(OvernightIndexedSwap::Payer), nominal_(1.0), overnightSpread_(0.0), fixedDayCount_(overnightIndex->dayCounter()), telescopicValueDates_(false) {}
floating TSecurity::RealCashflowAmount( const TDate& asettle ) const { floating amount; const TCalendar *cal = Calendar(); if( cal->IsHoliday( asettle ) ) // o svatku nebo vikendu nemuze return 0.0; // zadne cashflow nastat amount = CashflowAmount( asettle ); TDate i(asettle-1); while ( cal->IsHoliday(i) ) { amount += CashflowAmount( i ); i--; } return amount; }
FittedBondDiscountCurve::FittedBondDiscountCurve ( const Date& referenceDate, const vector<shared_ptr<BondHelper> >& bondHelpers, const DayCounter& dayCounter, const FittingMethod& fittingMethod, Real accuracy, Size maxEvaluations, const Array& guess, Real simplexLambda) : YieldTermStructure(referenceDate, Calendar(), dayCounter), accuracy_(accuracy), maxEvaluations_(maxEvaluations), simplexLambda_(simplexLambda), guessSolution_(guess), bondHelpers_(bondHelpers), fittingMethod_(fittingMethod) { fittingMethod_->curve_ = this; setup(); }
boost::shared_ptr<QuantLib::Instrument> qlInstrumentFactory::noteInstrument(const boost::shared_ptr<FpmlSerialized::NoteInfo> xml_serial) { Date tradeDate = xml_serial->getTradeDate()->dateValue(); Date effectiveDate = xml_serial->getEffectiveDate()->dateValue(); Date maturityDate = xml_serial->getMaturityDate()->dateValue(); double notional = xml_serial->getNotional()->DValue(); DayCounter daycounter = DayCounter(); Calendar calendar = Calendar(); boost::shared_ptr<QuantLib::NoteInst> noteinst = boost::shared_ptr<QuantLib::NoteInst>( new NoteInst("test",notional, effectiveDate, maturityDate, daycounter, calendar)); return noteinst; }
FittedBondDiscountCurve::FittedBondDiscountCurve ( const Date& referenceDate, const vector<shared_ptr<FixedRateBondHelper> >& bondHelpers, const DayCounter& dayCounter, const FittingMethod& fittingMethod, Real accuracy, Size maxEvaluations, const Array& guess, Real simplexLambda) : YieldTermStructure(referenceDate, Calendar(), dayCounter), accuracy_(accuracy), maxEvaluations_(maxEvaluations), simplexLambda_(simplexLambda), guessSolution_(guess), bondHelpers_(bondHelpers.size()), fittingMethod_(fittingMethod) { for (Size i=0; i<bondHelpers_.size(); ++i) { bondHelpers_[i] = boost::dynamic_pointer_cast<BondHelper>(bondHelpers[i]); } fittingMethod_->curve_ = this; setup(); }
// fixed reference date and fixed market data, option dates SwaptionVolatilityHullWhite::SwaptionVolatilityHullWhite(const Real reversion, const Handle<YieldTermStructure>& yts, const boost::shared_ptr<SwapIndex> indexBase, const Date& today, const std::vector<Date>& optionDates, const std::vector<Period>& swapT, const Matrix& vols, const DayCounter& dc) : reversion_(reversion),yts_(yts),indexBase_(indexBase),SwaptionVolatilityDiscrete(optionDates, swapT, today, Calendar(), Following, dc), volHandles_(vols.rows()), hwsigmas_(vols.rows(), vols.columns()), volatilities_(vols.rows(), vols.columns()) { checkInputs(vols.rows(), vols.columns()); // fill dummy handles to allow generic handle-based // computations later on for (Size i=0; i<vols.rows(); ++i) { volHandles_[i].resize(vols.columns()); for (Size j=0; j<vols.columns(); ++j) volHandles_[i][j] = Handle<Quote>(boost::shared_ptr<Quote>(new SimpleQuote(vols[i][j]))); } interpolation_ = BilinearInterpolation(swapLengths_.begin(), swapLengths_.end(), optionTimes_.begin(), optionTimes_.end(), volatilities_); interpolationSigma_ = BilinearInterpolation(swapLengths_.begin(), swapLengths_.end(), optionTimes_.begin(), optionTimes_.end(), hwsigmas_); }
void part_four_describe() { bool flag=true; while(flag) { cout<<"******************************************"<<endl; cout<<"* 第四章 ACM程序设计实战 *"<<endl; cout<<"******************************************"<<endl; cout<<"*(1)Quicksum *"<<endl; cout<<"*(2)IBM Minus One *"<<endl; cout<<"*(3)Binary Numbers *"<<endl; cout<<"*(4)Encoding *"<<endl; cout<<"*(5)Look and Say *"<<endl; cout<<"*(6)Abbreviation *"<<endl; cout<<"*(7)The Seven Percent Solution *"<<endl; cout<<"*(8)Digital Roots *"<<endl; cout<<"*(9)Box of Bricks *"<<endl; cout<<"*(10)Geometry Made Simple *"<<endl; cout<<"*(11)Reverse Text *"<<endl; cout<<"*(12)Word Reversal* *"<<endl; cout<<"*(13)A Simple Question of Chemistry *"<<endl; cout<<"*(14)Adding Reversed Numbers *"<<endl; cout<<"*(15)Image Transformation *"<<endl; cout<<"*(16)Beautiful Meadow *"<<endl; cout<<"*(17)DNA Sorting *"<<endl; cout<<"*(18)Daffodil Number *"<<endl; cout<<"*(19)Error Correction *"<<endl; cout<<"*(20)Martian Addition *"<<endl; cout<<"*(21)FatMouse’ Trade *"<<endl; cout<<"*(22)List the Books *"<<endl; cout<<"*(23)Head-to-Head Match *"<<endl; cout<<"*(24)Windows Message Queue *"<<endl; cout<<"*(25)Language of FatMouse *"<<endl; cout<<"*(26)Palindromes *"<<endl; cout<<"*(27)Root of the Problem *"<<endl; cout<<"*(28)Magic Square *"<<endl; cout<<"*(29)Semi-Prime *"<<endl; cout<<"*(30)Beautiful Number *"<<endl; cout<<"*(31)Phone List *"<<endl; cout<<"*(32)Calendar *"<<endl; cout<<"*(33)No Brainer *"<<endl; cout<<"*(34)Quick Change *"<<endl; cout<<"*(35)Total Amount *"<<endl; cout<<"*(36)Electrical Outlets *"<<endl; cout<<"*(37)Speed Limit *"<<endl; cout<<"*(38)Beat the Spread! *"<<endl; cout<<"*(39)Champion of the Swordsmanship *"<<endl; cout<<"*(40)Doubles *"<<endl; cout<<"*(41)File Searching *"<<endl; cout<<"*(42)Old Bill *"<<endl; cout<<"*(43)Divisor Summation *"<<endl; cout<<"*(44)Easier Done Than Said? *"<<endl; cout<<"*(45)Let the Balloon Rise *"<<endl; cout<<"*(46)The Hardest Problem Ever *"<<endl; cout<<"*(47)Fibonacci Again *"<<endl; cout<<"*(48)Excuses, Excuses! *"<<endl; cout<<"*(49)Lowest Bit *"<<endl; cout<<"*(50)Longest Ordered Subsequence *"<<endl; cout<<"******************************************"<<endl; cout<<"请输入对应的编号进入相应的题目(返回上级输入0):"<<endl; int num; cin>>num; while(num<0&&num>50){ cout<<"编号不存在"<<endl; cout<<"请输入对应的编号进入相应的题目(返回上级输入0):"<<endl; cin>>num; } switch(num){ case 0:flag=false;break; case 1:QuickSum();break; case 2:IBMMinusOne();break; case 3:BinaryNumbers();break; case 4:Encoding();break; case 5:LookAndSay();break; case 6:Abbreviation();break; case 7:TheSevenPercentSolution();break; case 8:DigitalRoots();break; case 9:BoxofBricks();break; case 10:GeometryMadeSimple();break; case 11:ReverseText();break; case 12:WordReversal();break; case 13:ASimpleQuestionofChemistry();break; case 14:AddingReversedNumbers();break; case 15:ImageTransformation();break; case 16:BeautifulMeadow();break; case 17:DNASorting();break; case 18:DaffodilNumber();break; case 19:ErrorCorrection();break; case 20:MartianAddition();break; case 21:FatMouseTrade();break; case 22:ListtheBooks();break; case 23:HeadToHeadMatch();break; case 24:WindowsMessageQueue();break; case 25:LanguageofFatMouse();break; case 26:Palindromes();break; case 27:RootoftheProblem();break; case 28:MagicSquare();break; case 29:SemiPrime();break; case 30:BeautifulNumber();break; case 31:PhoneList();break; case 32:Calendar();break; case 33:NoBrainer();break; case 34:QuickChange();break; case 35:TotalAmount();break; case 36:ElectricalOutlets();break; case 37:SpeedLimit();break; case 38:BeattheSpread();break; case 39:ChampionoftheSwordsmanship();break; case 40:Doubles();break; case 41:FileSearching();break; case 42:OldBill();break; case 43:DivisorSummation();break; case 44:EasierDoneThanSaid();break; case 45:LettheBalloonRise();break; case 46:TheHardestProblemEver();break; case 47:FibonacciAgain();break; case 48:ExcusesExcuses();break; case 49:LowestBit();break; case 50:LongestOrderedSubsequence();break; //case 3:part_three_describe();break; //case 4:part_four_describe();break; } } total_describe(); }
FlatHazardRate::FlatHazardRate(const Date& referenceDate, Rate hazardRate, const DayCounter& dayCounter) : HazardRateStructure(referenceDate, Calendar(), dayCounter), hazardRate_(boost::shared_ptr<Quote>(new SimpleQuote(hazardRate))) {}
int checkIncomeDay(int lnumber) { int year; int month; int day; ifstream ifs; string str; char * cstr; char filename[64]; int sum = 0; int sub = 0; cout << "년도를 입력하세요: "; year = keyIO::inputNumList(-1000000000, 1000000000); cout << "월을 입력하세요: "; month = keyIO::inputNumList(1, 12); cout << "일을 입력하세요: "; day = keyIO::inputNumList(1, Calendar::getLastDay(year, month)); sprintf(filename, "data/sales/%d/%.2d%.2d.dat", lnumber, year, month); ifs.open(filename); if(ifs.fail()) { return M_CKINCOME; } while(getline(ifs, str)) { cstr = new char[str.length() + 1]; strcpy(cstr, str.c_str()); Calendar time = Calendar(atoi(strtok(cstr, "|"))); if(time.getDay() == day) { int money = atoi(strtok(NULL, "|")); if(money > 0) sum += money; else sub += money; } else if(time.getDay() > day) { delete [] cstr; break; } delete [] cstr; } ifs.close(); ifs.open(filename); if(ifs.fail()) { return M_CKINCOME; } int stack = 0; while(getline(ifs, str)) { cstr = new char[str.length() + 1]; strcpy(cstr, str.c_str()); Calendar c(atoi(strtok(cstr, "|"))); if(c.getDay() == day) { if(stack == 0) { cout << " ****************************************************************************** " << endl << " 숙 박 업 소 관 리 프 로 그 램 " << endl << " ****************************************************************************** " << endl << " 시간 | 항 목 | 금액 " << endl << " ------------------------------------------------------------------------------ " << endl; } int money = atoi(strtok(NULL, "|")); string s(strtok(NULL, "|")); cout << setw(3) << month << "-" << setw(2) << c.getDay() << " " << setw(2) << c.getHour() << ":" << setw(2) << c.getMin() << " | " << setw(49) << s << " | " << setw(12) << money << endl; stack++; if(stack > 14) { cout << " ------------------------------------------------------------------------------ " << endl << setw(28) << year << "년 " << setw(2) << month << "월 " << setw(2) << day << "일의 총 수익 : " << setw(11) << sum << " | " << endl << " 총 지출 : " << setw(11) << sub << " | " << setw(12) << (sum + sub) << endl << "Insert Any Key for view Next Page"; keyIO::getch(); stack = 0; } } else if(c.getDay() > day) { delete [] cstr; break; } delete [] cstr; } for(int i = stack; i < 15; i++) cout << endl; cout << " ------------------------------------------------------------------------------ " << endl << setw(28) << year << "년 " << setw(2) << month << "월 " << setw(2) << day << "일의 총 수익 : " << setw(11) << sum << " | " << endl << " 총 지출 : " << setw(11) << sub << " | " << setw(12) << (sum + sub) << endl << "Insert Any Key for return Menu"; keyIO::getch(); ifs.close(); return M_CKINCOME; }
int checkBook(const Lodging & lodging) { Room r; RoomList rltemp; RoomList rl = lodging.getRoomList(); int size = rl.getSize(); Calendar cal = Calendar(true); int x = 1; cout << " ****************************************************************************** " << endl << " 숙 박 업 소 관 리 프 로 그 램 " << endl << " ****************************************************************************** " << endl << endl; cout << setw(15) << ""; int m, d; for( int plus = 0; plus < 7 ; plus++) //1주 분량의 날짜 { m = cal.getMonth(); d = cal.getDay(); cout << setw(2) << m << "/" << setw(2) << d << " "; cal.addOneDay(); } cout << endl; cout << "------------------------------------------------------------" <<endl; if(size > 0) { cal = Calendar(true); r = rl.getFirstRoom(); cout << setw(11) << r.getRNumber() << "호| "; for ( int plus = 0 ; plus < 7 ; plus ++) { Room b; int k; fileIO::loadBookLodging(rltemp, r.getLNumber(), cal.getYear(), cal.getMonth(), cal.getDay(), 1); b = rltemp.searchRoom(r.getRNumber()); k = b.getRNumber(); if (k == -1) cout << " O "; else cout << " X "; cal.addOneDay(); } cout << endl; } while ( x < size ) { cal = Calendar(true); r = rl.getNextRoom(); cout << setw(11) << r.getRNumber() << "호| "; for(int plus = 0; plus < 7; plus++) { Room b; int k; fileIO::loadBookLodging(rltemp, r.getLNumber(), cal.getYear(), cal.getMonth(), cal.getDay(), 1); b = rltemp.searchRoom(r.getRNumber()); k = b.getRNumber(); if (k == -1) cout << " O "; else cout << " X "; cal.addOneDay(); } x++; cout << endl; } cal = Calendar(true); x = 1; cout << endl << " 오늘의 예약 | 인원 | 기간 | 연 락 처 | 이 름 " << endl << "------------------------------------------------------------" <<endl; if(size > 0) { r = rl.getFirstRoom(); cout << setw(11) << r.getRNumber() << "호| "; int k; Member m = fileIO::getBookUser(r.getLNumber(), r.getRNumber(), cal.getYear(), cal.getMonth(), cal.getDay()); k = m.getMNumber(); if (k == -1) cout << " 오늘의 예약이 없습니다."; else cout << setw(4) << m.getSPerson() << " | " << setw(4) << m.getSPeriod() << " | " << setw(16) << m.getTelephone() << " | " << m.getName(); cout << endl; } while ( x < size ) { r = rl.getNextRoom(); cout << setw(11) << r.getRNumber() << "호| "; Room b; int k; Member m = fileIO::getBookUser(r.getLNumber(), r.getRNumber(), cal.getYear(), cal.getMonth(), cal.getDay()); k = m.getMNumber(); if (k == -1) cout << " 오늘의 예약이 없습니다."; else cout << setw(4) << m.getSPerson() << " | " << setw(4) << m.getSPeriod() << " | " << setw(16) << m.getTelephone() << " | " << m.getName(); x++; cout << endl; } x = 1; cout << endl << " 오늘의 룸서비스 : "; if(size > 0) { r = rl.getFirstRoom(); if(fileIO::getBookRoomStatus(r.getLNumber(), r.getRNumber(), cal.getYear(), cal.getMonth(), cal.getDay()) == 1) cout << r.getRNumber() << "호, "; } while ( x < size ) { r = rl.getNextRoom(); if(fileIO::getBookRoomStatus(r.getLNumber(), r.getRNumber(), cal.getYear(), cal.getMonth(), cal.getDay()) == 1) cout << r.getRNumber() << "호, "; x++; } cout << endl; keyIO::getch(); return M_MENU; }
//--------------------------------------------------------------------------- void __fastcall TCalendarForm::FormShow( TObject * /*Sender*/ ) { int year = YearEdit->Text.ToIntDef(2000); vhf = Calendar(year); bool loaded = false; if (year > 2009) { loaded = vhf.parseFile( ".\\configuration\\vhfContests10.xml" ); } else if (year == 2009) { loaded = vhf.parseFile( ".\\configuration\\vhfContests09.xml" ); } else { loaded = vhf.parseFile( ".\\configuration\\vhfContests.xml" ); } if ( !loaded ) { ShowMessage( "Failed to load the calendar file" ); CalendarVersionLabel->Caption = "No file loaded"; return ; // don't close - they need a chance to download } CalendarVersionLabel->Caption = ("File Version " + vhf.version).c_str(); CalendarGrid->RowCount = vhf.calendar.size() + 1; CalendarGrid->ColCount = 8; CalendarGrid->ColWidths[ 0 ] = CalendarGrid->Canvas->TextWidth( "144MHz UK Activity Contest and Club ChampionshipXXX" ); CalendarGrid->ColWidths[ 1 ] = CalendarGrid->Canvas->TextWidth( "248GHZZZ" ); CalendarGrid->ColWidths[ 2 ] = CalendarGrid->Canvas->TextWidth( "99/99/9999 99:99XXX" ); CalendarGrid->ColWidths[ 3 ] = CalendarGrid->Canvas->TextWidth( "99/99/9999 99:99XXX" ); CalendarGrid->ColWidths[ 4 ] = CalendarGrid->Canvas->TextWidth( "1PT/QSOXX" ); CalendarGrid->ColWidths[ 5 ] = CalendarGrid->Canvas->TextWidth( "MULTSXX" ); CalendarGrid->ColWidths[ 6 ] = CalendarGrid->Canvas->TextWidth( "3S, 3M, 10S, 10M, XX" ); CalendarGrid->ColWidths[ 7 ] = CalendarGrid->Canvas->TextWidth( "LOW POWER CONTEST" ); CalendarGrid->Cells[ 0 ][ 0 ] = "Contest Name"; CalendarGrid->Cells[ 1 ][ 0 ] = "Band"; CalendarGrid->Cells[ 2 ][ 0 ] = "Start (UTC)"; CalendarGrid->Cells[ 3 ][ 0 ] = "Finish (UTC)"; CalendarGrid->Cells[ 4 ][ 0 ] = "Scoring"; CalendarGrid->Cells[ 5 ][ 0 ] = "Mults"; CalendarGrid->Cells[ 6 ][ 0 ] = "Sections"; CalendarGrid->Cells[ 7 ][ 0 ] = "Special Rules"; int row = 1; int nextContest = 0; TDateTime now = TDateTime::CurrentDateTime(); for ( std::vector<IndividualContest>::iterator i = vhf.calendar.begin(); i != vhf.calendar.end(); i++ ) { if (!description.IsEmpty()) { if (nextContest == 0 && description == (*i).description.c_str()) { nextContest = row; } } else { if (nextContest == 0 && now <= (*i).finish) { nextContest = row; } } CalendarGrid->Cells[ 0 ][ row ] = ( *i ).description.c_str(); CalendarGrid->Cells[ 1 ][ row ] = ( *i ).bands.c_str(); CalendarGrid->Cells[ 2 ][ row ] = ( *i ).start.FormatString( "dd/mm/yyyy hh:mm" ); CalendarGrid->Cells[ 3 ][ row ] = ( *i ).finish.FormatString( "dd/mm/yyyy hh:mm" ); CalendarGrid->Cells[ 4 ][ row ] = ( *i ).ppKmScoring ? "1Pt/Km" : "1Pt/QSO"; CalendarGrid->Cells[ 5 ][ row ] = ( *i ).mults.c_str(); CalendarGrid->Cells[ 6 ][ row ] = ( *i ).sections.c_str(); CalendarGrid->Cells[ 7 ][ row ] = ( *i ).specialRules.c_str(); row++; } if (nextContest) { CalendarGrid->Row = nextContest; } }
/* Generally inflation indices are available with a lag of 1month and then observed with a lag of 2-3 months depending whether they use an interpolated fixing or not. Here, we make the swap use the interpolation of the index to avoid incompatibilities. */ ZeroCouponInflationSwap::ZeroCouponInflationSwap( Type type, Real nominal, const Date& startDate, // start date of contract (only) const Date& maturity, // this is pre-adjustment! const Calendar& fixCalendar, BusinessDayConvention fixConvention, const DayCounter& dayCounter, Rate fixedRate, const boost::shared_ptr<ZeroInflationIndex> &infIndex, const Period& observationLag, bool adjustInfObsDates, Calendar infCalendar, BusinessDayConvention infConvention) : Swap(2), type_(type), nominal_(nominal), fixedRate_(fixedRate), infIndex_(infIndex), observationLag_(observationLag), dayCounter_(dayCounter) { // first check compatibility of index and swap definitions if (infIndex_->interpolated()) { Period pShift(infIndex_->frequency()); QL_REQUIRE(observationLag_ - pShift > infIndex_->availabilityLag(), "inconsistency between swap observation of index " << observationLag_ << " index availability " << infIndex_->availabilityLag() << " interpolated index period " << pShift << " and index availability " << infIndex_->availabilityLag() << " need (obsLag-index period) > availLag"); } else { QL_REQUIRE(infIndex_->availabilityLag() < observationLag_, "index tries to observe inflation fixings that do not yet exist: " << " availability lag " << infIndex_->availabilityLag() << " versus obs lag = " << observationLag_); } if (infCalendar==Calendar()) infCalendar = fixCalendar; if (infConvention==BusinessDayConvention()) infConvention = fixConvention; if (adjustInfObsDates) { baseDate_ = infCalendar.adjust(startDate - observationLag_, infConvention); obsDate_ = infCalendar.adjust(maturity - observationLag_, infConvention); } else { baseDate_ = startDate - observationLag_; obsDate_ = maturity - observationLag_; } Date infPayDate = infCalendar.adjust(maturity, infConvention); Date fixedPayDate = fixCalendar.adjust(maturity, fixConvention); // At this point the index may not be able to forecast // i.e. do not want to force the existence of an inflation // term structure before allowing users to create instruments. Real T = inflationYearFraction(infIndex_->frequency(), infIndex_->interpolated(), dayCounter_, baseDate_, obsDate_); // N.B. the -1.0 is because swaps only exchange growth, not notionals as well Real fixedAmount = nominal * ( std::pow(1.0 + fixedRate, T) - 1.0 ); legs_[0].push_back(boost::shared_ptr<CashFlow>( new SimpleCashFlow(fixedAmount, fixedPayDate))); bool growthOnly = true; legs_[1].push_back(boost::shared_ptr<CashFlow>( new IndexedCashFlow(nominal,infIndex,baseDate_,obsDate_,infPayDate,growthOnly))); for (Size j=0; j<2; ++j) { for (Leg::iterator i = legs_[j].begin(); i!= legs_[j].end(); ++i) registerWith(*i); } switch (type_) { case Payer: payer_[0] = +1.0; payer_[1] = -1.0; break; case Receiver: payer_[0] = -1.0; payer_[1] = +1.0; break; default: QL_FAIL("Unknown zero-inflation-swap type"); } }