What you need is to create several of the DayCounter subclasses for different implementations that you need such asActual365CNAnnualActual365CNQuarterlyActual365CNMonthly....And then provide public function to create the above instancesDayCounter& DayCounter::Actual365CN(const Frequency f)------------------------------------------------------------------------------Dear Quantlib,
I'm a Quantlib user from China. I was doing some calculation of yield about fixed coupon bond. As we all know, the day counter is the basis of yield calcutation of Bond.
Quantlib provieds such as ACT/ACT including ISDA, ISMA and ABF, ACT365 and so on. But, I found that these international day count convention is not applicable for China.
The China inter bank day count convention is as folows. The year fraction is t/TS, where t is the actual number of accrued interest days, and TS is the actual number of current period of interest days.
This is different from ISDA, which considering the interest frequency. There are several examples:
1、the issue date is 2009/8/15,maturity date is 2011/8/15,settlement date is 2009/9/15,frequency is annual, the year fraction is 1+(2010/8/15-2009/9/15)/365=1+334/365=1.9151
2、the issue date is 2009/8/15,maturity date is 2012/8/15,settlement date is 2011/9/15,frequency is annual, the year fraction is (2012/8/15-2011/9/15)/366=335/366=0.9153
3、the issue date is 2011/8/15,maturity date is 2012/8/15,settlement date is 2012/1/1,frequency is Quarterly, the year fraction is 0.5+(2012/2/15-2012/1/1)/(2012/2/15-2011/11/15)=0.5+45/92*0.25=0.6223
If I want to calculate the year fraction according to China inter bank day count convention, I must use the additional arguement of interest frequency.
As I know, the all day counter class in Quantlib is inherited from Impl class, but this class only have the vitual yearfraction function as
virtual Time yearFraction(const Date& d1, const Date& d2, const Date& refPeriodStart, const Date& refPeriodEnd) const = 0; It only have arguement about date.
If I want to rewrite the day counter class for China, I must change the interface of Impl, but this will cause that I will change all the day counter class in Quantlib.
Can you give me some suggestions about how to write another day counter class for China condition and have the less change in other class.
I will very appreciate it if you can help me.
Thank you very much!
--Best Regards!Tuo YangBeijing University of Posts and Telecommuncations, BUPTXitucheng Road #10, BeijingTel:(+86) 152-0136-1443E-Mail:[hidden email]------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Free forum by Nabble | Disable Popup Ads | Edit this page |