niutrader
同花顺自动化交易系统:用 Python 操作 Windows 上的同花顺下单程序(网上股票交易系统 5.0),实现查询资金持仓、下单、撤单。
由于 easytrader 无法使用,精简了其中功能,只保留了同花顺客户端交易功能。已经修复了其中的错误,验证码识别正常。
快速开始
- 安装同花顺电脑版,打开下单程序并登录资金账户(可以先用模拟炒股账户)。
- 同花顺下单程序设置:
- 交易设置 → 默认交易费率:万一
- 交易设置 → 默认买入价格 / 买入数量 / 卖出价格 / 卖出数量:都设为空
- 界面设置 → 显示悬浮工具栏:否
- Windows 显示缩放:100%、125%、150%、175% 均已实测可用;改了缩放后要重启同花顺下单程序。
- 安装验证码识别工具 tesseract,并添加到系统环境变量 PATH:
- Windows 安装包:https://github.com/UB-Mannheim/tesseract/wiki,或
winget install UB-Mannheim.TesseractOCR
- Windows 安装包:https://github.com/UB-Mannheim/tesseract/wiki,或
- 安装 niutrader:在项目根目录执行
pip install .(开发时用pip install -e .)。 - 测试连接:
from niutrader.niutrader import connect_ths
user = connect_ths(r'C:\同花顺远航版\transaction\xiadan.exe') # 改成你的 xiadan.exe 路径
print(user.balance) # 资金
print(user.position) # 持仓
# 下单:客户端会按代码自动选择市场,前缀 sz / sh 可写可不写
# user.buy(security='000001', price=10.00, amount=100)
同花顺可以最小化或放在其他窗口后面,运行时会自动切到前台;运行期间不要点击鼠标或敲键盘,也不要锁屏。
查资金约 0.5 秒,查持仓/委托约 1.2 秒(含自动识别验证码),限价下单约 4 秒,详见 性能与耗时。
文档
- 使用指南:准备工作、全部接口说明、返回值
- 工作原理:模块结构、控件定位、验证码处理、下单流程
- 常见问题:报错与处理方法
- 性能与耗时:各操作实测耗时、下单耗时拆分、优化方向
- 开发指南:查找控件 ID、测试、发布流程
- AI skill:让 Claude Code、Codex、Cursor 等 AI 助手查询账户、按确认规则交易
- 更新日志
风险提示
本项目通过模拟界面操作下单,可能因客户端版本、界面变化、操作干扰等原因出错。下单前请先在模拟账户中充分测试,实盘使用风险自负。
许可证
Metadata
Release files for niutrader 0.0.22
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 |
|---|---|---|---|---|
| niutrader-0.0.22.tar.gz | 69.8 kB | Without provenance | Details for niutrader-0.0.22.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| niutrader-0.0.22-py3-none-any.whl | Python 3 | none | any | Details for niutrader-0.0.22-py3-none-any.whl |
Total release size: 103.3 kB
Release files / niutrader-0.0.22.tar.gz
| Download URL | niutrader-0.0.22.tar.gz |
|---|---|
| Size | 69.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
809b986de801e581df18c14096d841457f45520d29a3fa7ebfb5b1b3cb08a714
|
|
BLAKE2b-256 checksum How to use checksums |
a95c3a13eebc027fc3fb0d35273b2920ab722b0724dbeda7e373fac81b1e24f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / niutrader-0.0.22-py3-none-any.whl
| Download URL | niutrader-0.0.22-py3-none-any.whl |
|---|---|
| Size | 33.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe978164284f7ed4f6c9086f034246bb8701c58663ce59f02e9248b3db61a25e
|
|
BLAKE2b-256 checksum How to use checksums |
254ae31dc37bceea07e94c6e451cd44d7134da47a8e2791430576cef67cc616b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for niutrader 0.0.22
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.