fintie.stock.hist_quotes

行情获取模块

本模块负责获取股票的历史交易行情信息。

获取通道包括:

Get https://stock.xueqiu.com/v5/stock/chart/kline.json

params:

"symbol": 代码
"begin": 时间戳
"period": 频率,
"type": 复权类型,
"count": 数量,
"indicator": "kline,ma,macd,kdj,boll,rsi,wr,bias,cci,psy",

加载:

from pathlib import Path
import pandas as pd

with Path('data.json').open(encoding="utf-8") as f:
    quotes = json.load(f)

df = pd.DataFrame(data=quotes['item'], column=quotes['column'])
df.timestamp = pd.to_datetime(df.timestamp, unit='ms')
df.set_index('timestamp', inplace=True)

TODO

async fintie.stock.hist_quotes.async_get_hist_quotes(session, symbol, ref_dt, count=100, freq='1m', fq_type='before', data_path=None, return_df=True)[源代码]

小于 day 频率的数据,会有时间限制,只能取最近的数据,请谨慎使用

参数
  • sessionaiohttp.ClientSession 对象,同步接口不需要传

  • symbol – 股票代码,如 SZ002353

  • ref_dt – 行情数据参考日期,count 传负是截止日期,传正为开始日期

  • count – 要取的行情数据的条数

  • freq – 数据频率:1m/5m/15m/30m/60m/120m/day/week/month/quarter/year

  • fq_type – before/after/normal 前复权、后复权、不复权

  • data_path – 数据保存路径

  • return_df – 是否返回 pandas.DataFrame 对象,False 返回原始数据

返回

行情原始数据或带有行情数据的 pandas.DataFrame 对象,见 return_df 参数

fintie.stock.hist_quotes.get_hist_quotes(*args, **kwargs)[源代码]

小于 day 频率的数据,会有时间限制,只能取最近的数据,请谨慎使用

参数
  • sessionaiohttp.ClientSession 对象,同步接口不需要传

  • symbol – 股票代码,如 SZ002353

  • ref_dt – 行情数据参考日期,count 传负是截止日期,传正为开始日期

  • count – 要取的行情数据的条数

  • freq – 数据频率:1m/5m/15m/30m/60m/120m/day/week/month/quarter/year

  • fq_type – before/after/normal 前复权、后复权、不复权

  • data_path – 数据保存路径

  • return_df – 是否返回 pandas.DataFrame 对象,False 返回原始数据

返回

行情原始数据或带有行情数据的 pandas.DataFrame 对象,见 return_df 参数