Use python faster fetch market quotes data


Keywords
aiohttp, async, asyncio, python, stock-market
License
MIT
Install
pip install fastquotes==0.2.0

Documentation

PyPI Documentation Status

FastQuotes

通过多线程或者异步的方法来获取行情

中文文档

注意:
获取股票列表的接口容易被封 IP,请提前做好应对措施!!

Installation

安装: pip install --upgrade fastquotes
卸载: pip uninstall fastquotes -y

Examples

import fastquotes

# quote = fastquotes.TencentQuote()
quote = fastquotes.SinaQuote()
codes = fastquotes.stock_list()

tick_dict = quote.tick_dict(codes)
print(len(tick_dict))
print(tick_dict["000001"])

Output:

4074
{'time': '150003', 'name': '平安银行', 'code': '000001', 'current_price': 18.46, 'pre_close': 17.83, 'open': 17.78, 'high': 18.5, 'low': 17.75, 'total_amount': 2508632642.49, 'total_vol': 137340072.0, 'bid1_vol': 125782, 'bid1': 18.45, 'bid2_vol': 42000, 'bid2': 18.44, 'bid3_vol': 15240, 'bid3': 18.43, 'bid4_vol': 31100, 'bid4': 18.42, 'bid5_vol': 21200, 'bid5': 18.41, 'ask1_vol': 404680, 'ask1': 18.46, 'ask2_vol': 285665, 'ask2': 18.47, 'ask3_vol': 15240, 'ask3': 18.48, 'ask4_vol': 31100, 'ask4': 18.49, 'ask5_vol': 2538805, 'ask5': 18.5}

Requirements

Python 3.6+

References

Cli

Usage: fquotes [OPTIONS]

Options:
  -c, --codes TEXT  Set fund code to get profit.
  -i, --intro TEXT  Set fund code to get intro.
  --help            Show this message and exit.

Examples

$ fquotes -i 110011
{'基金代码': '110011', '基金简称': '易方达中小盘混合', '基金类型': '混合型'}

$ fquotes -i 110011 -i 163808
{'基金代码': '110011', '基金简称': '易方达中小盘混合', '基金类型': '混合型'}
{'基金代码': '163808', '基金简称': '中银中证100指数增强', '基金类型': '股票指数'}

$ fquotes -c 110011 -c 481010 -c 570001
110011 2021-01-22 0.010017025810292735
481010 2021-01-22 0.015934207144692847
570001 2021-01-22 0.0156294563915349