Date Generator in Trading
Generally speaking, the fomular in all the markets, including FX, Interest and Commodity&Equity&Credit would be the same as follows,
Date = Correspoding Exchange's Financial Calendar + Market Convention (eg., Spot Convention, Business Day Convention, etc)
Although there are many subtle differences between different markets, this is a general rule.
def is_biz_day(date): # get the data from the stock's corresponding exchange, eg., # [HKEX Financial Calendar](https://www.hkex.com.hk/News/HKEX-Calendar?sc_lang=en) # `curl -L https://www.hkex.com.hk/News/HKEX-Calendar?sc_lang=en` pass def settlement_date(t_date): # HKEX: # Spot Date - T+0 # Settlement Date - T+2 if is_biz_day(t_date + 0 + 2): return t_date + 2 else: return settlement_date(t_date + 1)