Reference/wj

From Kx Wiki
(Difference between revisions)
Jump to: navigation, search
(created, based on arthur's list msg)
 
Line 1: Line 1:
 
= wj =
 
= wj =
  
window join is a generalization of asof join.
+
window join is a generalization of asof join, and is available in KDB+ 2.6 and later.
 
asof join takes a snapshot of current state.
 
asof join takes a snapshot of current state.
 
window join aggregates all values of specified columns within an interval.
 
window join aggregates all values of specified columns within an interval.

Revision as of 20:16, 6 July 2009

wj

window join is a generalization of asof join, and is available in KDB+ 2.6 and later. asof join takes a snapshot of current state. window join aggregates all values of specified columns within an interval.

e.g. regnms

/ i have taq 2003.09.10(5.6M trades and 35M quotes) on my laptop
d:`:/taq/2003.09.10

x:select sym,time,price from d`trade

q:select sym,time,bid,ask from d`quote

f:`sym`time

/ 264,000 trades outside (bid;ask)

\t a:select from aj[f;x;q]where not price within(bid;ask)

/ 4 seconds to process 5.6M trades against 35M quotes

w:-3000 1000 / look at quotes from 3 seconds before to 1 second after

\t b:select from wj[w;f;x;(q;(max;`ask);(min;`bid))]where not price within(bid;ask)

/ 28 seconds to do all the windows.  max ask and min bid within each window

\t c:select from wj[w;f;a;(q;(max;`ask);(min;`bid))]where not price within(bid;ask)

/ same result in 1.4seconds by using initial aj snapshot

now 37,000 violations instead of 264,000

See also


For a complete list of functions, see the kdb+ Function Reference.

Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox