Expand description
Quant1X Standard Library for Rust
This library provides cross-language compatible utilities for quantitative trading, with implementations in C++, Go, and Rust that maintain API consistency.
§命名空间设计
- Crate名称:
quant1x - 命名空间:
quant1x:: - 使用方式:
use quant1x::Timestamp;
§示例
use quant1x::Timestamp;
let ts = Timestamp::now();
let parsed = Timestamp::parse("2022-06-15 14:30:45").unwrap();Re-exports§
pub use crate::app::*;pub use crate::exchange::*;pub use crate::factors::*;pub use crate::datasets::*;
Modules§
- app
- block_
info - block_
meta - buffer
- commands
- config
- connection_
pool - datasets
- endpoint
- except
- exchange
- factors
- finance_
info - homedir
- learn
- numerics
- operation_
handler - protocol
- runtime
- security_
list - transaction_
data - transaction_
history
Macros§
Structs§
- Binary
Stream - Block
Info Request - Block
Info Response - Block
Meta - Block
Meta Response - Connection
- 池化连接包装器。池拥有连接,并在丢弃时返回连接到池的守卫。
- Endpoint
- Endpoint
Manager - 简单的线程安全端点管理器,类似于 C++ 的 EndpointManager。
- Finance
Info - Finance
Info Request - Finance
Info Response - Heartbeat
Request - Heartbeat
Response - Hello1
Request - Hello1
Response - Hello2
Request - Hello2
Response - Pooled
Connection - RAII 守卫,在丢弃时将连接返回到池。
- Security
Bar - Security
Bars Request - Security
Bars Response - Standard
Protocol Handler - 精简的客户端协议辅助工具, 模拟 C++ 中 StandardProtocolHandler 的握手与保活实现.
- TcpConnection
Pool - 基于 Mio 的 TCP 连接池. 这是 C++ TcpConnectionPool 语义的简化端口: acquire 返回一个连接, 该连接在 Drop 时自动返回.
- Xdxr
Info - Xdxr
Info Request - Xdxr
Info Response
Enums§
Constants§
- BLOCK_
CHUNKS_ SIZE - BLOCK_
DATA - BLOCK_
META - COMPANY_
CATEGORY - COMPANY_
CONTENT - DEFAULT_
DATA_ PROVIDER - FINANCE_
INFO - HEARTBEAT
- HISTORY_
MINUTE_ DATA - HISTORY_
TRANSACTION_ DATA - INDEX_
BARS - LOGIN1
- LOGIN2
- MINUTE_
TIME_ DATA - OLD_
SECURITY_ LIST - PING
- PLUGIN_
MASK_ BASE_ DATA - PLUGIN_
MASK_ FEATURE - PLUGIN_
MASK_ STRATEGY - SECURITY_
BARS - SECURITY_
COUNT - SECURITY_
LIST - SECURITY_
QUOTES_ NEW - SECURITY_
QUOTES_ OLD - TRANSACTION_
DATA - XDXR_
INFO
Traits§
- Data
Adapter - DataAdapter 特征:对应 C++ 中的 DataAdapter(包含 Schema + Update/Print)
- Feature
Adapter - FeatureAdapter 提供文件名和聚合相关的辅助方法
- Network
Operation Handler - 用户应该实现的连接池特征,用于执行协议特定的工作: 握手和保活检查.
- Schema
- 描述插件的 Schema
Functions§
- clone_
feature_ adapter - decode_
line_ bytes - 将原始字节行解码为 UTF-8 Rust String。 启发式方案:先尝试 UTF-8,再尝试 GBK(使用 encoding_rs);选择包含更多汉字的解码结果。
- default_
base_ unit - defaultBaseUnit 等价实现(来自 C++ security_quote.h)
- default_
cache_ path - Public wrapper for default cache path
- default_
home_ path - Public wrapper for default home path
- fetch_
block_ info - Fetch block data for filename and offset from level1 server.
- fetch_
finance_ info - fetch_
xdxr - Fetch XDXR info for a single security code using the level1 client pool. Returns Some(XdxrInfoResponse) on success, None on any error.
- get_
calendar_ filename - Return the filename used for the calendar cache (convenience wrapper around
the internal config helper). This is intentionally a tiny, stable API so
external tests and tools can locate the calendar cache without exposing the
full
configmodule. - get_
data_ adapter - 按 kind 获取插件(精确匹配)
- get_
datetime_ from_ u32 - 对应 C++ helpers::GetDatetimeFromUint32,用于从压缩的日期/分钟编码中恢复年月日时分
- get_
meta_ path - Public wrapper to return the meta directory path (eg. ~/.q1x-rust/meta)
- get_
security_ filename - Public wrapper to return the securities CSV filename under meta
- get_
std_ conn - 获取一个到 level1 服务器的池化连接。
- get_
xdxr_ path - Public wrapper to return the xdxr cache directory
- homedir
- Return the preferred home directory following C++ priority: QUANT1X_HOME, GOX_HOME, HOME (or USERPROFILE on Windows), then fallback to temp dir.
- int_
to_ float64 - 对应 C++ helpers::IntToFloat64,将整数编码解码为浮点价格值
- parse_
frequency - Parse frequency string similar to C++ pandas::ParseTimeRule + parse_frequency Returns (minutes, normalized_freq_string) or Err(message)
- plugins
- 返回与 mask 匹配的所有插件(mask==0 时返回全部)
- plugins_
with_ name - 返回 key 在 keywords 中且匹配 plugin_type mask 的插件
- pool_
max_ connections - 如果全局连接池已初始化,则返回其配置的最大连接数。
- process
- register
- 注册插件;如果已存在则 panic(等同于 ErrAlreadyExists 行为)
- sequence_
id - 对应 C++ 中的
SequenceId(),保持前置自增行为。 - update_
all_ mask - Convenience: pick adapters from registry according to mask and optional keywords and run update.
- update_
with_ adapters - 按顺序更新给定的适配器列表。每个适配器决定其数据如何更新。
Feature 适配器(即
as_feature_clone返回 Some 的适配器)会基于 codes 并行执行, 其结果将被汇总并写入适配器指定的缓存文件(使用适配器提供的 headers/values)。