Hi,
I’m looking for an efficient way to easily grab the exact timestamps associated with the highs and the lows within a OHLC (open, high, low, close) aggregation via xbar
For example:
select open_timestamp: first time, open:first price, high:max price, low:min price, close:last price, last_timestamp: last time by 0D00:10:00.000000000 xbar time from trade where sym=`XXXXXX, exg=` XXXXXX
As shown above, it’s easy enough to grab the times of the first and the last values (open_timestamp and last_timestamp), but indexing in and getting the timestamp for the max and min values is less straight forward ..
I came up with messy and verbose way to do this, but I’m sure there is a better way to do this .. via search & comparison (?) or similar which is eluding me at the moment.
Any ideas?
Thanks,
Bill
Something like the below might work for your case - A callback function that will be executed for each time slice, and which finds the index of the min/max price within that slice and uses that index to extract the relevant time value.
(I imagine this will be covered in Q Tips by Nick Psaris - I don't have my copy handy)
q)t:([]time:asc n?23:59;price:(n:10000)?100.0)
q)ohlc:{[t;p](t p?a;t p?b;a:min p;b:max p)}
q)select ohlc[time;price] by 10 xbar time.minute from t
--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to personal-kdbplus+unsubscribe@googlegroups.com.
To post to this group, send email to personal-kdbplus@googlegroups.com.
Visit this group at https://groups.google.com/group/personal-kdbplus.
For more options, visit https://groups.google.com/d/optout.
Something like the below might work for your case - A callback function that will be executed for each time slice, and which finds the index of the min/max price within that slice and uses that index to extract the relevant time value.
(I imagine this will be covered in Q Tips by Nick Psaris - I don't have my copy handy)
q)t:([]time:asc n?23:59;price:(n:10000)?100.0)
q)ohlc:{[t;p](t p?a;t p?b;a:min p;b:max p)}
q)select ohlc[time;price] by 10 xbar time.minute from t
On 27 July 2018 at 02:05, William Mayott <wma...@gmail.com> wrote:
Hi,
I’m looking for an efficient way to easily grab the exact timestamps associated with the highs and the lows within a OHLC (open, high, low, close) aggregation via xbar
For example:
select open_timestamp: first time, open:first price, high:max price, low:min price, close:last price, last_timestamp: last time by 0D00:10:00.000000000 xbar time from trade where sym=`XXXXXX, exg=` XXXXXX
As shown above, it’s easy enough to grab the times of the first and the last values (open_timestamp and last_timestamp), but indexing in and getting the timestamp for the max and min values is less straight forward ..
I came up with messy and verbose way to do this, but I’m sure there is a better way to do this .. via search & comparison (?) or similar which is eluding me at the moment.
Any ideas?
Thanks,
Bill
--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to personal-kdbpl...@googlegroups.com.
To post to this group, send email to personal...@googlegroups.com.