How do I change MatLab's internal table of holidays (BUS/252)?

4 views (last 30 days)
Hi!
I am working with MatLab's Financial Instruments Toolbox to calculate interest rates for the Brazilian Bond Market (day count basis = BUS/252).
In spite of having the BUS/252 option for the calculations I need, MatLab's default calendar is NYSE based so my results will be wrong if I use this business calendar as it is provided.
I already have a vector of serial date numbers corresponding to all holidays and nontrading days that apply to the Brazilian market but I found no way of changing MatLab´s internal table of holidays.
Can someone please let me know how to change MatLab's internal table of holidays?
Thanks in advance.
Fernando
(*) I found out that there is a http://www.FinancialCalendar.com paying option to create a file holidays.m file. Is this the only way? I already have the data required. Do I have to pay this company to get the same data in another format? http://www.mathworks.com/help/finance/createholidays.html
() Do the changes performed by this new holidays.m file apply to all MatLab's functions?

Accepted Answer

Sean de Wolski
Sean de Wolski on 4 Nov 2013
If you look at the source code for holidays
>> edit holidays.m
You'll see an option for altholidays, this is a file you'll have to write yourself, to return the date numbers of the dates you don't want.
  1 Comment
Selene Chen
Selene Chen on 21 Jun 2022
Hi Sean, can you elaborate on how this is done? do I create a text file altholidays.txt with the additional holidays I want? We use functions like isbusday, busdate in quite a lot places in our process, do I need to define the altholidays every time I use these functions, or all the functions will pick up the altholidays automatically?

Sign in to comment.

More Answers (2)

Luiz Fernando Carnot R de Almeida
Sean,
Thank you very much for your help.
Your solution seems to make most functions in the Financial Toolbox (probably all of them) work the way they should (I tried many of them and got the results I expected).
Unfortunately it doesn't happen to some functions in the Financial Instruments Toolbox .
The IRFunctionCurve.fitSvensson(...) function (the one I am interested in) enters into a loop after changing the "holidays.m" file. It works fine if I keep the original "holidays.m" but something goes wrong after providing a new vector of holidays.
The code presented below is the one I have used for testing purposes.
Settle = repmat(datenum('30-Apr-2013'),[11 1]);
Maturity = [datenum('01-Jul-2013');datenum('01-Oct-2013');datenum('02-Jan-2014');datenum('01-Apr-2014');datenum('01-Jul-2014');datenum('02-Jan-2015');datenum('01-Apr-2015');datenum('01-Jul-2015');datenum('04-Jan-2016');datenum('01-Jul-2016');datenum('02-Jan-2017')];
CleanPrice = [987.931242000000; 968.170142000000; 948.926947000000; 930.765435000000; 912.497244000000; 873.137646000000; 854.284681000000; 835.874924000000; 798.617222000000; 762.796087000000; 727.527400000000];
CouponRate = [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0];
Instruments = [Settle Maturity CleanPrice CouponRate];
dataMovimento = datenum('30-Apr-2013');
SvenssonModel = IRFunctionCurve.fitSvensson('Zero',dataMovimento,Instruments,'Basis', 13, 'InstrumentFace', 1000);|
If you have any further ideas please let me know. Thank you.
Fernando

Luiz Fernando Carnot R de Almeida
Sean,
Everything is working fine now. Your answer solved the problem .
I probably did something wrong on my previous tests.
Thank you again!
Fernando

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!