Gurus,Need some help here.How can I get top 10 hourly winners based on volume from tick data . Ican easily calculate like this for the whole day. But i want to applyhourly buckets to this data.10#`totvs xdesc select last price, totvs:sum volume by sym from selectfrom trade where date 09.02.18How can I caluclate top 10 hourly winners based on %age gain as well?Many thanks in advance for all your helpMike
Hello Mike,
The function xbar is probably what you’re looking for.
https://code.kx.com/trac/wiki/Reference/xbar
Regards,
Fintan.
Fintan,Thanks for ur reply. I am aware of xbar and yes i have to use it tobucket data but my question is little bit different, i need to get top10 from each buckets not all.MikeOn Feb 21, 4:41?pm, Fintan Quill <fint…> wrote:> Hello Mike,>> The function xbar is probably what you’re looking for.>> https://code.kx.com/trac/wiki/Reference/xbar>> Regards,>> Fintan.>>>> On Sat, Feb 21, 2009 at 3:04 PM, Mike <ejb…> wrote:>> > Gurus,> > Need some help here.> > How can I get top 10 hourly winners based on volume from tick data . I> > can easily calculate like this for the whole day. But i want to apply> > hourly buckets to this data.>> > 10#`totvs xdesc select last price, totvs:sum volume by sym from select> > from trade where date=2009.02.18>> > How can I caluclate top 10 hourly winners based on %age gain as well?>> > Many thanks in advance for all your help>> > Mike- Hide quoted text ->> - Show quoted text -</ejb…></fint…>
The following works, though I suspect there are better ways to expressit:make some trades:len:600sym:len#20?3time:(len?1000)+len#09:30:00+15*til 1440price:len?100fsize:len?100trade:([]time;sym;price;size)
time xasctrade/ top 3 sizes in each hour:select last price, sum size by sym,hour:time.hh from tradeungroup {3#''x} select sym,price,size by hour from
size xdesc ahour sym price size----------------------9 gmj 91.18408 3559 hno 8.195391 3499 gbo 42.67676 32710 mjc 83.13825 87510 hno 81.77877 83310 bge 17.90757 667…/ top 3 increases in last price in each hour:c:select hour,price,gain:ratios price by sym from ad:`gain xdesc ungroup {1_'‘x}cungroup {3#’'x} select sym,price,gain by hour from dhour sym price gain--------------------------10 jma 32.05186 14.665910 mjc 83.13825 11.9302710 hno 81.77877 9.9786311 gmj 29.4649 28.4963211 dbm 18.90813 12.4624211 aah 93.88087 9.406706…On Feb 23, 9:53?am, Mike <ejb…> wrote:> Fintan,> Thanks for ur reply. I am aware of xbar ?and yes i have to use it to> bucket data but my question is little bit different, i need to get top> 10 from each buckets not all.</ejb…>
Oops, missing assignment in first select statement:a:select last price, sum size by sym,hour:time.hh from tradeOn Feb 23, 12:54?pm, Chris Burke <cdbu…> wrote:> The following works, though I suspect there are better ways to express> it:>> make some trades:>> len:600> sym:len#20?3> time:(len?1000)+len#09:30:00+15*til 1440> price:len?100f> size:len?100> trade:([]time;sym;price;size)>
time xasctrade>> / top 3 sizes in each hour:> select last price, sum size by sym,hour:time.hh from trade> ungroup {3#''x} select sym,price,size by hour from
size xdesc a> hour sym price ? ?size> ----------------------> 9 ? ?gmj 91.18408 355> 9 ? ?hno 8.195391 349> 9 ? ?gbo 42.67676 327> 10 ? mjc 83.13825 875> 10 ? hno 81.77877 833> 10 ? bge 17.90757 667> …>> / top 3 increases in last price in each hour:> c:select hour,price,gain:ratios price by sym from a> d:`gain xdesc ungroup {1_'‘x}c> ungroup {3#’'x} select sym,price,gain by hour from d> hour sym price ? ?gain> --------------------------> 10 ? jma 32.05186 14.6659> 10 ? mjc 83.13825 11.93027> 10 ? hno 81.77877 9.97863> 11 ? gmj 29.4649 ?28.49632> 11 ? dbm 18.90813 12.46242> 11 ? aah 93.88087 9.406706> …>> On Feb 23, 9:53?am, Mike <ejb…> wrote:>> > Fintan,> > Thanks for ur reply. I am aware of xbar ?and yes i have to use it to> > bucket data but my question is little bit different, i need to get top> > 10 from each buckets not all.</ejb…></cdbu…>
Oops, missing assignment in first select statement:a:select last price, sum size by sym,hour:time.hh from tradeOn Feb 23, 12:54?pm, Chris Burke <cdbu…> wrote:> The following works, though I suspect there are better ways to express> it:>> make some trades:>> len:600> sym:len#20?3> time:(len?1000)+len#09:30:00+15*til 1440> price:len?100f> size:len?100> trade:([]time;sym;price;size)>
time xasctrade>> / top 3 sizes in each hour:> select last price, sum size by sym,hour:time.hh from trade> ungroup {3#''x} select sym,price,size by hour from
size xdesc a> hour sym price ? ?size> ----------------------> 9 ? ?gmj 91.18408 355> 9 ? ?hno 8.195391 349> 9 ? ?gbo 42.67676 327> 10 ? mjc 83.13825 875> 10 ? hno 81.77877 833> 10 ? bge 17.90757 667> …>> / top 3 increases in last price in each hour:> c:select hour,price,gain:ratios price by sym from a> d:`gain xdesc ungroup {1_'‘x}c> ungroup {3#’'x} select sym,price,gain by hour from d> hour sym price ? ?gain> --------------------------> 10 ? jma 32.05186 14.6659> 10 ? mjc 83.13825 11.93027> 10 ? hno 81.77877 9.97863> 11 ? gmj 29.4649 ?28.49632> 11 ? dbm 18.90813 12.46242> 11 ? aah 93.88087 9.406706> …>> On Feb 23, 9:53?am, Mike <ejb…> wrote:>> > Fintan,> > Thanks for ur reply. I am aware of xbar ?and yes i have to use it to> > bucket data but my question is little bit different, i need to get top> > 10 from each buckets not all.</ejb…></cdbu…>
use subslist instead of # (take) to correctly handle cases where a name has trader fewer than n times in a bucket.