英文:
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 
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论