Sina Level2 Quote Python API
该软件需要自行购买新浪的level2标准版 (168每月, 998每年)
暂时不支持新浪的level2普及版 (60每月, 298每年) (楼主正在研究中...)
购买地址 http://stock.finance.sina.com.cn/stock/buy.php
标准版网页 http://stock.finance.sina.com.cn/lv2/sh603001.html
普及版网页 http://finance.sina.com.cn/realstock/company/sh603001/l2.shtml
版本要求 Python3.4+
安装
git clone https://github.com/flycandy/sinalv2
cd sinalv2
pip install -r requirements.txt
vim account.example.json # 修改account.example.json 为自己的用户名密码
python sinalv2.py
新浪level2行情接口 说明
Step 1 登陆新浪
登陆脚本参考该页面 Reference https://gist.github.com/mrluanma/3621775
Step 2 请求一个token
请求地址: https://current.sina.com.cn/auth/api/jsonp.php/varxxxl/AuthSign_Service.getSignCode 方法: Get
| 字段 | 说明 |
|---|---|
| query_type | A_hq (A股行情) |
| ip | 当前机器的公网IP |
| list | 请求的查看股票的列表 |
| kick | 设置为1, 否则可能出现取不到token的情况 |
使用token用websocket获取行情
获取token是一个websocket协议
ws://ff.sinajs.cn/wskt?token={token}&list={list}
token必须是使用该{list}得到的token. 不然会报错
token需要定时更新. 每一个websocket只会持续大概3-5分钟. 当websocket disconnect之后, 需要重新请求一个token. 然后再次链接websocket
Metadata
Release files for sinalv2 1.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sinalv2-1.1.5.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sinalv2-1.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.8 kB
Release files / sinalv2-1.1.5.tar.gz
| Download URL | sinalv2-1.1.5.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b8f0f7040648f4011a7629090dad556550b36b59e8cf05836456e81aa918bda7
|
|
BLAKE2b-256 checksum How to use checksums |
5a25fa43a55060b22e1058cf9ef5713610d53db1041fa21c59c3bd8eba98ee1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.2
|
Release files / sinalv2-1.1.5-py3-none-any.whl
| Download URL | sinalv2-1.1.5-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b3e1a8627d4bb1b46bf561568a4ba9e254e84f095c7669259b171d530ed981d6
|
|
BLAKE2b-256 checksum How to use checksums |
8c9e7fff4349fd2bd7ce2de744d7c5e960be4c4921101874f3c0ba81999f3396
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.2
|