如何在DolphinDB中检索每个周期内第N个和倒数第N个交易日的记录?

huangapple go评论100阅读模式
英文:

How to retrieve the records of the Nth and the last Nth trading days within each period in DolphinDB?

问题

如何检索每个周期(如年度、季度或月份)的第N个交易日记录和最后第N个交易日记录?

英文:

How to retrieve the records of the Nth trading day and the last Nth trading day for each period (such as a year, quarter, or month)?

答案1

得分: 1

要检索第N个交易日的记录:

select * , rowNum - first(rowNum) as offset , quarterEnd(end_date) as q from tradingday_rowno(2020.01.01,2021.01.01) context by quarterEnd(end_date) csort end_date

要检索最后第N个交易日的记录:

select * , rowNum - last(rowNum) as offset , quarterEnd(end_date) as q from tradingday_rowno(2020.01.01,2021.01.01) context by quarterEnd(end_date) csort end_date
英文:

To retrieve records of the Nth trading day:

select * , rowNum-first(rowNum)  as  offset ,quarterEnd(end_date) as q from tradingday_rowno(2020.01.01,2021.01.01)  context by quarterEnd(end_date) csort end_date 

To retrieve records of the last Nth trading day:

select * , rowNum-last(rowNum)  as  offset ,quarterEnd(end_date) as q from tradingday_rowno(2020.01.01,2021.01.01)  context by quarterEnd(end_date) csort end_date 

huangapple
  • 本文由 发表于 2023年8月10日 09:55:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76872189.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定