# Vnpy Export

Export a Vibe-Trading backtest strategy to a runnable vnpy CtaTemplate Python class, ...

- Repository: https://github.com/HKUDS/Vibe-Trading (37375 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add HKUDS/Vibe-Trading --skill vnpy-export -g -a claude-code -y`
Codex: `npx skills add HKUDS/Vibe-Trading --skill vnpy-export -g -a codex -y`
Cursor: `npx skills add HKUDS/Vibe-Trading --skill vnpy-export -g -a cursor -y`
Gemini CLI: `npx skills add HKUDS/Vibe-Trading --skill vnpy-export -g -a gemini-cli -y`

## Description

Export a Vibe-Trading backtest strategy to a runnable vnpy CtaTemplate Python class, supports A-share equities, futures, and crypto via BarGenerator + ArrayManager.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

## Overview

This skill translates a Vibe-Trading strategy into a **vnpy `CtaTemplate` subclass** `.py` file
that can be loaded directly into the vnpy CTA Strategy App for live trading or vnpy backtesting.

Output file: `artifacts/vnpy_strategy/<StrategyName>Strategy.py` (inside the run directory).

vnpy is the most widely-used open-source quant framework in mainland China (39k+ GitHub stars).
Use this skill when the user asks to export to vnpy, requests a `/vnpy` command, or wants to
run a Vibe-Trading strategy inside vnpy's CTA backtester or live trading engine.

---

## Workflow: Export from Backtest Run

1. `load_skill("vnpy-export")`, read this guide
2. `read_file("config.json")`, extract instrument, dates, parameters, interval
3. `read_file("code/signal_engine.py")`, understand the Python signal logic
4. Determine asset class from `config.json` → choose correct CtaTemplate convention (see below)
5. Translate signal logic to CtaTemplate using the reference tables
6. `write_file("artifacts/vnpy_strategy/<StrategyName>Strategy.py")`, save the output
7. Return the class in a code block with setup instructions

## Workflow: Generate from Description

1. `load_skill("vnpy-export")`, read this guide
2. Write a CtaTemplate class from the user's strategy description
3. `write_file("artifacts/vnpy_strategy/<StrategyName>Strategy.py")`, save the output
4. Return the class with setup and usage instructions

---

## Asset Class Conventions

vnpy uses the same `CtaTemplate` base class for all asset types, but parameter conventions differ:

| Asset Class | Instrument Example | `vt_symbol` Format | Position Unit |
|-------------|-------------------|---------------------|---------------|
| A-share stock | Ping An Bank | `000001.SZSE` | shares (整手, min 100) |
| Futures | IF2406 | `IF2406.CFFEX` | lots |
| Crypto | BTC/USDT | `BTC/USDT.BINANCE` | coin units |

The rest: https://github.com/HKUDS/Vibe-Trading/blob/HEAD/agent/src/skills/vnpy-export/SKILL.md
