Zinvest-trade-api-python
zinvest-trade-api-python 尊嘉证券行情API,用户可以订阅港股、美股实时行情,包含买卖10档盘口与最新价。说明文档:(https://www.zvsts.com/api).
同时尊嘉证券提供免费实时的RESTful交易API。编程语言不限于Python/JS/JAVA/C++/Go等。说明文档:(https://www.zvsts.com/api).
安装
Python 环境:python>=3.6 and python <= 3.9
从pip库一键安装:
pip install zinvest-trade-api
下载源代码安装
一键安装以下依赖包:pip install -r requirements.txt
python-dateutil==2.8.1
msgpack==1.0.2
websockets==8.0
下载zinvest-trade-api-python代码后,进入根目录运行steam_example.py可以查看订阅结果。
python ./stream_example.py
如果自定义开发客户端订阅,把zinvest_trade_api目录引入工程里,可以自行开发。
API Keys
应用市场搜索下载'尊嘉金融'APP,注册登录获取实时行情订阅权限。
| Environment | default | Description |
|---|---|---|
| ZVST_API_KEY_ID=<key_id> | 尊嘉金融APP用户名 | |
| ZVST_API_SECRET_KEY=<secret_key> | 尊嘉金融APP登录密码 |
服务
- 数据:
怎样订阅实时港股、美股行情
实时行情包含如下类型:
- Quotes (https://www.zvsts.com/api)
- Snapshots (https://www.zvsts.com/api)
实时订阅行情参考:'stream_example.py'
import logging
from zinvest_trade_api.stream import Stream
log = logging.getLogger(__name__)
async def print_quote(q):
print('quote', q)
async def print_snapshots(s):
print('snapshots', s)
def main():
logging.basicConfig(level=logging.INFO)
stream = Stream(key_id='test', secret_key='test')
stream.subscribe_quotes(print_quote, 'HKEX_00700', 'HKEX_03690')
stream.subscribe_snapshots(print_snapshots, 'HKEX_00700')
stream.run()
if __name__ == "__main__":
main()
更多示例可以参考example目录:
- 停止和恢复websocket连接。
- 动态订阅或取消订阅某些股票。
Metadata
Release files for zinvest-trade-api 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| zinvest-trade-api-0.0.4.tar.gz | 7.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zinvest_trade_api-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.4 kB
Release files / zinvest-trade-api-0.0.4.tar.gz
| Download URL | zinvest-trade-api-0.0.4.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6cec45650dfc6ebebb81917efb6f6c6bf025a40e0cd0a1bdd92995a91866e46a
|
|
BLAKE2b-256 checksum How to use checksums |
b9443d6cf1e0ec8cddb48deb160dd021070de80f2e97a82bac8a90aaeca69e01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/3.7.3 pkginfo/1.4.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.7.2
|
Release files / zinvest_trade_api-0.0.4-py3-none-any.whl
| Download URL | zinvest_trade_api-0.0.4-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec8d6e153deda3109da85e3270017c29dda0d93cf1945a75ca4921ec3700d1a5
|
|
BLAKE2b-256 checksum How to use checksums |
da4389b86783703ed8964a2d559b9baa93bfca123845876d14aca70a87c6e85a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/3.7.3 pkginfo/1.4.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.7.2
|