Crate quant1x

Crate quant1x 

Source
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§

apply_forward_adjustment_for_event

Structs§

BinaryStream
BlockInfoRequest
BlockInfoResponse
BlockMeta
BlockMetaResponse
Connection
池化连接包装器。池拥有连接,并在丢弃时返回连接到池的守卫。
Endpoint
EndpointManager
简单的线程安全端点管理器,类似于 C++ 的 EndpointManager。
FinanceInfo
FinanceInfoRequest
FinanceInfoResponse
HeartbeatRequest
HeartbeatResponse
Hello1Request
Hello1Response
Hello2Request
Hello2Response
PooledConnection
RAII 守卫,在丢弃时将连接返回到池。
SecurityBar
SecurityBarsRequest
SecurityBarsResponse
StandardProtocolHandler
精简的客户端协议辅助工具, 模拟 C++ 中 StandardProtocolHandler 的握手与保活实现.
TcpConnectionPool
基于 Mio 的 TCP 连接池. 这是 C++ TcpConnectionPool 语义的简化端口: acquire 返回一个连接, 该连接在 Drop 时自动返回.
XdxrInfo
XdxrInfoRequest
XdxrInfoResponse

Enums§

DeserializeError
KLineType

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§

DataAdapter
DataAdapter 特征:对应 C++ 中的 DataAdapter(包含 Schema + Update/Print)
FeatureAdapter
FeatureAdapter 提供文件名和聚合相关的辅助方法
NetworkOperationHandler
用户应该实现的连接池特征,用于执行协议特定的工作: 握手和保活检查.
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 config module.
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)。

Type Aliases§

Kind