sinalv2


Namesinalv2 JSON
Version 1.1.5 PyPI version JSON
download
home_pagehttps://github.com/yanjlee/sinalv2
Summary该软件需要自行购买新浪的level2标准版.
upload_time2024-06-01 08:25:03
maintainerNone
docs_urlNone
authoryanjlee
requires_pythonNone
licenseNone
keywords
VCS
bugtrack_url
requirements autobahn rsa requests
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/yanjlee/sinalv2",
    "name": "sinalv2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "yanjlee",
    "author_email": "yanjlee@163.com",
    "download_url": "https://files.pythonhosted.org/packages/5a/25/fa43a55060b22e1058cf9ef5713610d53db1041fa21c59c3bd8eba98ee1b/sinalv2-1.1.5.tar.gz",
    "platform": null,
    "description": "# Sina Level2 Quote Python API\r\n\u8be5\u8f6f\u4ef6\u9700\u8981\u81ea\u884c\u8d2d\u4e70\u65b0\u6d6a\u7684level2\u6807\u51c6\u7248 (168\u6bcf\u6708, 998\u6bcf\u5e74)\r\n\r\n\u6682\u65f6\u4e0d\u652f\u6301\u65b0\u6d6a\u7684level2\u666e\u53ca\u7248 (60\u6bcf\u6708, 298\u6bcf\u5e74) (\u697c\u4e3b\u6b63\u5728\u7814\u7a76\u4e2d...)\r\n\r\n\u8d2d\u4e70\u5730\u5740 http://stock.finance.sina.com.cn/stock/buy.php\r\n\r\n\u6807\u51c6\u7248\u7f51\u9875 http://stock.finance.sina.com.cn/lv2/sh603001.html\r\n\r\n\u666e\u53ca\u7248\u7f51\u9875 http://finance.sina.com.cn/realstock/company/sh603001/l2.shtml\r\n\r\n\u7248\u672c\u8981\u6c42 Python3.4+\r\n\r\n# \u5b89\u88c5\r\n```\r\ngit clone https://github.com/flycandy/sinalv2\r\ncd sinalv2\r\npip install -r requirements.txt\r\nvim account.example.json # \u4fee\u6539account.example.json \u4e3a\u81ea\u5df1\u7684\u7528\u6237\u540d\u5bc6\u7801\r\npython sinalv2.py\r\n```\r\n\r\n\r\n\r\n# \u65b0\u6d6alevel2\u884c\u60c5\u63a5\u53e3 \u8bf4\u660e\r\n\r\n## Step 1 \u767b\u9646\u65b0\u6d6a\r\n\r\n\u767b\u9646\u811a\u672c\u53c2\u8003\u8be5\u9875\u9762 Reference https://gist.github.com/mrluanma/3621775\r\n\r\n## Step 2 \u8bf7\u6c42\u4e00\u4e2atoken\r\n\r\n\r\n\u8bf7\u6c42\u5730\u5740: https://current.sina.com.cn/auth/api/jsonp.php/varxxxl/AuthSign_Service.getSignCode\r\n\u65b9\u6cd5: Get\r\n\r\n\u5b57\u6bb5       | \u8bf4\u660e \r\n---------|-------\r\nquery_type | A_hq (A\u80a1\u884c\u60c5)\r\n ip  | \u5f53\u524d\u673a\u5668\u7684\u516c\u7f51IP\r\nlist | \u8bf7\u6c42\u7684\u67e5\u770b\u80a1\u7968\u7684\u5217\u8868 \r\nkick | \u8bbe\u7f6e\u4e3a1, \u5426\u5219\u53ef\u80fd\u51fa\u73b0\u53d6\u4e0d\u5230token\u7684\u60c5\u51b5\r\n\r\n\r\n\r\n\r\n## \u4f7f\u7528token\u7528websocket\u83b7\u53d6\u884c\u60c5\r\n\r\n\u83b7\u53d6token\u662f\u4e00\u4e2awebsocket\u534f\u8bae\r\n\r\nws://ff.sinajs.cn/wskt?token={token}&list={list}\r\n\r\ntoken\u5fc5\u987b\u662f\u4f7f\u7528\u8be5{list}\u5f97\u5230\u7684token. \u4e0d\u7136\u4f1a\u62a5\u9519\r\n\r\ntoken\u9700\u8981\u5b9a\u65f6\u66f4\u65b0. \u6bcf\u4e00\u4e2awebsocket\u53ea\u4f1a\u6301\u7eed\u5927\u69823-5\u5206\u949f. \u5f53websocket disconnect\u4e4b\u540e, \u9700\u8981\u91cd\u65b0\u8bf7\u6c42\u4e00\u4e2atoken. \u7136\u540e\u518d\u6b21\u94fe\u63a5websocket\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "\u8be5\u8f6f\u4ef6\u9700\u8981\u81ea\u884c\u8d2d\u4e70\u65b0\u6d6a\u7684level2\u6807\u51c6\u7248.",
    "version": "1.1.5",
    "project_urls": {
        "Homepage": "https://github.com/yanjlee/sinalv2"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8c9e7fff4349fd2bd7ce2de744d7c5e960be4c4921101874f3c0ba81999f3396",
                "md5": "a3a07f177169fbba37e3cfa1731e143a",
                "sha256": "b3e1a8627d4bb1b46bf561568a4ba9e254e84f095c7669259b171d530ed981d6"
            },
            "downloads": -1,
            "filename": "sinalv2-1.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a3a07f177169fbba37e3cfa1731e143a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3153,
            "upload_time": "2024-06-01T08:25:00",
            "upload_time_iso_8601": "2024-06-01T08:25:00.243819Z",
            "url": "https://files.pythonhosted.org/packages/8c/9e/7fff4349fd2bd7ce2de744d7c5e960be4c4921101874f3c0ba81999f3396/sinalv2-1.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5a25fa43a55060b22e1058cf9ef5713610d53db1041fa21c59c3bd8eba98ee1b",
                "md5": "def8da37cb718b0114b14fe1ef9d2827",
                "sha256": "b8f0f7040648f4011a7629090dad556550b36b59e8cf05836456e81aa918bda7"
            },
            "downloads": -1,
            "filename": "sinalv2-1.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "def8da37cb718b0114b14fe1ef9d2827",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3641,
            "upload_time": "2024-06-01T08:25:03",
            "upload_time_iso_8601": "2024-06-01T08:25:03.435940Z",
            "url": "https://files.pythonhosted.org/packages/5a/25/fa43a55060b22e1058cf9ef5713610d53db1041fa21c59c3bd8eba98ee1b/sinalv2-1.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-01 08:25:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yanjlee",
    "github_project": "sinalv2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "autobahn",
            "specs": []
        },
        {
            "name": "rsa",
            "specs": []
        },
        {
            "name": "requests",
            "specs": []
        }
    ],
    "lcname": "sinalv2"
}
        
Elapsed time: 0.28867s