KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ What is the difference between wj and wj1? Re: What is the difference between wj and wj1?

  • rocuinneagain

    Member
    August 19, 2022 at 12:00 am

    You are seeing the same results as your t2 has an entry for every second

    If we swap til 9 for 2*til 9 we can create gaps and then you can see the differences where wj will bring in prevailing values but wj1 will not.

     

    t1:([]sym:3#`ibm;time:07:01:01 07:01:03 07:01:05;price:100 101 105); 
    a:101 103 103 104 104 107 108 107 108; 
    b:98 99 102 103 103 104 106 106 107; 
    t2:([]sym:`ibm; time:07:00:58+2*til 9; ask:a; bid:b); 
    c:`sym`time; w:-2 1+:t1.time; 
    o1:wj[w;c;t1;(t2;(max;`ask);(min;`bid))]; 
    o2:wj1[w;c;t1;(t2;(max;`ask);(min;`bid))]; 
    o1~o2; 
    // 0b; 
    
    q)wj[w;c;t1;(t2;(::;`ask);(::;`bid))] 
    sym time price ask bid 
    ------------------------------------------ 
    ibm 07:01:01 100 101 103 103 98 99 102 
    ibm 07:01:03 101 103 103 104 99 102 103 
    ibm 07:01:05 105 103 104 104 102 103 103 
    
    q)wj1[w;c;t1;(t2;(::;`ask);(::;`bid))] 
    sym time price ask bid 
    ---------------------------------- 
    ibm 07:01:01 100 103 103 99 102 
    ibm 07:01:03 101 103 104 102 103 
    ibm 07:01:05 105 104 104 103 103