Actively developed AlgoGP bridge

VeighNa (vn.py) guide

VeighNa is the standard toolkit for China futures automation, with a broad gateway ecosystem.

Last reviewed · Also known as vnpy, vn.py, VeighNa, CtaTemplate

Quick answer

VeighNa (formerly vn.py) is the most widely used open-source quant trading platform in China. It combines a desktop trader GUI, an event engine, apps such as CtaStrategy and CtaBacktester, and gateways for China futures (CTP), securities, Interactive Brokers and crypto exchanges. Strategies subclass CtaTemplate and receive ticks and bars.

VeighNa (vn.py) at a glance

Category
Backtest + live trading engines
Language
Python
License
MIT
Does
Backtesting, Live trading, Optimization
Markets
Futures, Options, Stocks, Crypto
Best for
China futures and options via CTP, and traders who want a desktop GUI around their algorithms.
In AlgoGP
Built-in bridge: add it to any project

Pick it if

China futures and options via CTP, and traders who want a desktop GUI around their algorithms.

Watch out for

Documentation and community are primarily in Chinese.

VeighNa (vn.py) strengths and limitations

Strengths

  • Gateways for CTP and many Chinese brokers, plus IB and crypto.
  • GUI apps for strategy management, backtesting and risk.
  • Large Chinese-language community and documentation.

Limitations

  • Documentation and community are primarily in Chinese.
  • Windows-first; some gateways are platform-specific.

VeighNa (vn.py) example

pip install vnpy vnpy_ctastrategy
Install
from vnpy_ctastrategy import CtaTemplate, BarData, BarGenerator, TickData

class Demo(CtaTemplate):
    author = "me"
    def __init__(self, cta_engine, strategy_name, vt_symbol, setting):
        super().__init__(cta_engine, strategy_name, vt_symbol, setting)
        self.bg = BarGenerator(self.on_bar)
    def on_tick(self, tick: TickData):
        self.bg.update_tick(tick)
    def on_bar(self, bar: BarData):
        if self.pos == 0:
            self.buy(bar.close_price, 1)
CtaTemplate skeleton.

Use VeighNa (vn.py) with AlgoGP

AlgoGP has a built-in VeighNa (vn.py) bridge. Describe the strategy to the copilot and backtest it in AlgoGP, then open the project’s APIs & keys tab and add VeighNa (vn.py) under Frameworks. The project gains these files, saved as a new version and included in every export:

  • frameworks/algogp_bridge.py
  • frameworks/tests/test_bridge.py
  • frameworks/vnpy_cta_strategy.py
  • requirements.txt gains: vnpy, vnpy_ctastrategy
Add AlgoGPCtaStrategy in VeighNa’s CtaStrategy or CtaBacktester app
Run the AlgoGP strategy with VeighNa (vn.py).

VeighNa (vn.py) connects to Interactive Brokers, Binance, OKX, Bybit. Each guide shows how to create the API key, which you can store in the project’s Keys & secrets.

VeighNa (vn.py): frequently asked questions

Is vn.py the same as VeighNa?

Yes. The project was renamed VeighNa; the package and community still use vnpy.

Does VeighNa support Interactive Brokers?

Yes, through the vnpy_ib gateway.

VeighNa (vn.py) alternatives

Independent guide. AlgoGP is not affiliated with VeighNa (vn.py). Features, licenses and maintenance change; check the official documentation. Nothing here is investment advice.

Build a strategy