Skip to content

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

PTRade 策略 API Codex Skill

这是一个面向 Codex 的 PTRade/PTrade 量化策略开发 skill。安装后,Codex 在编写、改造、审查或调试 PTRade 策略时,会优先参考仓库内置的 PTRade API 文档,而不是凭通用 Python 或其他量化平台经验猜测接口。

适用场景

这个 skill 适合用于:

  • 编写 PTRade 策略模板,包括 initialize(context)、handle_data(context, data)、盘前和盘后函数。
  • 迁移其他平台策略到 PTRade,例如从 JoinQuant、QMT、掘金或本地 Python 策略迁移。
  • 查询 PTRade 的行情、历史数据、财务数据、Tick/L2 数据接口写法。
  • 编写下单、撤单、持仓、委托、成交、资金查询相关代码。
  • 区分回测环境和实盘环境中的 API 差异。
  • 检查策略代码是否误用了字段名、状态枚举、生命周期函数或返回结构。
  • 让 Codex 基于本地 API 参考文档生成更符合 PTRade 约定的策略代码。

仓库内容

skills/
  ptrade-strategy-api/
    SKILL.md
    references/
      ptrade_api_full.md
    agents/
      openai.yaml

文件说明:

  • skills/ptrade-strategy-api/SKILL.md:Codex skill 的主说明文件,定义何时使用、如何使用 PTRade API 参考。
  • skills/ptrade-strategy-api/references/ptrade_api_full.md:PTRade API 本地参考文档,是该 skill 的核心资料。
  • skills/ptrade-strategy-api/agents/openai.yaml:Codex 界面展示用元数据。

安装前准备

请先确认:

  • 已安装 Codex。
  • 终端里可以运行 Python 3。
  • 可以访问 GitHub。

如果你不确定 Python 是否可用,可以先运行:

python3 --version

Windows PowerShell 用户也可以运行:

python --version

如果 Windows 上 python 不可用,可以试:

py --version

安装方法

macOS / Linux

在 Terminal 中运行:

python3 ~/.codex/skills/.system/skill-installer/scripts/install-skill-from-github.py \
  --repo stepven8/ptrade-strategy-api-skill \
  --path skills/ptrade-strategy-api

Windows

在 PowerShell 中运行:

python "$env:USERPROFILE\.codex\skills\.system\skill-installer\scripts\install-skill-from-github.py" `
  --repo stepven8/ptrade-strategy-api-skill `
  --path skills/ptrade-strategy-api

如果提示 python 无法识别,请改用 py:

py "$env:USERPROFILE\.codex\skills\.system\skill-installer\scripts\install-skill-from-github.py" `
  --repo stepven8/ptrade-strategy-api-skill `
  --path skills/ptrade-strategy-api

安装完成后,请重启 Codex,让新的 skill 被加载。

安装后的目录通常是:

  • macOS / Linux:~/.codex/skills/ptrade-strategy-api
  • Windows:%USERPROFILE%\.codex\skills\ptrade-strategy-api

使用方法

重启 Codex 后,可以在对话中直接点名使用:

$ptrade-strategy-api

示例:

使用 $ptrade-strategy-api 写一个 PTRade 策略,每天 09:35 根据股票池进行调仓。

也可以这样描述任务:

用 $ptrade-strategy-api 检查这个 PTRade 策略有没有生命周期函数、下单接口或数据字段方面的问题。

Codex 使用该 skill 时,会优先搜索 references/ptrade_api_full.md,再根据文档中的函数签名、参数说明、返回结构和注意事项生成代码或审查结果。

更新方法

如果之后仓库更新了 API 文档或 skill 内容,可以先删除旧版本,再重新安装。

macOS / Linux:

rm -rf ~/.codex/skills/ptrade-strategy-api
python3 ~/.codex/skills/.system/skill-installer/scripts/install-skill-from-github.py \
  --repo stepven8/ptrade-strategy-api-skill \
  --path skills/ptrade-strategy-api

Windows PowerShell:

Remove-Item -Recurse -Force "$env:USERPROFILE\.codex\skills\ptrade-strategy-api"
python "$env:USERPROFILE\.codex\skills\.system\skill-installer\scripts\install-skill-from-github.py" `
  --repo stepven8/ptrade-strategy-api-skill `
  --path skills/ptrade-strategy-api

更新后同样需要重启 Codex。

卸载方法

macOS / Linux:

rm -rf ~/.codex/skills/ptrade-strategy-api

Windows PowerShell:

Remove-Item -Recurse -Force "$env:USERPROFILE\.codex\skills\ptrade-strategy-api"

注意事项

  • 该 skill 只提供 PTRade API 使用指导和本地参考文档,不包含券商账号、交易权限、行情权限或任何实盘连接能力。
  • 生成的策略代码在实盘使用前,必须先由使用者自行回测、仿真、审查风控逻辑,并确认目标券商环境支持相关 API。
  • PTRade 不同券商环境、客户端版本或 Python 版本可能存在细节差异,遇到差异时应以实际环境文档和测试结果为准。
  • 涉及下单、撤单、资金和持仓的代码,需要特别核对函数参数、数量单位、价格规则、返回结构和状态枚举。

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors