select Future:last(price) by date, 5 xbar time.minute from idxFutTrade where date within(2011.07.15;2011.08.14),symbol = `IF1108,time>=09:30:00,time<=15:00:00
ssym:`600000
sdate:2011.08.25
tbl:"shTrade"
tmPeriod:60
tradeInitiationSingle:{[ssym;sdate;tbl;tmPeriod]
pref:2#tbl;
quoteMkt:?[("S"$pref)="S"$"sh"; "shTradeQuote"; ?[("S"$pref)="S"$"sz"; "szTradeQuote";"idxFutTrade"]];
.trd: `acumShares xasc `acumShares xkey select time, acumShares:`int$sums share, price,share from "S"$tbl where date=sdate,symbol=ssym;
.qot: `acumShares xasc `acumShares xkey select time, `int$acumShares, acumVolume, buy1, sell1 from "S"$quoteMkt where date=sdate,symbol=ssym;
.tt: `acumShares xasc select time, acumShares, price, buy1, sell1, share, idx:sums ?[null buy1;0;1] from (.trd uj .qot);
.tt1 : select last time, initiation: (sum strength), sum share by idx from select time, strength: (signum((price-(buy1+sell1)%2)))*share,buy1,sell1, price, share, idx from select time, price, fills buy1, fills sell1, share, idx from .tt;
.tt2: select vwap:last price wavg price by tmPeriod xbar time.second from .trd where time >=09:30:00;
.tt3: select time, initiation, share from .tt1 where time>= 09:30:00;
.tt4:select sum(initiation), (sum share), signum( sum(initiation) % sum(share)) by tmPeriod xbar time.second from .tt3;
.tt5: select second, initiation, share, initiation1, vwap, signum( vwap - prev vwap) from ( .tt4 uj .tt2) ;
perc:select (sum abs(vwap1+ prev initiation1))%( 2* count .tt5) from .tt5;
flip `date`sym1`accuracy!( (enlist sdate); (enlist ssym); ( perc[`vwap1]))
};
tradeInitiationDays:{[ssym;sdate;numOfDats;tbl;tmPeriod]
dayList: (neg numOfDats)#(select distinct date from "S"$tbl where date <= sdate)[`date];
uj/ [ tradeInitiationSingle[ssym;;tbl;tmPeriod] peach dayList]
};
tradeInitiationDays[`601288;2011.08.30;10;"shTrade";120]
tradeInitiationSingle[`600010;2011.08.29;"shTrade";120]
`date xdesc raze tradeInitiationDays[;2011.08.26;2;"shTrade";120] each A50
tradeInitiationDays:{[ssym;sdate;numOfDats;tbl;tmPeriod]
dayList: (neg numOfDats)#(select distinct date from "S"$tbl where date <= sdate)[`date];
uj/ [ tradeInitiationSingle[ssym;;tbl;tmPeriod] peach dayList]
};
tradeInitiationDays[`601288;2011.08.30;10;"shTrade";120]
tradeInitiationSingle[`600010;2011.08.29;"shTrade";120]
`date xdesc raze tradeInitiationDays[;2011.08.26;2;"shTrade";120] each A50