【问题标题】:The factor calculation is very small, how do I use parallel computing to speed it up?因子计算很小,如何使用并行计算加快速度?
【发布时间】:2021-11-08 06:41:51
【问题描述】:

例如,我需要计算 Alpha147 因子。脚本如下所示:

def alpha147SQL(vector) {
    ...
}

input = select tradingdate, symbol, closeprice from loadTable("dfs://xxxx", "level2") where tradingdate = 2020.01.02
alpha147DDBSql = select alpha147SQL(closeprice) from input context by symbol

【问题讨论】:

  • 如果您使用 SQL 来计算繁重的东西,那么您可能不应该这样做。找到使用实际编程语言的方法,例如 C/C++/Java/Python

标签: sql quantitative-finance dolphindb


【解决方案1】:

您可以使用分区内存表来并行执行计算。优化代码如下:

def alpha147SQL(vector) {
    ...
}

input = select tradingdate, symbol, closeprice from loadTable("dfs://shenwan", "level2") where tradingdate = 2020.01.02
db = database("", HASH, [SYMBOL, 20])
pt = db.createPartitionedTable(input, "input", `symbol)
pt.append!(input)
timer(10) { pnodeRun(clearAllCache) }
timer alpha147DDBSql = select alpha147SQL(closeprice) from pt context by symbol

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-18
    • 2012-01-08
    • 1970-01-01
    • 2011-08-31
    • 2011-09-28
    • 2013-07-08
    • 1970-01-01
    相关资源
    最近更新 更多