Saturday, 15 January 2011

how to use multiple arguments in kdb where query? -


I want to select the maximum element from the table within the next 5, 10, 30 minutes etc. I suspect that this is not possible where many elements in the section are both general & lt; and & lt; /: is failing to use my code / query below:

  `Select the maximum value of the date from time & lt; /: (09:05:00; 09:10:00; 09:30:00) `  

Any ideas what I am doing wrong here? The idea is to get the maximum price for the next 5, 10, 30 ... minutes for each line and the maximum price for the maximum prices in the entire table for just 3 maximum prices.

  select the maximum value from the DAT where the time is & lt; /: Time + \ :( 5 10 30)   

This will not work, but should give general thought.

To clarify further, I want to calculate the maximum value at the time of each row of the table from [i] to 5, 10, 30 minutes. So for each table row the maximum value is X + 5, X + 10, X + 30 minutes, where X is the time entry in that row.

You can try something like:

  Select c1: maximum value [where time <09: 05: 00], C2: maximum price [where time & lt; 09: 10: 00], C3: Maximum value from date where time is & lt; 09:30:00   

You can pirate this question, however you like. So if you have a list of times, l: 09: 05: 00 09:10:00 09:15:00 09:20:00 ... to work for it, using the functional form of the above query Can create a function different lengths of L:

  q) f: {[t]? [Dat; Enlist (& lt;; `time; max; t); 0b; ('$' C ', /: `` time, /: t)))))} q   Pre> 

You can use F Work for different tables and more.

No comments:

Post a Comment