Skip to main content

A utility for Fetch China Stock Info

Project description

pqquotation

快速获取新浪/腾讯/东方财富的全市场行情,网络正常的情况下只需要 200+ms。本软件基于 easyquotation改进而来。

前言

  • 获取新浪的免费实时行情
  • 获取腾讯财经的免费实时行情
  • 获取东方财富的免费实时行情
  • 获取集思路的数据

安装

pip install pqquotation

用法

引入:

import pqquotation

选择行情

quotation = pqquotation.use('sina') # 新浪 ['sina'], 腾讯 ['tencent', 'qq'], 东方财富 ['dc', 'eastmoney']

获取所有股票行情

# prefix 指定返回行情的股票代码是否带 sz/sh/bj 市场前缀
quotation.market_snapshot(prefix=True) 

return

 {'sh000159': {'name': '国际实业', # 股票名
  'buy': 8.87, # 竞买价
  'sell': 8.88, # 竞卖价
  'now': 8.88, # 现价
  'open': 8.99, # 开盘价
  'close': 8.96, # 昨日收盘价
  'high': 9.15, # 今日最高价
  'low': 8.83, # 今日最低价
  'turnover': 22545048, # 交易股数
  'volume': 202704887.74 # 交易金额
  'ask1': 8.88, # 卖一价
  'ask1_volume': 111900, # 卖一量
  'ask2': 8.89,
  'ask2_volume': 54700,
  'bid1': 8.87, # 买一价
  'bid1_volume': 21800, # 买一量
  ...
  'bid2': 8.86, 
  'bid2_volume': 78400,
  'date': '2016-02-19',
  'time': '14:30:00',
  ...},
  ......
}
单只股票
quotation.real('162411') # 支持直接指定前缀,如 'sh000001'
多只股票
quotation.real(['000001', '162411']) 
同时获取指数和行情
# 获取相同代码的指数和股票时 prefix 必须为 True
quotation.real(['sh000001', 'sz000001'], prefix=True)

更新内置全市场股票代码

easyquotation.update_stock_codes()
港股日k线图

腾讯日k线图

import easyquotation
quotation  = easyquotation.use("daykline")
data = quotation.real(['00001','00700'])
print(data)
{
    '00001': [
                ['2017-10-09', '352.00', '349.00', '353.00', '348.60', '13455864.00'], # [日期, 今开, 今收, 最高, 最低, 成交量 ]
                ['2017-10-10', '350.80', '351.20', '352.60', '349.80', '10088970.00'],
               ]
    '00700':[
        
    ]           
     }
}
腾讯港股实时行情

腾讯控股实时行情

import easyquotation
quotation = easyquotation.use("hkquote")
data = quotation.real(['00001','00700'])
print(data)
{
    '00001': 
        {
            'stock_code': '00001', # 股票代码
            'lotSize': '"100', # 每手数量
            'name': '长和', # 股票名称
            'price': '97.20', # 股票当前价格
            'lastPrice': '97.75', # 股票昨天收盘价格
            'openPrice': '97.75', # 股票今天开盘价格
            'amount': '1641463.0', # 股票成交量 
            'time': '2017/11/29 15:38:58', # 当前时间
            'high': '98.05', # 当天最高价格
            'low': '97.15' # 当天最低价格
        }, 
    '00700': 
        {
            'stock_code': '00700', 
            'lotSize': '"100',
            'name': '腾讯控股', 
            'price': '413.20', 
            'lastPrice': '419.20', 
            'openPrice': '422.20', 
            'amount': '21351010.0', 
            'time': '2017/11/29 15:39:01', 
            'high': '422.80',
            'low': '412.40'
        }
}

选择 jsl(集思录) 行情

quotation = easyquotation.use('jsl') 
设置 cookie (可选)

不设置的话获取相关数据有限制

quotation.set_cookie('从浏览器获取的集思录 Cookie')
指数ETF查询接口

TIP : 尚未包含黄金ETF和货币ETF

集思录ETF源网页

quotation.etfindex(index_id="", min_volume=0, max_discount=None, min_discount=None)

return

{
    "510050": {
        "fund_id": "510050",                # 代码
        "fund_nm": "50ETF",                 # 名称
        "price": "2.066",                   # 现价
        "increase_rt": "0.34%",             # 涨幅
        "volume": "71290.96",               # 成交额(万元)
        "index_nm": "上证50",                # 指数
        "pe": "9.038",                      # 指数PE
        "pb": "1.151",                      # 指数PB
        "index_increase_rt": "0.45%",       # 指数涨幅
        "estimate_value": "2.0733",         # 估值
        "fund_nav": "2.0730",               # 净值
        "nav_dt": "2016-03-11",             # 净值日期
        "discount_rt": "-0.34%",            # 溢价率
        "creation_unit": "90",              # 最小申赎单位(万份)
        "amount": "1315800",                # 份额
        "unit_total": "271.84",             # 规模(亿元)
        "index_id": "000016",               # 指数代码
        "last_time": "15:00:00",            # 价格最后时间(未确定)
        "last_est_time": "23:50:02",        # 估值最后时间(未确定)
    }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pqquotation-0.8.0.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pqquotation-0.8.0-py3-none-any.whl (38.9 kB view details)

Uploaded Python 3

File details

Details for the file pqquotation-0.8.0.tar.gz.

File metadata

  • Download URL: pqquotation-0.8.0.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for pqquotation-0.8.0.tar.gz
Algorithm Hash digest
SHA256 f0fc1aebccf640b6df3bc0ad0cb17b4c94b969d46e1dfd2e9bb80248171fce5d
MD5 a434ff7e5e66ddd87e6406a341da3268
BLAKE2b-256 4d62e6f811c6a72f16cb956094f2faf9f4bb0dfa8fe8fe6d5b28eaada21c0a4a

See more details on using hashes here.

File details

Details for the file pqquotation-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: pqquotation-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 38.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for pqquotation-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 584249bf3edb7695c4030ebe679a979ae6e35dc199fbf4e6c8ceed4df4871e16
MD5 d1b872328185d2faaf1c77631ccaf46e
BLAKE2b-256 cf324df97cccdb150e338fdda55b218f7107bded2ea8420002ef4a9b0143247e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page