ys_base
YS 统一 SDK:契约模型(contracts)、auth 客户端与差量同步(auth)、WebSocket RPC 基类(ws)、 本地存储(store,默认 SQLite)、子系统服务骨架(server,extra)、交易网关(trade,extra,P4 收编)。
pip install ys_base # 契约 + auth 客户端 + SQLite 存储
pip install ys_base[server] # + FastAPI 子系统骨架
pip install ys_base[trade] # + 交易网关(纯策略系统只装这个)
使用 uv 添加依赖:
uv add ys_base # 契约 + auth 客户端 + SQLite 存储
uv add "ys_base[server]" # + FastAPI 子系统骨架
uv add "ys_base[trade]" # + 交易网关(纯策略系统只装这个)
trade extra 提供统一行情查询、健康检查与高可用快照缓存:
from ys_base.trade import (
DefaultSnapshotFields,
SnapshotCache,
check_quote_service_alive,
get_quote_by_symbol_id,
get_quote_by_symbol_ids,
get_statics_by_symbol_ids,
)
quotes = await get_quote_by_symbol_ids({"600000.SH", "300750.SZ"})
names = await get_quote_by_symbol_ids(["600000.SH"], fields="f57,f58")
statics = await get_statics_by_symbol_ids({"600000.SH"})
alive = await check_quote_service_alive()
cache = SnapshotCache(
fetcher=get_quote_by_symbol_ids,
ttl_seconds=30,
stale_ttl_seconds=300,
)
snapshots = await cache.get(slot_key="2026-07-24T09:30:00", symbol_ids={"600000.SH"})
DefaultSnapshotFields == "f43,f58,f60",返回原始 f* 字段,并固定映射
f43 -> close、f60 -> pre_close、f58 -> name。不提供 last_price 或 pre_price 兼容字段;
可通过字符串或字段集合指定其他 fields。SnapshotCache 会合并同一时间片的并发回源,
并在短暂回源失败时使用 stale_ttl_seconds 范围内的最近快照。
刚发布的新版本若已在 PyPI 页面可见,但 uv 仍提示该版本不存在,通常是本地缓存的 PyPI Simple Index 元数据尚未更新。先清理单包缓存并从官方源重试: uv cache clean ys-base:优先清理单包缓存。 uv cache clean:单包清理无效时清理完整缓存。 使用 --default-index https://pypi.org/simple 从官方 PyPI 重新安装。 使用 --refresh 强制刷新解析。
uv cache clean ys-base
uv add "ys_base[trade]" --default-index https://pypi.org/simple --refresh
如果仍无法解析,再清理完整缓存:
uv cache clean
uv add "ys_base[trade]" --default-index https://pypi.org/simple --refresh
设计文档:ys_auth/docs/架构方案.md(v6 终版)、契约初稿.md。
Metadata
Release files for ys_base 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ys_base-0.1.6.tar.gz | 52.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ys_base-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 114.6 kB
Release files / ys_base-0.1.6.tar.gz
| Download URL | ys_base-0.1.6.tar.gz |
|---|---|
| Size | 52.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c3fc7ce5ad1f82f63c729d347bbf3ea3056b53fdda990f7c712aebc95449e33
|
|
BLAKE2b-256 checksum How to use checksums |
3d10f4fc054192fd42350e0721b2a5ac526e2bd4dbaf2d19f7bdf90855350f50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Release files / ys_base-0.1.6-py3-none-any.whl
| Download URL | ys_base-0.1.6-py3-none-any.whl |
|---|---|
| Size | 62.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ff2b74d84ab631add41024ef56d395e75eb397fbec31860693f5691f305e0b79
|
|
BLAKE2b-256 checksum How to use checksums |
a4d6c97fb1a309b86b87f1381b888c8336ebcffafaefa3f19dfaf2900de29702
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|