SMS metadata engine with Rust runtime core.
Project description
pytrade-sms
证券资产管理元数据存储与检索标准协议
核心定位:
pytrade-sms是一套专为证券资产管理设计的元数据标准化协议。它不仅是金融数据建模的基石,更是构建高性能量化交易系统、行情中心以及极速证券搜索服务的核心组件。
为什么选择 pytrade-sms?
在处理全球证券数据时,开发者常面临代码不统一、行业分类混乱、检索性能低下等痛点。pytrade-sms 通过标准化的实体模型,为你解决以下核心问题:
- 全场景覆盖:从股票(Stock)、ETF、指数(Index)到债券(Bond)与期货(Future),一套协议打通全资产类别。
- 极速搜索能力:内置针对金融终端优化的复合拼音索引设计,支持“边打边出”的毫秒级 Suggest 接口。
- 多维标签架构:利用动态倒排索引思想,轻松实现申万行业、成分股、地域板块及业务标签(如 ST、融资融券)的复杂交集过滤。
- 跨平台兼容性:预置
mapping机制,无缝对接 Wind、Bloomberg、Reuters 等主流金融终端数据标识。
核心架构设计
系统采用三层数据隔离架构,兼顾检索性能与扩展性:
- 核心索引区 (Core Index):
- $O(1)$ 精确匹配:通过
code全局唯一标识。 - 极速搜索:内置
pinyin复合索引(全拼|首字母),完美支持终端拼音模糊搜索。
- $O(1)$ 精确匹配:通过
- 业务标签区 (Business Categories):
- 动态倒排索引:针对行业分类(申万、证监会)、上市状态、成份股等字段设计,支持复杂的组合过滤。
- 多维分层:支持 L1/L2/L3 级行业透视及地域、板块过滤。
- 扩展属性区 (Extended Attributes):
- 泛化存储:存放股本结构、公司画像、特定资产(如 ETF 跟踪指数、债券费率)等非搜索类数值型数据。
- 多源映射 (Mapping):内置不同金融数据终端的代码转换逻辑。
安装方法
数据月更。可自行改动 Query 函数 做查询重排。
每日更新:Tien-Guan
Install from Pypi
pip install -U pytrade-sms
使用示例
from pytrade.sms.public_api import PrivateSMS as SMSMetadataEngine
sms_engine = SMSMetadataEngine()
filters: dict[str, Any] = {"market": markets, "asset_type": "stock", }
if exclude_st:
filters["tags__not"] = "ST"
meta_data = sms_engine.query(filters=filters, limit=-1)
data: dict[str, list[Any]] = {
"market": [obj.market for obj in meta_data],
"symbol": [obj.code[:-3] for obj in meta_data],
}
数据实体定义 (Python @dataclass)
系统核心采用 Python 高性能 dataclass
定义,支持严格的类型校验与不可变性(Frozen)。具体的定义见:engine.py#L35
@dataclass(frozen=True)
class SecurityRecord:
"""证券元数据实体模型"""
# [核心索引]
code: str # 600519.SH
name: str # 贵州茅台
pinyin: str # guizhoumaotai|gzmt
asset_type: str # stock, etf, index, bond...
market: str # SH, SZ, HK, NY...
# [业务标签] - 建议存入倒排索引数据库(如 Elasticsearch / Redis Stack)
categories: dict = {
"sw_l1": "食品饮料",
"listing_status": "L",
"tags": "ST|融资融券|沪股通",
"index_constituents": "000300.CSI|000001.SH"
}
# [扩展属性] - 存储于 Document Store 或列式数据库
attributes: dict = {
"share_capital": {"total_shares": 125619.78},
"mapping": ["Bloomberg: CH", "Reuters: .SS"],
"specific": {"is_convertible": False}
}
⚖️ 开源协议
本项目遵循 Apache-2.0 License 开源协议。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytrade_sms-0.4.1-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: pytrade_sms-0.4.1-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 496.1 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a25eb10c79bffd8e2ba5d3368f6b2e24706ea521fdf789235c8a60a2c25b83ab
|
|
| MD5 |
2c8ddc4819928cf573fddd7f9fd727cc
|
|
| BLAKE2b-256 |
0dc2b6851d0392a8ab38cc3b62ec9990b25e5f57403e9f6e65c9faeafd217150
|
File details
Details for the file pytrade_sms-0.4.1-cp310-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: pytrade_sms-0.4.1-cp310-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 704.7 kB
- Tags: CPython 3.10+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff9241d4c7c343301054e9979ecc14944ea6115c6e1446a51e2f6cc3bb4e4bc9
|
|
| MD5 |
89620c323800ae23f0f216026672f56d
|
|
| BLAKE2b-256 |
2264c6aefae815506e782776a672d7115c5087057aeae6e826fe71d795031abe
|
File details
Details for the file pytrade_sms-0.4.1-cp310-abi3-macosx_11_0_universal2.whl.
File metadata
- Download URL: pytrade_sms-0.4.1-cp310-abi3-macosx_11_0_universal2.whl
- Upload date:
- Size: 519.7 kB
- Tags: CPython 3.10+, macOS 11.0+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02d485735adcfb2534e31552c35a2e1448c424992c59c574bfeb8a0fd44ea93e
|
|
| MD5 |
0905eece07914d5b81bbf8908dbc433a
|
|
| BLAKE2b-256 |
9d7ad39ba1458c09df2b7024047d084f06aea9109e54ddfd983446c85e0f0cd5
|