我正在試圖找出使用交易數據填充給定交易量的價格變動的平均值,媒體和百分比範圍。附上下面的代碼。問題是,當我在〜80K記錄上運行代碼時,代碼給了我一個wsfull錯誤。我正在使用一個4G的Linux機器。目前,我只能運行它約30k記錄,即使如此,q使用我的內存> 70%。 有什麼辦法可以讓它更加記憶友好嗎?如何使音量範圍計算更友善?
rangeForVol : {[symIn; vol; dt]
data: select from table where sym=symIn, date=dt;
data: update cumVol: sums quantity, cVol: sums quantity from data;
data: update cumVolTgt: cumVol + vol from data;
data: update pxLst: price[where each ((cumVol>=/:cVol) and (cumVol<=/:cumVolTgt))=1] from data;
.Q.gc[];
data: update minPx: min each pxLst, maxPx: max each pxLst from data;
data: update range: maxPx - minPx from data;
data
};
select count i by floor range%0.5 from rangeForVol[`ABC; 2500; 2012.06.04]