Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

dolphindb 中,如何根据一组合约快速取到tick数据?

我有一张表A,是日期和对应的合约名:

TradingDay InstrumentID
2019.11.27 IF1911
2019.11.28 IF1911

现在想根据这张表,取连续的tick数据,tick表是分布式表,结构简化后如下:

TradingDay InstrumentID UpdateTime LastPrice ProductID
2019.11.27 IF1911 2019.11.27T09:48:00.001 0.01 IF

我如果用ej, 那么需要tick全部加载内存然后跟A表关联,

ej(tick, A, 'TradingDay`InstrumentID)

这样ej的左表会很大, 感觉也不是很有效率。这个有什么解决方案吗?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

取连续合约数据,可以对表A中的每一行,分别提交一个query,最后用union合并


def getTickData(dict){
?curDate = dict.TradingDay
?curID = dict.InstrumentID
?curProductID = curID.left(2)
?return select TradingDay, UpdateTime, InstrumentID, LastPrice from loadTable("db", "tick") where TradingDay = curDate, ProductId =curProductID, InstrumentID = curID
}
ploop(getTicketData, A).unionAll(false)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...