Question about year fraction calculation of China inter-bank bond

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about year fraction calculation of China inter-bank bond

杨拓

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:

1the issue date is 2009/8/15maturity date is 2011/8/15settlement date is 2009/9/15frequency is annual, the year fraction is  1+2010/8/15-2009/9/15/365=1+334/365=1.9151

2the issue date is 2009/8/15maturity date is 2012/8/15settlement date is 2011/9/15frequency is annual, the year fraction is 2012/8/15-2011/9/15/366=335/366=0.9153

3the issue date is 2011/8/15maturity date is 2012/8/15settlement date is 2012/1/1frequency 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 Yang
Beijing University of Posts and Telecommuncations, BUPT
Xitucheng Road #10, Beijing
Tel:(+86) 152-0136-1443

------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|

Re: Question about year fraction calculation of China inter-bank bond

CK TUNG
What you need is to create several of the DayCounter subclasses  for different implementations that you need such as
Actual365CNAnnual
Actual365CNQuarterly
Actual365CNMonthly
....

And then provide public function to create the above instances
DayCounter& DayCounter::Actual365CN(const Frequency f)


杨拓 <[hidden email]> :

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:

1the issue date is 2009/8/15maturity date is 2011/8/15settlement date is 2009/9/15frequency is annual, the year fraction is  1+2010/8/15-2009/9/15/365=1+334/365=1.9151

2the issue date is 2009/8/15maturity date is 2012/8/15settlement date is 2011/9/15frequency is annual, the year fraction is 2012/8/15-2011/9/15/366=335/366=0.9153

3the issue date is 2011/8/15maturity date is 2012/8/15settlement date is 2012/1/1frequency 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 Yang
Beijing University of Posts and Telecommuncations, BUPT
Xitucheng Road #10, Beijing
Tel:(+86) 152-0136-1443
------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|

Re: Question about year fraction calculation of China inter-bank bond

Luigi Ballabio
That's a possibility. Or you can create one class that takes the frequency as a constructor parameter.



On Fri, Jul 22, 2016 at 12:31 PM CK TUNG <[hidden email]> wrote:
What you need is to create several of the DayCounter subclasses  for different implementations that you need such as
Actual365CNAnnual
Actual365CNQuarterly
Actual365CNMonthly
....

And then provide public function to create the above instances
DayCounter& DayCounter::Actual365CN(const Frequency f)


杨拓 <[hidden email]> :

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:

1the issue date is 2009/8/15maturity date is 2011/8/15settlement date is 2009/9/15frequency is annual, the year fraction is  1+2010/8/15-2009/9/15/365=1+334/365=1.9151

2the issue date is 2009/8/15maturity date is 2012/8/15settlement date is 2011/9/15frequency is annual, the year fraction is 2012/8/15-2011/9/15/366=335/366=0.9153

3the issue date is 2011/8/15maturity date is 2012/8/15settlement date is 2012/1/1frequency 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 Yang
Beijing University of Posts and Telecommuncations, BUPT
Xitucheng Road #10, Beijing
Tel:(+86) 152-0136-1443
------------------------------------------------------------------------------
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

------------------------------------------------------------------------------
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