@@ -8,7 +8,6 @@ getBuckets:{[s;e;p](s+p*til(ceiling 1+e%p)-(ceiling s%p))}
88// params[`tn] is table name
99// params[`replayinterval] is the data time interval to bucket the messages into.
1010tableDataToDataStream : {[params ]
11- .dbg.params: params ;
1211 // Sort table by time column.
1312 params [`t ]: params [`tc ] xasc delete date from params [`t ];
1413
@@ -42,7 +41,7 @@ tableDataToDataStream:{[params]
4241 // if there is no interval, cut by distinct time.
4342 ([]
4443 time : distinct t_times ;
45- msg : {(`upd ;x;$ [ 1 < count y; flip y; first y] )}[params [`tn ]] each
44+ msg : {(`upd ;x;y )}[params [`tn ]] each
4645 (where differ t_times ) cut params [`t ]
4746 )
4847 ]
@@ -53,26 +52,35 @@ tableDataToDataStream:{[params]
5352// params[`h] is handle to hdb process
5453// params[`tn] is table name used to query hdb
5554// params[`syms] is list of instruments to get
56- // params[`where] is an additional where clause in functional form - Not Reuqired
55+ // params[`where] is an additional where clause in functional form - Not Required
5756// params[`sts] is start of time window to get
5857// params[`ets] is end of time window to get
5958tableToDataStream : {[params ]
59+ // Have hdb evaluate select statement.
60+ t : @ [params [`h ];
61+ (eval ;tableSelectStatement params );
62+ {.lg.e [`dataloader ;"Failed to evauluate query on hdb: " , x]}
63+ ];
6064
65+ tableDataToDataStream [params , enlist [`t ]! enlist t]
66+ };
67+
68+ // params[`tn] is table name used to query hdb
69+ // params[`syms] is list of instruments to get
70+ // params[`where] is an additional where clause in functional form - Not Required
71+ // params[`sts] is start of time window to get
72+ // params[`ets] is end of time window to get
73+ tableSelectStatement : {[params ]
6174 // Build where clause
6275 wherec : (enlist (within ;`date ;(enlist ;`date $ params [`sts ];`date $ params [`ets ]))) // date in daterange
6376 ,$ [count params [`syms ];enlist (in ;`sym ;enlist params [`syms ]);()] //if syms is empty, omit sym in syms
6477 ,$ [count params [`where ];params [`where ];()] // custom where clause (optional)
6578 , enlist (within ;params [`tc ];(enlist ;params [`sts ];params [`ets ])); // time within (sts;ets)
66-
67- // Have hdb evaluate select statement.
68- t : @ [params [`h ];
69- (eval ;.backtest.query: (? ;params [`tn ];enlist wherec ;0b ;()));
70- {.lg.e [`dataloader ;"Failed to evauluate query on hdb: " , x]}
71- ];
7279
73- tableDataToDataStream [ params , enlist [ `t ] ! enlist t]
80+ ( ? ; params [ `tn ]; enlist wherec ; 0b ;())
7481 };
7582
83+
7684// params[`sts] is start of time window to get
7785// params[`ets] is end of time window to get
7886// params[`tp] is the increment between times
@@ -94,7 +102,7 @@ getTimers:{[params]
94102// prarms[`tc] is the time column of the tables specified - Defualt `time
95103// params[`timerfunc] is the timer function to use in timer messages - Default `.z.ts
96104tablesToDataStream : {[params ]
97- defaults : `timer`h`syms`replayinterval` timerinterval`tc`timerfunc`where ! (0b ;0 ;`symbol $ (); `timespan $ 0n ;`timespan $ 0n ;`time ;`.z.ts ;());
105+ defaults : `timer`h`syms`timerinterval`tc`timerfunc`where ! (0b ;0 ;`symbol $ ();`timespan $ 0n ;`time ;`.z.ts ;());
98106 params : defaults , params ;
99107
100108 // check for default parameters `tabs`sts`ets
0 commit comments