Metadata-Version: 2.4
Name: quantdash
Version: 0.1.0
Summary: QuantDash Python SDK - 专业金融数据平台
Author: QuantDash
License: MIT
Project-URL: Documentation, https://docs.quantdash.net
Keywords: finance,stock,market-data,quant,kline,quantdash,a-share,us-stock,hk-stock,real-time-quotes
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.25.0
Requires-Dist: typing-extensions>=4.0.0
Requires-Dist: pandas>=1.5.0
Requires-Dist: tqdm>=4.60.0

# QuantDash Python SDK

QuantDash Python SDK 是 QuantDash 金融数据平台的 Python 客户端，支持 A 股、ETF、美股、港股。

> **完整文档**：<https://docs.quantdash.net>

---

## 安装

```bash
pip install quantdash
```

SDK 支持 Python 3.9+，推荐 3.10 或更高版本。内置 pandas 和 tqdm 支持。

---

## 初始化

```python
from quantdash import QuantDash

qd = QuantDash(api_key="your-api-key")
```

也支持环境变量：

```bash
export QUANTDASH_API_KEY="your-api-key"
```

```python
from quantdash import QuantDash
qd = QuantDash()  # 自动读取 QUANTDASH_API_KEY
```

---

## 标的代码格式

| 示例 | 说明 |
|------|------|
| `600519.SH` | 上交所 |
| `000001.SZ` | 深交所 |
| `AAPL.US` | 美股 |
| `00700.HK` | 港股 |

---

## 基础用法

### K 线获取

```python
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)
```

**批量获取**：多只标的一次拉取：

```python
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"]])
```

### 日内分时

```python
# 当日 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)
```

### 实时行情

**按标的代码查询**

```python
df = qd.quotes.get(symbols=["600519.SH", "000001.SZ"], to_dataframe=True)
print(df[["symbol", "last_price", "volume", "ext.name", "ext.change_pct"]])
```

**按标的池查询（全量行情）**

```python
# 全部 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）

### 五档盘口

```python
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"])
```

### 标的信息

```python
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']})")
```

### 复权因子

```python
df = qd.klines.ex_factors(["600519.SH", "000001.SZ"], to_dataframe=True)
print(df[["symbol", "trade_date", "ex_factor"]].tail())
```

---

## 更多文档

- [Python SDK 快速开始](https://docs.quantdash.net/zh-Hans/sdk/python-quickstart)
- [使用示例](https://docs.quantdash.net/zh-Hans/sdk/python-examples)
- [REST API 说明](https://docs.quantdash.net/zh-Hans/api-reference/introduction)

---

## License

MIT
