Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

有没有函数可用于选择一段时间区间里属于交易日的日期

如题.
选择一个时间区间内,属于交易日的那些天


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

DolphinDB中有个函数可以判断某个日期是周几,例如

days=2020.010.01..2020.10.30
days[weekday(days) between 1:5]

上述代码列出了10月周一到周五的所有日期,但周一到周五有可能是节假日,不一定是交易日。这个可以通过手工列举所有假日并从中剔除。

days=2020.10.01..2020.10.30
holiday=[2020.10.01,2020.10.02]
def getTradingDays(days,holiday){
    return days[weekday(days) between 1:5 and not days in holiday ]
}
getTradingDays(days,holiday)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...