MCPcopy
hub / github.com/vnpy/vnpy

github.com/vnpy/vnpy @4.4.0 sqlite

repository ↗ · DeepWiki ↗ · release 4.4.0 ↗
874 symbols 2,592 edges 72 files 682 documented · 78%
README

VeighNa - By Traders, For Traders, AI-Powered.

💬 Want to read this in chinese ? Go here

<img src ="https://img.shields.io/badge/version-4.4.0-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/platform-windows|linux|macos-yellow.svg"/>
<img src ="https://img.shields.io/badge/python-3.10|3.11|3.12|3.13-blue.svg" />
<img src ="https://img.shields.io/github/actions/workflow/status/vnpy/vnpy/pythonapp.yml?branch=master"/>
<img src ="https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange"/>

VeighNa is a Python-based open source quantitative trading system development framework that has grown step by step into a fully-featured quantitative trading platform with continuous contributions from the open source community. It currently has many users from domestic and international financial institutions, including hedge funds, investment banks, futures brokers, university research institutions, proprietary trading companies, etc.

If you have any questions about using VeighNa for secondary development (strategies, modules, etc.), please check the VeighNa Project Documentation. If you can't solve it, please go to the [Questions and Help] section of the Official Community Forum for help, or share your experience in the [Experience Sharing] section!

Want to get more information about VeighNa? Please scan the QR code below to add the assistant and join the [VeighNa Community Exchange WeChat Group]:

AI-Powered

On the tenth anniversary of VeighNa's release, version 4.0 officially introduces the vnpy.alpha module targeting AI quantitative strategies, providing professional quantitative traders with an all-in-one multi-factor machine learning (ML) strategy development, research, and live trading solution:

  • :bar_chart: dataset: Factor Feature Engineering

    • Designed specifically for ML algorithm training optimization, supporting efficient batch feature calculation and processing
    • Built-in rich factor feature expression calculation engine, enabling rapid one-click generation of training data
    • Alpha 158: A collection of stock market features from Microsoft's Qlib project, covering multiple dimensions of quantitative factors including K-line patterns, price trends, and time-series volatility
  • :bulb: model: Prediction Model Training

    • Provides standardized ML model development templates, greatly simplifying model building and training processes
    • Unified API interface design, supporting seamless switching between different algorithms for performance comparison testing
    • Integrates multiple mainstream machine learning algorithms:
      • Lasso: Classic Lasso regression model, implementing feature selection through L1 regularization
      • LightGBM: Efficient gradient boosting decision tree with a training engine optimized for large-scale datasets
      • MLP: Multi-layer perceptron neural network, suitable for modeling complex non-linear relationships
  • :robot: strategy: Strategy Research and Development

    • Quickly build quantitative trading strategies based on ML signal prediction models
    • Support for both cross-sectional multi-asset and time-series single-asset strategy types
  • :microscope: lab: Research Process Management

    • Integrates complete workflow including data management, model training, signal generation, and strategy backtesting
    • Simple API design with built-in visualization analysis tools for intuitive evaluation of strategy performance and model effectiveness
  • :book: notebook: Quantitative Research Demo

    • download_data_rq: Download A-share index constituent stock data based on RQData, including index constituent tracking and historical market data retrieval
    • download_data_xt: Download A-share index constituent historical changes and stock K-line data based on XtQuant data service
    • research_workflow_lasso: Quantitative research workflow based on Lasso regression model, demonstrating feature selection and prediction capability of linear models
    • research_workflow_lgb: Quantitative research workflow based on LightGBM gradient boosting tree, utilizing efficient ensemble learning methods for prediction
    • research_workflow_mlp: Quantitative research workflow based on multilayer perceptron neural network, demonstrating the application of deep learning in quantitative trading

The design concept of the vnpy.alpha module was inspired by the Qlib project, providing powerful AI quantitative capabilities while maintaining ease of use. We would like to express our sincere gratitude to the Qlib development team!

Functional Features

Modules marked with :arrow_up: have completed the upgrade compatibility testing for version 4.0. Additionally, the 4.0 core framework uses an upgrade approach that prioritizes compatibility, so most modules can also be used directly (interfaces involving C++ API encapsulation must be upgraded before use).

  1. :arrow_up: Multi-functional quantitative trading platform (vnpy.trader) that integrates various trading interfaces and provides simple and easy-to-use APIs for specific strategy algorithm and function development, for quickly building quantitative trading applications required by traders.

  2. Trading interfaces (vnpy.gateway) covering all domestic and international trading varieties:

    • Domestic market

      • :arrow_up: CTP (ctp): Domestic futures and options

      • :arrow_up: CTP Mini (mini): Domestic futures, options

      • :arrow_up: CTP Securities (sopt): ETF options

      • :arrow_up: FEMAS (femas): Domestic futures

      • :arrow_up: Esunny (esunny): Domestic futures, Gold TD

      • :arrow_up: APEX HTS (hts): ETF options

      • :arrow_up: XTP (xtp): Domestic securities (A shares), ETF options

      • :arrow_up: TORA (tora): Domestic securities (A shares), ETF options

      • OST (ost): Domestic securities (A shares)

      • EMT (emt): Domestic securities (A shares)

      • SGIT (sgit): Gold TD, domestic futures

      • :arrow_up: KsGold (ksgold): Gold TD

      • :arrow_up: LStar (lstar): Futures asset management

      • :arrow_up: Rohon (rohon): Futures asset management

      • :arrow_up: Jees (jees): Futures asset management

      • ComStar (comstar): Interbank market

      • :arrow_up: TTS (tts): Domestic futures (simulation)

    • Overseas market

      • :arrow_up: Interactive Brokers (ib): Global securities, futures, options, forex, etc.

      • :arrow_up: Esunny 9.0 (tap): Global futures

      • :arrow_up: Direct Futures (da): Global futures

    • Special Applications

      • :arrow_up: RQData Market Data (rqdata): Cross-market (stocks, indices, ETFs, futures) real-time market data

      • :arrow_up: XtQuant Market Data (xt): Cross-market (stocks, indices, convertible bonds, ETFs, futures, options) real-time market data

      • :arrow_up: RPC service (rpc): Inter-process communication interface for distributed architecture

  3. Out-of-the-box trading applications for various quantitative strategies (vnpy.app):

    • :arrow_up: cta_strategy: CTA strategy engine module, which allows users to perform fine-grained control over the order management during the operation of CTA-type strategies while maintaining ease of use (reducing trading slippage, implementing high-frequency strategies)

    • :arrow_up: cta_backtester: CTA strategy backtester module, no need to use Jupyter Notebook, directly use the graphical interface to carry out strategy backtesting analysis, parameter optimization and other related work

    • :arrow_up: spread_trading: Spread trading module, supports custom spreads, real-time calculation of spread quotes and positions, supports semi-automatic spread algorithm trading and fully automatic spread strategy trading modes

    • :arrow_up: option_master: Option trading module, designed for the domestic options market, supports various option pricing models, implied volatility surface calculation, Greek value risk tracking and other functions

    • :arrow_up: portfolio_strategy: Portfolio strategy module, designed for trading multi-contract quantitative strategies (Alpha, option arbitrage, etc.) simultaneously, providing historical data backtesting and live automatic trading functions

    • :arrow_up: algo_trading: Algorithm trading module, providing various commonly used intelligent trading algorithms: TWAP, Sniper, Iceberg, BestLimit, etc.

    • :arrow_up: script_trader: Script strategy module, designed for multi-asset portfolio trading strategies and computational tasks, also can directly achieve REPL instruction trading in the command line, does not support backtesting functions

    • :arrow_up: paper_account: Simulation trading module, pure localized implementation of simulation trading functions, based on real-time quotes obtained from the trading interface for order matching, providing order execution pushing and position records

    • :arrow_up: chart_wizard: K-line chart module, based on RQData data service (futures) or trading interface to obtain historical data, and combined with Tick push to display real-time market changes

    • :arrow_up: portfolio_manager: Portfolio module, for various fundamental trading strategies, based on separate strategy sub-accounts, providing automatic tracking of trading positions and real-time profit and loss statistics

    • :arrow_up: rpc_service: RPC service module, allowing a VeighNa Trader process to be started as a server, serving as a unified routing channel for quotes and trades, allowing multiple clients to connect simultaneously, realizing a multi-process distributed system

    • :arrow_up: data_manager: Historical data management module, view existing data in the database through a tree directory, select any time period data to view field details, supports CSV file data import and export

    • :arrow_up: data_recorder: Market data recording module, based on the graphical interface for configuration, records Tick or K-line data to the database in real-time according to demand, for strategy backtesting or live initialization

    • :arrow_up: excel_rtd: Excel RTD (Real Time Data) real-time data service, based on pyxll module to achieve real-time push updates of various data (quotes, contracts, positions, etc.) in Excel

    • :arrow_up: risk_manager: Risk management module, providing statistics and restrictions on rules including trade flow control, number of orders placed, active orders, total number of cancelled orders, etc., effectively implementing front-end risk control functions

    • :arrow_up: web_trader: Web service module, designed according to the requirements of B-S architecture, implementing a web server that provides active function calls (REST) and passive data push (WebSocket)

  4. Python trading API interface package (vnpy.api), providing the underlying implementation of the above trading interfaces:

    • :arrow_up: REST Client (rest): High-performance REST API client based on coroutine process asynchronous IO which adopts the programming model of event me

Core symbols most depended-on inside this repo

add_feature
called by 121
vnpy/alpha/dataset/template.py
calculate_by_expression
called by 101
vnpy/alpha/dataset/utility.py
connect
called by 43
vnpy/trader/engine.py
join
called by 23
vnpy/rpc/client.py
create_label
called by 22
vnpy/trader/ui/widget.py
_as_series
called by 22
vnpy/alpha/dataset/utility.py
result
called by 19
vnpy/alpha/dataset/utility.py
register
called by 18
vnpy/rpc/server.py

Shape

Method 654
Function 115
Class 105

Languages

Python100%

Modules by API surface

tests/test_alpha101.py103 symbols
vnpy/trader/ui/widget.py102 symbols
vnpy/trader/engine.py77 symbols
vnpy/trader/utility.py73 symbols
vnpy/chart/widget.py38 symbols
vnpy/trader/object.py35 symbols
vnpy/alpha/strategy/backtesting.py32 symbols
vnpy/alpha/dataset/utility.py29 symbols
vnpy/chart/item.py24 symbols
vnpy/alpha/strategy/template.py24 symbols
vnpy/trader/gateway.py23 symbols
vnpy/alpha/lab.py23 symbols

Dependencies from manifests, versioned

PySide66.8.2.1 · 1×
deap1.4.2 · 1×
loguru0.7.3 · 1×
nbformat5.10.4 · 1×
numpy2.2.3 · 1×
pandas2.2.3 · 1×
plotly6.0.0 · 1×
pyqtgraph0.13.7 · 1×
pyzmq26.3.0 · 1×
qdarkstyle3.2.3 · 1×
qrcode7.4.2 · 1×
requests2.32.0 · 1×

For agents

$ claude mcp add vnpy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact