我正在尝试使用AquaQ的TorQ来填充一个价格和报价数据库。为此,我使用.loader.loadallfiles函数。区别在于,prices是每日数据,而quotes是日内数据,例如外汇利率。
我的装货方式如下:
/- check the location of database directory
hdbdir:hsym `$getenv[`KDBHDB]
/hdbdir:@[value;`hdbdir;`:hdb]
rawdatadir:hsym `$getenv[`KDBRAWDATA]
target:hdbdir;
rawdatadir:hsym `$("" sv (getenv[`KDBRAWDATA]; "prices"));
.loader.loadallfiles[`headers`types`separator`tablename`dbdir`partitioncol`partitiontype`dataprocessfunc!(`date`sym`open`close`low`high`volume;"DSFFFFF";enlist ",";`prices;target;`date;`year;{[p;t] `date`sym`open`close`low`high`volume xcols update volume:"i"$volume from t}); rawdatadir];
rawdatadir:hsym `$("" sv (getenv[`KDBRAWDATA]; "quotes"));
.loader.loadallfiles[`headers`types`separator`tablename`dbdir`partitioncol`partitiontype`dataprocessfunc!(`date`sym`bid`ask;"ZSFF";enlist ",";`quotes;target;`date;`year;{[p;t] `date`sym`bid`ask`mid xcols update mid:(bid+ask)%2.0 from t}); rawdatadir];这个很好用。但是,在加载数据库时,尝试从任何一个表中进行选择都会出现错误。原因是对于某些分区,没有任何prices或或没有任何quotes数据。例如试图:
quotes::`date`sym xkey select from quotes; 如果说年份的分区失败,例如hdb/2000/不存在,这是正确的,2000年只有prices,没有quotes
据我所见,有两种可能的解决方案,但我都不知道如何实现:
.loader.loadallfiles为没有任何数据的分区中的报价和价格创建空模式。select from ... where ignore empty partitions )没有数据的情况发布于 2017-12-14 14:19:32
尝试使用.Q.chk[`:hdb]
其中`:hdb是您的HDB文件
这将填充缺少的表,然后允许您预置查询。
或者,您可以使用.Q.bv,其中wiki声明:
如果您的表存在于最新的分区中(因此有一个模式的原型),那么您可以使用
.Q.bv[]在运行时动态创建空表,而不必在磁盘上创建这些空表。
https://stackoverflow.com/questions/47814538
复制相似问题