Skip to content

Commit c4a08f7

Browse files
committed
QPR-12152 added dates python example
1 parent 9d231fe commit c4a08f7

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<CalendarAdjustments>
2+
<Calendar name= "Japan">
3+
<AdditionalHolidays>
4+
<Date>2020-06-01</Date>
5+
</AdditionalHolidays>
6+
<AdditionalBusinessDays>
7+
<Date>2020-05-05</Date>
8+
</AdditionalBusinessDays>
9+
</Calendar>
10+
</CalendarAdjustments>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
import ORE as ore
3+
4+
startDateString = '2020-05-01'
5+
calendarString = 'Japan'
6+
tenorString = '1M'
7+
businessDayConventionString = 'F'
8+
calAdjXml = "Input/caladj.xml"
9+
10+
startDate = ore.parseDate(startDateString)
11+
calendar = ore.parseCalendar(calendarString)
12+
tenor = ore.parsePeriod(tenorString)
13+
bdc = ore.parseBusinessDayConvention(businessDayConventionString)
14+
endOfMonth = False
15+
16+
## ADVANCE DATE -- pre adjustment
17+
endDate = calendar.advance(startDate, tenor, bdc, endOfMonth)
18+
print('---------------------------')
19+
print("advance start date by", tenorString)
20+
print("startDate", startDate.to_date())
21+
print("endDate ", endDate.to_date())
22+
23+
## EXPLORE QL/ORE JAPAN CALENDAR
24+
print('---------------------------')
25+
print('holidays (pre adjustment):')
26+
holidayList = calendar.holidayList(startDate, endDate)
27+
for idx in holidayList:
28+
print(idx.to_date())
29+
30+
## MAKE USE OF CALENDAR ADJUSTMENT
31+
## new holiday : 2020-06-01
32+
## new business day (previously holiday) : 2020-05-05
33+
calAdj = ore.CalendarAdjustmentConfig()
34+
calAdj.fromFile(calAdjXml)
35+
36+
print('---------------------------')
37+
print('holidays (post adjustment):')
38+
holidayList = calendar.holidayList(startDate, endDate)
39+
for idx in holidayList:
40+
print(idx.to_date())
41+
42+
## ADVANCE DATE -- post adjustment
43+
endDate = calendar.advance(startDate, tenor, bdc, endOfMonth)
44+
print('---------------------------')
45+
print("advance start date by", tenorString)
46+
print("startDate", startDate.to_date())
47+
print("endDate ", endDate.to_date())
48+
print('---------------------------')

0 commit comments

Comments
 (0)