问答交流

五日收益率算不出来

由yjz_quanter创建,最终由small_q 被浏览 22 用户

%%sql SELECT date, instrument, close, open, close/m_lag(close,1) as cr, (close / LAG(close, 5) OVER (PARTITION BY instrument ORDER BY date))-1 AS change_ratio_5d, PERCENT_RANK() OVER (PARTITION BY date ORDER BY change_ratio_5d ASC) AS percentile_rank_cr5d

FROM cn_stock_bar1d WHERE date = '2023-12-20'

标签

收益率股票开盘价收盘价
评论
  • sql计算是基于你提取出来的数据进行计算的,你只抽了一天的数据,m_lag(close,5)这个5天前的数据自然就是nan,最后算出来的值就是nan
  • undefined
  • undefined
  • 然后这样也算不出来,老师们帮忙看看。
  • undefined
{link}