爱股数据(别名:A股数据),一个集A股、期货与一体的量化交易数据服务平台。
Project description
✨ 特性
- 🐍 全版本兼容: 支持 Python 2.7+ 和 Python 3.5+,自动适配依赖版本
- 🚀 开箱即用: 简洁的API设计,几行代码即可获取数据
- 📊 数据处理: 内置pandas支持,返回DataFrame格式,便于分析
- 🔧 灵活配置: 支持环境变量配置,支持自定义API端点
- 📈 实时数据: 提供A股、期货等金融数据的实时访问
- 🛡️ 安全可靠: 支持API密钥管理,支持密钥有效期设置
🚀 快速开始
安装
pip install agushuju
获取API密钥
- 访问 官网 注册账号
- 进入会员中心,点击"API密钥"
- 复制您的API密钥
💡 密钥类型说明:
- 默认密钥:用于在线调试,不可删除
- 自定义密钥:可设置注释和有效期,便于管理
🆘 遇到问题? 加入QQ群 224731242 获取帮助!
基础使用
import agushuju
# 创建API客户端
api = agushuju.api("your_token_here")
# 获取股票基本信息(默认参数)
df = api.stock_basic()
print(df.head())
高级查询
# 带参数查询(指定条件,返回指定字段)
df = api.stock_basic(
request={
"list_status": "L", # 查询上市股票
"limit": 100, # 限制返回数量
"offset": 0 # 偏移量
},
response=["stock_code", "stock_name", "area"] # 指定返回字段
)
print(f"查询到 {len(df)} 只股票")
print(df.head())
使用别名导入
# 也可以使用 aigushuju 别名
import aigushuju as agu
api = agu.api("your_token_here")
df = api.stock_basic()
📚 接口文档
详细的接口参数和返回字段说明,请查看:
👉 完整接口文档
💡 使用示例
获取股票列表
import agushuju
# 初始化API
api = agushuju.api("your_token_here")
# 获取所有上市股票
stocks = api.stock_basic(
request={"list_status": "L"},
response=["stock_code", "stock_name", "area", "industry"]
)
print(f"共找到 {len(stocks)} 只上市股票")
print(stocks.head(10))
数据分析示例
import pandas as pd
# 获取股票数据
df = api.stock_basic()
# 按地区统计股票数量
area_stats = df['area'].value_counts().head(10)
print("各地区股票数量:")
print(area_stats)
批量查询
# 分页获取数据
all_stocks = []
offset = 0
limit = 1000
while True:
batch = api.stock_basic(
request={"limit": limit, "offset": offset},
response=["stock_code", "stock_name"]
)
if len(batch) == 0:
break
all_stocks.append(batch)
offset += limit
print(f"已获取 {offset} 条记录...")
# 合并所有数据
final_df = pd.concat(all_stocks, ignore_index=True)
print(f"总共获取 {len(final_df)} 条股票记录")
⚙️ 配置
环境变量
您可以通过环境变量设置默认配置,避免在代码中硬编码:
# Windows
set AGU_TOKEN=your_token_here
set AGU_BASE_URL=https://www.agushuju.com/api
# Linux/macOS
export AGU_TOKEN="your_token_here"
export AGU_BASE_URL="https://www.agushuju.com/api"
# 使用环境变量
import agushuju
# 自动从环境变量读取配置
api = agushuju.api() # 无需传入token
🔧 兼容性
| Python版本 | 状态 | requests版本 | pandas版本 |
|---|---|---|---|
| Python 2.7 | ✅ 支持 | >= 2.20.0, < 3.0.0 | >= 0.24.0, < 1.0.0 |
| Python 3.5+ | ✅ 支持 | >= 2.25.0 | >= 1.1.0 |
📞 支持与社区
- 🌐 官网: https://www.agushuju.com/
- 📖 文档: https://www.agushuju.com/doc
- 💬 社区: https://www.agushuju.com/ask
- 👥 QQ群: 224731242
- 📧 邮箱: jinguxun@qq.com
📄 许可证
本项目基于 MIT License 开源协议。
⭐ 如果这个项目对您有帮助,请给我们一个星标!
Made with ❤️ by 安徽爱股科技有限公司
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
agushuju-0.1.3.tar.gz
(8.1 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
File details
Details for the file agushuju-0.1.3.tar.gz.
File metadata
- Download URL: agushuju-0.1.3.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8a1de713c0bce2ea27ca1e716021901d69bf4707b816d81d19b556da4b297a7
|
|
| MD5 |
791ddf131f00b8dd84c2f43e810a947d
|
|
| BLAKE2b-256 |
987fdbce57f203f234815a4a700ef582e595b5d71a98353e3c56cdef06e66619
|
File details
Details for the file agushuju-0.1.3-py3-none-any.whl.
File metadata
- Download URL: agushuju-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4f260ed686c88cb9a4ab8aefe32a96c2b5be531bcebe6392fe095509c112d55
|
|
| MD5 |
eedb043f59ae8ef0d33fc18f1862867c
|
|
| BLAKE2b-256 |
3682e1d718d103dab9227cf001c39f8c9cbebd963f31ab95b1827f212a52dc14
|