So I am running the following query without problems:
print(self.data_source.connections['history'].sync(
'{[x;y;z]select from trade where date within(x;y), sym in z}',
numpy.datetime64('2014-04-14', 'D'),
numpy.datetime64('2017-08-14', 'D'),
NumpyUtil.parse_symbols(['instr81', 'instr61', 'instr26'])
))
Here the self.data_source.connections[]
is just a dictionary with the tickerplant, hdb and rdb connections and the NumpyUtil.parse_symbols()
is a little method that parses the argument to the correct Numpy type (has been successfully tested).
The result it produces is the following and is as suspected:
[ ('2017-07-20', b'instr26', 31538122, b'instr14', 93.87083689, 77.0477359 , 81)
('2017-07-20', b'instr26', 31543119, b'instr72', 27.69372507, 80.00145357, 8)
('2017-07-20', b'instr26', 31678121, b'instr56', 58.24375362, 13.93626591, 36)
...,
('2017-07-26', b'instr81', 55344040, b'instr95', 18.75910878, 63.28561637, 98)
('2017-07-26', b'instr81', 81898858, b'instr78', 34.76710694, 8.32085477, 69)
('2017-07-26', b'instr81', 81938857, b'instr97', 64.54823106, 0.16524401, 81)]
Perfect :)
My problem arises when I put it into this wrapper method:
def synced_query(self, database, query, parameters):
print(self.connections[database].sync(query, parameters))
When passing the exact same parameters, it returns something else, a QProjection:
QProjection(QLambda('{[x;y;z]select from trade where date within(x;y),sym in z}'), [numpy.datetime64('2012-06-20'), numpy.datetime64('2017-07-30'), QList([b'instr81', b'instr61', b'instr26'],
dtype='|S7')])
Now I've looked through my code (the data is passed around through some functions before ending up in the synced_query()
method) but I believe the data is parsed and passed correctly.
When I look at the docs the q.sync()
method should only return a message returned from kdb and otherwise raise an exception.
So I'm basicly wondering why kdb is giving me such a strange answer. Any ideas? :)