mytt 的 REF 使用报错

请教一个有关mytt的REF(x,y)的问题, 当是一个确定的数据时, 不会报错, 但当是一个变量时报错. 比如当我回看涨停数据时 , 用BARSLAST(pct_change>9.95) as 涨停距, 代码和结果如下(此时正常):

t0 = select *,BARSLAST(pct_change>9.95)as 涨停距 from loadTable("dfs://股票库","日线") where trade_date>=2023.08.01 and ts_code='000004.SZ'  当我用REF(open,涨停距)取那天的open时报错:
qxw-pc:8846 Server response: 'BSLST = select ts_code,trade_date,open,high,low,close,pct_change,mytt::REF(open, 涨停距) as zt_open from t0 => mytt::REF: return ::move(S, N) => A scalar object is expected. But the actual object is a vector.'

请先 登录 后评论

1 个回答

Polly

DolphinDB 的 REF 是通过 move 函数实现的,入参 N 是一个标量,返回值是一个移动后的序列,此处涨停距是一个字段,即是向量。可以用 select *, open[til(count open)-涨停距] as open2 from T 替代 REF 实现您想要的结果。


请先 登录 后评论
  • 1 关注
  • 0 收藏,429 浏览
  • veryOrdinary 提出于 2023-10-26 11:54

相似问题