factor

module
v0.0.0-...-cd5cb31 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: MIT

README

moox-factor

因子管理端(moox-factor-mgr)与计算引擎(moox-factor-engine):因子定义、计算任务、补算,以及按采集周期计算表达式因子并写回 Storage。

设计文档:因子

构建与测试

./scripts/build/build.sh factor-mgr
./scripts/build/build.sh factor-engine
scripts/deploy/deploy-factor-engine.sh --help
go test -count=1 ./modules/factor/...

配置

管理端 config/app.yaml、config/trpc_go.yaml;引擎 config/engine.yaml、config/trpc_go.engine.yaml;因子库在 factors/(YAML 表达式定义),表达式语言在 packages/factorexpr。

FactorMgr 监听 loopback 原生 tRPC 11403,管理端的 FactorEngine 服务监听 11405;控制台与 CLI 经主机网关访问。外置计算引擎以 factor-engine 身份经 Access 访问这两个管理端服务与 Storage,并独立订阅 EventBus。

Directories

Path Synopsis
cmd
cli command
engine command
moox-factor-engine consumes collector period events, computes factors with the factorexpr expression engine and writes results to Storage.
moox-factor-engine consumes collector period events, computes factors with the factorexpr expression engine and writes results to Storage.
mgr command
internal
bootstrap
Package bootstrap loads configuration and wires the moox-factor-mgr process.
Package bootstrap loads configuration and wires the moox-factor-mgr process.
engine
Package engine wires moox-factor-engine: it consumes collector period events, runs the factor expression pipeline and recalc jobs, and talks to moox-factor-mgr only through outbound FactorEngine calls.
Package engine wires moox-factor-engine: it consumes collector period events, runs the factor expression pipeline and recalc jobs, and talks to moox-factor-mgr only through outbound FactorEngine calls.
enginehub
Package enginehub is moox-factor-mgr's side of the compute engine contract: it records which engine process is current, keeps the latest heartbeat, assembles the hashed catalog snapshot and leases recalc jobs to the engine.
Package enginehub is moox-factor-mgr's side of the compute engine contract: it records which engine process is current, keeps the latest heartbeat, assembles the hashed catalog snapshot and leases recalc jobs to the engine.
factorlib
Package factorlib 读取 YAML 因子库:每个 *.yaml 文件是 [{factor_id, name, category_id, category_name, spec}] 列表,一个文件可以包含多个因子。
Package factorlib 读取 YAML 因子库:每个 *.yaml 文件是 [{factor_id, name, category_id, category_name, spec}] 列表,一个文件可以包含多个因子。
factorwire
Package factorwire converts between factor domain types and their protobuf form.
Package factorwire converts between factor domain types and their protobuf form.
gapledger
Package gapledger 是因子引擎的跳过账本:每次因回看窗口空洞、或实时周期里标的还在预热而跳过的 (标的, 周期, 因子) 都追加一行到按月的 JSONL 文件,永不自动删除。
Package gapledger 是因子引擎的跳过账本:每次因回看窗口空洞、或实时周期里标的还在预热而跳过的 (标的, 周期, 因子) 都追加一行到按月的 JSONL 文件,永不自动删除。
localdata
Package localdata 是因子管线的数据层(pipeline.Data 的实现):把本地时序存储、内存窗口与同步器组合起来。
Package localdata 是因子管线的数据层(pipeline.Data 的实现):把本地时序存储、内存窗口与同步器组合起来。
memadmit
Package memadmit 是进程级内存准入(设计 4.4):常驻的窗口与缓存先从预算里扣除,计算、回放、导入、窗口换代 在开始前向它预留内存,预留不到就排队,等不到时拒绝。
Package memadmit 是进程级内存准入(设计 4.4):常驻的窗口与缓存先从预算里扣除,计算、回放、导入、窗口换代 在开始前向它预留内存,预留不到就排队,等不到时拒绝。
periodclock
Package periodclock 提供因子任务的周期计算,以及真实时间与交易序号时间轴之间的换算。
Package periodclock 提供因子任务的周期计算,以及真实时间与交易序号时间轴之间的换算。
preview
Package preview 在管理端试算一个表达式定义(设计 9.4 PreviewFactor):在指定因子任务的源数据上, 对少量标的计算最近若干期。
Package preview 在管理端试算一个表达式定义(设计 9.4 PreviewFactor):在指定因子任务的源数据上, 对少量标的计算最近若干期。
recalcexec
Package recalcexec runs a recalc window in chunks through the factor pipeline.
Package recalcexec runs a recalc window in chunks through the factor pipeline.
rpc
seriesstore
Package seriesstore 是因子机本地的时序存储:Pebble 持久化、按块列式编码,数据永不删除。
Package seriesstore 是因子机本地的时序存储:Pebble 持久化、按块列式编码,数据永不删除。
seriessync
Package seriessync 把 Storage 的近期数据同步到因子机的本地时序存储(设计第 5 节): 每期只拉增量、启动时补停机缺口、按 Storage 的行变更序号跟进修正、断档时由对账重建基线。
Package seriessync 把 Storage 的近期数据同步到因子机的本地时序存储(设计第 5 节): 每期只拉增量、启动时补停机缺口、按 Storage 的行变更序号跟进修正、断档时由对账重建基线。
serieswindow
Package serieswindow 是因子引擎内存里的列式滑动窗口(设计第 4 节):每个数据源一份,按序列(标的 × series_tag) 保存最近 Lookback 根的数值字段,本地数据连续,所以序列的时间轴由起点和步长隐含,不存时间数组,也没有缺行。
Package serieswindow 是因子引擎内存里的列式滑动窗口(设计第 4 节):每个数据源一份,按序列(标的 × series_tag) 保存最近 Lookback 根的数值字段,本地数据连续,所以序列的时间轴由起点和步长隐含,不存时间数组,也没有缺行。
store
Package store persists Factor configuration and asynchronous recalc jobs.
Package store persists Factor configuration and asynchronous recalc jobs.
udfhost
Package udfhost 把 packages/factorudf(wazero 宿主)接到因子表达式引擎:实现 exec.UDFHost,并把模块元数据转换成 factorexpr 的自定义算子解析环境。
Package udfhost 把 packages/factorudf(wazero 宿主)接到因子表达式引擎:实现 exec.UDFHost,并把模块元数据转换成 factorexpr 的自定义算子解析环境。
watermark
Package watermark 保存因子任务的连续水位:committed_through 这一期及之前已经连续算完, 引擎据此逐期推进,不跳过任何还没补到的周期。
Package watermark 保存因子任务的连续水位:committed_through 这一期及之前已经连续算完, 引擎据此逐期推进,不跳过任何还没补到的周期。
proto
factorgen module
Package schema embeds the Factor SQLite schema.
Package schema embeds the Factor SQLite schema.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL