ys_trade_sdk
YS 交易网关 SDK。账号线程、迅投/聚源客户端、行情与静态信息、盈亏缓存、Auth 账号对账都在这个包里。
契约、Auth 客户端和服务骨架仍在 ys_base。网关改动只升本包,不带动 Auth、MS、模板。
uv add ys_trade_sdk
需要服务骨架的交易系统同时安装底座:
uv add "ys_base[server]"
uv add ys_trade_sdk
本目录开发:
uv python install 3.13
uv sync --frozen
uv run pytest
发布到 PyPI
先改 ys_trade_sdk/__init__.py 的 __version__。PyPI 不允许覆盖同版本。Token 用钥匙串项目 pypi:__token__,不要把明文放进仓库。
cd ys_trade_sdk
./publish-pypi.sh
清华镜像能看到该版本后再给消费仓升锁。生产锁文件走清华镜像,禁止 --default-index https://pypi.org/simple。
from ys_trade_sdk import Account, TradeManager, TradeRuntimeConfig
manager = TradeManager(
accounts=[
Account(
account="A001",
password="...",
trade_source="xt",
trade_uri="ws://trade.example.com",
profit_enabled=True,
)
],
runtime_config=TradeRuntimeConfig(
quote_data_base_url="http://quote.example.com",
symbol_data_base_url="http://symbol.example.com",
symbol_data_token="symbol-token",
trade_data_base_url="http://trade-data.example.com",
trade_data_username="trade-user",
trade_data_password="trade-password",
),
)
交易日历由宿主传入(0.1.3 起不再依赖 exchange-calendars、pandas,不按周一到周五猜):
from ys_base.calendar import CalendarService
calendar = CalendarService(lambda: server.store)
calendar.attach(server)
current = None # 启动和日历变化时 current = await calendar.calendar()
TradeRuntimeConfig(..., calendar=lambda: current) # 也可以直接传 ChinaCalendar
启用盈亏的账号没配日历时 TradeManager 启动即报错;计算上一交易日时没有日历抛 TradingCalendarUnavailable,日历缺年份抛 CalendarMissing。
证券连接只认账户快照 stock_td_server。有地址和端口时交易源为迅投,地址为 ws://地址:端口。
profit_enabled=True 时才要求行情、静态信息和交易数据三类地址齐全。
Metadata
Release files for ys_trade_sdk 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ys_trade_sdk-0.1.3.tar.gz | 134.1 kB | Without provenance | Details for ys_trade_sdk-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ys_trade_sdk-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for ys_trade_sdk-0.1.3-py3-none-any.whl |
Total release size: 169.2 kB
Release files / ys_trade_sdk-0.1.3.tar.gz
| Download URL | ys_trade_sdk-0.1.3.tar.gz |
|---|---|
| Size | 134.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1038e8dede2bb2d99aa6c1aaa9fd6f9c1a87685c703176dd5945f6834e934447
|
|
BLAKE2b-256 checksum How to use checksums |
0b948bffea8e4e11619f6fd1a1127e601a7d32bcfe7a27c3a9f703b6cdf8efaa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / ys_trade_sdk-0.1.3-py3-none-any.whl
| Download URL | ys_trade_sdk-0.1.3-py3-none-any.whl |
|---|---|
| Size | 35.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
590acb55974a88c60059c86a1e98ad5ace193d9efc169889480d76e9fb564f94
|
|
BLAKE2b-256 checksum How to use checksums |
c7d501739a4e4aacdbb7e0b76a70910d9267a283bca74b022ef5021a58cbe14f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for ys_trade_sdk 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.