Incompatible vector/matrix size

运行例子 ,

==============================================================

defg featureEngine(bidPrice,bidQty,offerPrice,offerQty){

bas = offerPrice[0]\bidPrice[0]-1

wap = (bidPrice[0]*offerQty[0] + offerPrice[0]*bidQty[0])\(bidQty[0]+offerQty[0])

di = (bidQty-offerQty)\(bidQty+offerQty)

bidw=(1.0\(bidPrice-wap))

bidw=bidw\(bidw.rowSum())

offerw=(1.0\(offerPrice-wap))

offerw=offerw\(offerw.rowSum())

press=log((bidQty*bidw).rowSum())-log((offerQty*offerw).rowSum())

rv=std(log(wap)-log(prev(wap)))*sqrt(24*252*size(wap))

return avg(bas),avg(di[0]),avg(di[1]),avg(di[2]),avg(di[3]),avg(di[4]),avg(di[5]),avg(di[6]),avg(di[7]),avg(di[8]),avg(di[9]),avg(press),rv

//SQL for level2 snapshot data processing

result = select

featureEngine(

matrix(BidPrice0,BidPrice1,BidPrice2,BidPrice3,BidPrice4,BidPrice5,BidPrice6,BidPrice7,BidPrice8,BidPrice9),

matrix(BidOrderQty0,BidOrderQty1,BidOrderQty2,BidOrderQty3,BidOrderQty4,BidOrderQty5,BidOrderQty6,BidOrderQty7,BidOrderQty8,BidOrderQty9),

matrix(OfferPrice0,OfferPrice1,OfferPrice2,OfferPrice3,OfferPrice4,OfferPrice5,OfferPrice6,OfferPrice7,OfferPrice8,OfferPrice9),

matrix(OfferOrderQty0,OfferOrderQty1,OfferOrderQty2,OfferOrderQty3,OfferOrderQty4,OfferOrderQty5,OfferOrderQty6,OfferOrderQty7,OfferOrderQty8,OfferOrderQty9)) as `BAS`DI0`DI1`DI2`DI3`DI4`DI5`DI6`DI7`DI8`DI9`Press`RV

======================================

结果报错:

 featureEngine: bidw = 1 \ (bidPrice - wap) => Incompatible vector/matrix size

这应该怎么处理?

请先 登录 后评论

1 个回答

mhxiang

请问你的版本是多少?我这边2.00.7和1.30.19版本没有问题

defg featureEngine(bidPrice,bidQty,offerPrice,offerQty){

bas = offerPrice[0]\bidPrice[0]-1

wap = (bidPrice[0]*offerQty[0] + offerPrice[0]*bidQty[0])\(bidQty[0]+offerQty[0])

di = (bidQty-offerQty)\(bidQty+offerQty)

bidw=(1.0\(bidPrice-wap))

bidw=bidw\(bidw.rowSum())

offerw=(1.0\(offerPrice-wap))

offerw=offerw\(offerw.rowSum())

press=log((bidQty*bidw).rowSum())-log((offerQty*offerw).rowSum())

rv=std(log(wap)-log(prev(wap)))*sqrt(24*252*size(wap))

return avg(bas),avg(di[0]),avg(di[1]),avg(di[2]),avg(di[3]),avg(di[4]),avg(di[5]),avg(di[6]),avg(di[7]),avg(di[8]),avg(di[9]),avg(press),rv
}

//SQL for level2 snapshot data processing
n=100
BidPrice0,BidPrice1,BidPrice2,BidPrice3,BidPrice4,BidPrice5,BidPrice6,BidPrice7,BidPrice8,BidPrice9=rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n)
BidOrderQty0,BidOrderQty1,BidOrderQty2,BidOrderQty3,BidOrderQty4,BidOrderQty5,BidOrderQty6,BidOrderQty7,BidOrderQty8,BidOrderQty9=rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n)
OfferPrice0,OfferPrice1,OfferPrice2,OfferPrice3,OfferPrice4,OfferPrice5,OfferPrice6,OfferPrice7,OfferPrice8,OfferPrice9=rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n)
OfferOrderQty0,OfferOrderQty1,OfferOrderQty2,OfferOrderQty3,OfferOrderQty4,OfferOrderQty5,OfferOrderQty6,OfferOrderQty7,OfferOrderQty8,OfferOrderQty9=rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n),rand(10.,n)
tb=table(BidPrice0,BidPrice1,BidPrice2,BidPrice3,BidPrice4,BidPrice5,BidPrice6,BidPrice7,BidPrice8,BidPrice9, BidOrderQty0,BidOrderQty1,BidOrderQty2,BidOrderQty3,BidOrderQty4,BidOrderQty5,BidOrderQty6,BidOrderQty7,BidOrderQty8,BidOrderQty9,OfferPrice0,OfferPrice1,OfferPrice2,OfferPrice3,OfferPrice4,OfferPrice5,OfferPrice6,OfferPrice7,OfferPrice8,OfferPrice9,OfferOrderQty0,OfferOrderQty1,OfferOrderQty2,OfferOrderQty3,OfferOrderQty4,OfferOrderQty5,OfferOrderQty6,OfferOrderQty7,OfferOrderQty8,OfferOrderQty9)
result = select
featureEngine(

matrix(BidPrice0,BidPrice1,BidPrice2,BidPrice3,BidPrice4,BidPrice5,BidPrice6,BidPrice7,BidPrice8,BidPrice9),

matrix(BidOrderQty0,BidOrderQty1,BidOrderQty2,BidOrderQty3,BidOrderQty4,BidOrderQty5,BidOrderQty6,BidOrderQty7,BidOrderQty8,BidOrderQty9),

matrix(OfferPrice0,OfferPrice1,OfferPrice2,OfferPrice3,OfferPrice4,OfferPrice5,OfferPrice6,OfferPrice7,OfferPrice8,OfferPrice9),

matrix(OfferOrderQty0,OfferOrderQty1,OfferOrderQty2,OfferOrderQty3,OfferOrderQty4,OfferOrderQty5,OfferOrderQty6,OfferOrderQty7,OfferOrderQty8,OfferOrderQty9)) as `BAS`DI0`DI1`DI2`DI3`DI4`DI5`DI6`DI7`DI8`DI9`Press`RV from tb 

attachments-2022-08-FuEkDVmU62f0819da77d7.png

请先 登录 后评论
  • 1 关注
  • 0 收藏,36 浏览
  • yyjsir 提出于 2022-08-04 09:03

相似问题