取第nextN行的P值用下标索引,取未来nextN行记录中的最大值可以使用dolphindb的eachRight函数和loop函数实现 p = 100..105 nextN = 1 2 3 1 1 1 tb=select * ,p[ nextN + til(p.size())] as nextNp,eachRight(def(x,range)->x.subarray(range).max(), p, loop(pair, 1..p.size(), 1..p.size() + nextN)) as mmaxnextN...
回答于 2022-11-24 17:36
可以通过元编程sqlColAlias实现 sql(sqlColAlias(makeCall(ff,sqlCol(`s)),`a+string(1..60)),table(rand(1.0,10) as s)).eval() a1 a2 a3 a4 a5 a6 ... ----------------- ----------------- ----------------- -----------...
回答于 2022-11-24 11:06
通过tb[`col][2]获取b列的第3行 tb=table(rand(1.,50) as a,rand(2.,50) as b,rand(2.,50) as c) tb[`b][2] print(tb[`b][2])
回答于 2022-11-24 10:51
用replaceColumn把AskPriceBook和AskVolumeBook转化为DOUBLE[] 再append 例 result = table(10:0, `SecurityID`BidPriceBook`AskPriceBook `BidVolumeBook`AskVolumeBook`Time, [SYMBOL,DOUBLE[], DOUBLE[], INT[], INT[], TIME]) SecurityID = string(100000) BidPriceBook = array(DOUBLE[], 0, 20).append!([1.4799 1....
回答于 2022-11-24 10:10
可以使用binaryExpr和unifiedExpr实现以上的功能 n=10 colNames=`wd_nBidPrice+string(1..n) weights=1..n\10 weights_ = array(ANY, size(weights)).fill!(1..size(weights)-1, weights) selects = sqlColAlias(unifiedExpr(binaryExpr(sqlCol(colNames), weights_, *), take(+, size(weights)-1)), "weightedSum"); sql...
回答于 2022-11-15 17:20
可以使用ffill实现前值填充,如下 date=2022.01.01+1..50 factor=1..50*1.0 code =take(`A`B,50) select date,code,factor,ffill(iif(0..(size(date)-1) in (5*(0..(size(date)/5))),factor,NULL)) from table(date,code,factor) context by code date code factor ffill ---------- ---- ------ ----- 2022.01.02...
回答于 2022-11-03 16:39
在dolphindb中可以通过concat函数实现,动态生成字符数组可以通过each实现 concat(each(x->string(x)+`D,1..5),',') 1D,2D,3D,4D,5D
回答于 2022-10-20 09:32
矩阵转化为表时会丢失行标签。先通过join把行标签连接起来,再用unpivot t = table(2022.10.18 2022.10.19 2022.10.20 as Date, `sh600000`sh600002`sh600003 as Code, 1.0 2.0 3.0 as Price) m = exec Price from t pivot by Date, Code t=table(m.rowNames() as date) join table(m) t=t.unpivot(`date, m.colNames(...
回答于 2022-10-19 14:39
用each动态对元代码中的变量赋值 dim=10 T=1000 select_cols=each(def(x,T):sqlColAlias(<sum(class==x)\float(T)>,"L_"+string(x)),0..(dim-1),take(T,dim))
回答于 2022-10-10 17:13
可以通过dolphindb的lj函数实现重置索引。 如果重置的索引标签在原 表 中不存在,那么该标签对应的元素值将全部填充为 NULL。 如原始表如下 tb=table(sort(take(09:30:00+0..6*1200,10)) as time,take(`100000`600000,10) as code,rand(10.,10) as price) 需要按如下的时间对每只code重置索引 total_time=09:30:00+0....
回答于 2022-10-10 10:55