addMarketHoliday
Syntax
addMarketHoliday(marketName, holiday, [dateType =
'holidayDate'])
Arguments
marketName is a STRING scalar, indicating the identifier of the trading calendar, e.g., the Market Identifier Code of an exchange, or a user-defined calendar name.
holiday is a vector of DATE type, indicating holiday dates or trading dates.
-
When dateType='holidayDate', holiday should be specified as the dates of weekday holidays.
-
When dateType='tradingDate', holiday should be specified as trading dates.
dateType (optional) is a string, indicating the type of the added file from which the trading calendar is generated. It can take one of the following values: 'holidayDate' (default) and 'tradingDate'.
Details
Adds a file of holiday dates or trading dates to generate a trading calendar. A CSV file named marketName will be generated in the directory specified by marketHolidayDir.
Note:
-
It can only be executed by an administrator.
-
It only takes effect on the current node. In a cluster,
pnodeRun
can be used to call this function on all data/compute nodes. -
marketNamemust consist of four uppercase letters and cannot be the same as the file name in marketHolidayDir.
Examples
addMarketHoliday("DCBA",2022.01.03 2022.01.05)
temporalAdd(2022.01.01,1,"DCBA")
//Output: 2022.01.04
index = [2022.01.01, 2022.01.02, 2022.01.03, 2022.01.04]
s = indexedSeries(index, 1..4)
s.resample("DCBA", sum);
label | col1 |
---|---|
2021.12.31 | 6 |
2022.01.04 | 4 |
Create a trading calendar containing trading dates:
tradingDates=[2024.02.08, 2024.02.09, 2024.02.18, 2024.02.19, 2024.02.20, 2024.02.21]
addMarketHoliday(marketName="AAAA", holiday=tradingDates, dateType='tradingDate')
A file named AAAA.csv will be generated in /server/marketHoliday/. In the file is a column named "tradingDate", which contains data from the vector tradingDates.
temporalAdd(2024.02.09, 1, "AAAA")
// Output: 2024.02.18
temporalAdd(2024.02.21, 1, "AAAA")
// Dates not included in AAAA.csv will throw an error: The returned date does not exist in trading calendar [AAAA].
Related functions: updateMarketHoliday, getMarketCalendar, getTradingCalendarType.