问答交流
评论
  • SQL特征里面的内容要严格遵守SQL语法,参考以下代码:
  • SELECT
  • -- 在这里输入因子表达式
  • -- DAI SQL 算子/函数: https://bigquant.com/wiki/doc/dai-PLSbc1SbZX#h-%E5%87%BD%E6%95%B0
  • -- 数据&字段: 数据文档 https://bigquant.com/data/home
  • IF(m_avg(amount, 180) IS NULL, NULL, IF(m_lag(amount/volume, 17.9282) IS NULL, NULL, IF(pct_rank_by(date, amount/volume - m_min(amount/volume, 16.1219)) < pct_rank_by(date, m_corr(amount/volume, m_avg(amount, 180), 17.9282)), 1, 0))) AS _factor_temp,
  • -1 * CAST(_factor_temp AS DOUBLE) AS factor,
  • -- 日期和股票代码
  • date, instrument
  • FROM
  • -- 预计算因子 cn_stock_factors https://bigquant.com/data/datasources/cn_stock_factors
  • cn_stock_bar1d
  • JOIN cn_stock_status USING (date, instrument)
  • WHERE
  • -- WHERE 过滤,在窗口等计算算子之前执行
  • -- 剔除ST股票
  • st_status = 0
  • QUALIFY
  • -- QUALIFY 过滤,在窗口等计算算子之后执行,比如 m_lag(close, 3) AS close_3,对于 close_3 的过滤需要放到这里
  • -- 去掉有空值的行
  • COLUMNS(*) IS NOT NULL
  • -- 按日期和股票代码排序,从小到大
  • ORDER BY date, instrument
  • 老师,运行不了哦,您改过的策略能分享吗
{link}