Skip to content

GuangfuWu/privora-python-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Privora Python Examples 🐍📈

Python examples for Privora — the AI-Agent-friendly quant data backend covering A 股 + 港股 8500+ 股票 (unified stock_day / stock_minutes 一张表) + 黄金 + 基金 + 财报事件.

当前状态 (2026-06-25)quickstart/ 3 个例子已用真 Bearer Token 跑过本地 dev stack E2E 验证(详见 test report — 之前 2026-06-25 上午有过一版 response-shape 写错的 bug,已 fix 在 commit <latest>)。 当前已 verified:

  • 01-bearer-token-setup.py — public ping + token verify
  • 02-fetch-stock-day.py — dataasset.list + dataasset.data.get pattern;dev 环境 stock_day 数据源未配是已知 gap,prod 数据完整
  • 03-portfolio-snapshot.py — graceful 处理 "tenant 没 DEK" 的 500(dev 测试账户预期,prod 账户都有 DEK 不会触发)

任何 prod 跑出来不 match 的请提 Issue。

📦 这个 repo 里有什么

目录 内容 验证状态
quickstart/ Bearer Token 配置 + 第一次调 API 的 3 个 minimal 例子 🟢 endpoint + response shape + 错误路径都已 dev stack 验证
backtest/ lg_utils 跑回测(双均线 / 多因子 / HK pipeline) coming soon
paper-trading/ 模拟盘 happy path:MARKET / LIMIT 委托 + 持仓监控 coming soon
alerts/ 阈值触发 → 飞书 / 微信 / 钉钉 webhook coming soon
ai-agent/ Claude / OpenClaw / Hermes 直接调 Privora 的 agent 配置 coming soon

🚀 1 分钟跑通第一个例子

# 1. clone
git clone https://github.com/GuangfuWu/privora-python-examples.git
cd privora-python-examples

# 2. 注册 Privora + 拿 Bearer Token
#    访问 https://privora.cn/profile/tokens?utm_source=github&utm_campaign=python-examples
#    点 "New Token",按你要跑的脚本选 scopes:
#      - 跑 01-bearer-token-setup.py     → dataasset.list
#      - 跑 02-fetch-stock-day.py        → + dataasset.data.get
#      - 跑 03-portfolio-snapshot.py     → + investment.stock.portfolio.list
#    全部跑的话: dataasset.list + dataasset.data.get + investment.stock.portfolio.list

# 3. 设置环境变量
export LG_AGENT_BASE_URL=https://privora.cn
export LG_AGENT_TOKEN=lgatk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

# 4. 跑第一个例子
pip install requests
python quickstart/01-bearer-token-setup.py

🎯 适合谁

  • 散户量化研究者:想用 Python 跑策略,但不想自建数据爬虫 + 数据库 + cron
  • AI Agent 开发者:想让 Claude / ChatGPT / Hermes 直接读金融数据 + 触发告警
  • 多人 / 团队:tenant 隔离 + 字段加密的持仓数据共享
  • 港股量化:A 股 + 港股 8500+ 股票 unified 一张表,按 ticker 路由(000001 / 00700.HK

🔗 相关资源

🤝 贡献 + 反馈

  • 想要新例子?提 Issue 描述你的场景
  • 你写了个好用的例子?欢迎 PR
  • 觉得 Privora 好用?请去 ClawHub 给 ⭐ star,让更多散户找到这个工具

📄 License

MIT License — 自由使用 / 修改 / 分发,代码用于商业项目无限制。

About

Real working Python examples for Privora — Bearer Token API, lg_utils backtests, paper-trading, AI Agent integration. A-share + HK 8500+ unified data backend.

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages