QuantDash Python SDK - 专业金融数据平台
Project description
QuantDash Python SDK
QuantDash Python SDK 是 QuantDash 金融数据平台的 Python 客户端,支持 A 股、ETF、美股、港股。
安装
pip install quantdash
SDK 支持 Python 3.9+,推荐 3.10 或更高版本。内置 pandas 和 tqdm 支持。
初始化
from quantdash import QuantDash
qd = QuantDash(api_key="your-api-key")
也支持环境变量:
export QUANTDASH_API_KEY="your-api-key"
from quantdash import QuantDash
qd = QuantDash() # 自动读取 QUANTDASH_API_KEY
标的代码格式
| 示例 | 说明 |
|---|---|
600519.SH |
上交所 |
000001.SZ |
深交所 |
AAPL.US |
美股 |
00700.HK |
港股 |
基础用法
K 线获取
from quantdash import QuantDash
qd = QuantDash(api_key="your-api-key")
# 日 K 线,返回 DataFrame
df = qd.klines.get("600519.SH", period="1d", count=5, to_dataframe=True)
print(df[["trade_date", "open", "high", "low", "close", "volume"]])
# 复权方式:forward(默认)/ backward / none
df = qd.klines.get("600519.SH", adjust="none", to_dataframe=True)
批量获取:多只标的一次拉取:
symbols = ["600519.SH", "000001.SZ", "601318.SH"]
dfs = qd.klines.batch(symbols, period="1d", count=5, to_dataframe=True, show_progress=True)
# dfs 是 dict: {"600519.SH": DataFrame, "000001.SZ": DataFrame, ...}
print(dfs["600519.SH"][["trade_date", "close"]])
日内分时
# 当日 1 分钟线
df = qd.klines.intraday("600519.SH", to_dataframe=True)
print(df[["trade_time", "close", "volume"]].tail())
# 5 分钟线
df = qd.klines.intraday("600519.SH", period="5m", to_dataframe=True)
# 批量日内分时
dfs = qd.klines.intraday_batch(["600519.SH", "000001.SZ"], to_dataframe=True)
实时行情
按标的代码查询
df = qd.quotes.get(symbols=["600519.SH", "000001.SZ"], to_dataframe=True)
print(df[["symbol", "last_price", "volume", "ext.name", "ext.change_pct"]])
按标的池查询(全量行情)
# 全部 A 股实时行情
df = qd.quotes.get(universes="CN_Stock", to_dataframe=True)
print(f"共 {len(df)} 只标的")
支持的标的池:CN_Stock(A股)、US_Stock(美股)、HK_Stock(港股)、CN_ETF(ETF)
五档盘口
depth = qd.depth.get("600519.SH")
print(f"标的: {depth['symbol']}, 地区: {depth['region']}")
print(f"买盘价: {depth['bid_prices']}")
print(f"卖盘价: {depth['ask_prices']}")
# 批量五档盘口
depths = qd.depth.batch(["600519.SH", "000001.SZ"])
标的信息
inst = qd.instruments.get("600519.SH")
print(f"{inst['symbol']}: {inst['name']} ({inst['exchange']}, {inst['type']})")
# 批量查询
insts = qd.instruments.batch(["600519.SH", "000001.SZ", "00700.HK"])
for i in insts:
print(f"{i['symbol']}: {i['name']} ({i['region']})")
复权因子
df = qd.klines.ex_factors(["600519.SH", "000001.SZ"], to_dataframe=True)
print(df[["symbol", "trade_date", "ex_factor"]].tail())
更多文档
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
quantdash-0.1.0.tar.gz
(19.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
quantdash-0.1.0-py3-none-any.whl
(24.6 kB
view details)
File details
Details for the file quantdash-0.1.0.tar.gz.
File metadata
- Download URL: quantdash-0.1.0.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32f91c5141fafcc786bb91a867a082d3bace5f0d4e103faffffff29d4c8d19b3
|
|
| MD5 |
7df5a19dab139a8daa3a47a2cdd3c1b3
|
|
| BLAKE2b-256 |
cb39a70a56214532bbe3597ba88f0d71a70a213c5b67061855a1f5634a95b995
|
File details
Details for the file quantdash-0.1.0-py3-none-any.whl.
File metadata
- Download URL: quantdash-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31f3e5a03e09056adc79c0d7f59832f3570d59efe3fd8904672d566b70d2c0a5
|
|
| MD5 |
33dac24fa4907143f3d2e494481a55e3
|
|
| BLAKE2b-256 |
5a3823f75498e7a00de1c2e249efd93074f8e03c34e00989b83afdf908d828ee
|