我有一个nbbo表,我希望在一定时间间隔(10秒,30秒,1分钟2分钟,5分钟)之后从整个月的某个特定时间拉出间谍nbbo。我使用以下代码,但它需要一段时间。可以请有人建议我一些替代方法来实现它
dtlist:h"select distinct date from t where strategy=`xxx,date within (2014.05.01,2014.05.30)"
spytab::();
grabspynbbo:{[dt]
tbl:{ distinct h "select date,trade_id,sym:`SPY, linetime:`time$trans_time from t where strategy = `xxx,date = ",string x}[dt];
getData:{[tbl] tempNbbo:select from nbbo where date in tbl`date,sym in `SPY,linetime within(09:30t;16:30t);
t1:select sym,linetime:(linetime+00:00:10t),trade_id from tbl;
t2:select sym,linetime:(linetime+00:00:30t),trade_id from tbl;
t3:select sym,linetime:(linetime+00:01:00t),trade_id from tbl;
t4:select sym,linetime:(linetime+00:02:00t),trade_id from tbl;
t5:select sym,linetime:(linetime+00:05:00t),trade_id from tbl;
t6:select sym,linetime:(linetime+00:10:00t),trade_id from tbl;
t1:`trade_id xkey select trade_id,bbo10s:0.5*(bid+ask) from (aj[`sym`linetime;t1;tempNbbo]);
t2:`trade_id xkey select trade_id,bbo30s:0.5*(bid+ask) from (aj[`sym`linetime;t2;tempNbbo]);
t3:`trade_id xkey select trade_id,bbo1m:0.5*(bid+ask) from (aj[`sym`linetime;t3;tempNbbo]);
t4:`trade_id xkey select trade_id,bbo2m:0.5*(bid+ask) from (aj[`sym`linetime;t4;tempNbbo]);
t5:`trade_id xkey select trade_id,bbo5m:0.5*(bid+ask) from (aj[`sym`linetime;t5;tempNbbo]);
t6:`trade_id xkey select trade_id,bbo10m:0.5*(bid+ask) from (aj[`sym`linetime;t6;tempNbbo]);
(ij/) (t1;t2;t3;t4;t5;t6)
};
h1(getData;tbl)}
spytab::(uj/)grabspynbbo each dtlist`date
我会批准任何帮助。 谢谢, 莫希特
答案 0 :(得分:0)
尝试进行以下两项修改,这应该提高速度(terrylynch也提到):
a)在where子句中使用策略条件之前的日期条件(代码中有2个查询)。
b)在tempNbbo表上使用`g#
和`s#
属性。这将大大加快“aj”。