Open source quantitative trading research framework based on C++/Python

Open source quantitative trading research framework based on C++/Python

2022-09-05 0 1,193
Resource Number 38056 Last Updated 2025-02-24
¥ 0USD Upgrade VIP
Download Now Matters needing attention
Can't download? Please contact customer service to submit a link error!
Value-added Service: Installation Guide Environment Configuration Secondary Development Template Modification Source Code Installation

This issue recommends hikyuu, an open source quantitative trading research framework based on C++Python.

Open source quantitative trading research framework based on C++/Python插图

Hikyuu is a high performance open source quantitative trading research framework based on C++/Python for strategy analysis and backtesting (currently used in the domestic securities market). Its core idea is based on the current mature systematic trading method, the entire systematic trading is abstracted into seven components: market environment judgment strategy, system effective condition, signal indicator, stop loss/stop profit strategy, fund management strategy, profit target strategy, slip spread algorithm. You can build the strategic asset library of these components respectively. In practical research, they are combined freely to observe the effectiveness, stability and effect of a single type of strategy.

Advantages of Hikyuu

1. The combination is flexible and the strategic asset library is constructed by classification : Hikyuu has carried out a good abstraction of the systematic trading method, including nine strategic components: Market environment judgment strategy, system effective condition, signal indicator, stop loss/stop profit strategy, fund management strategy, profit target strategy, sliding spread algorithm, trading object selection strategy, fund allocation strategy. On this basis, you can build your own policy library, and perform flexible combination and testing. When conducting strategy exploration, we can pay more attention to the performance and impact of a certain aspect of the strategy. Its main functional modules are as follows:

Open source quantitative trading research framework based on C++/Python插图1

2. Performance guarantee, create your own exclusive application : The current project contains three main components: core library based on C++, Python library wrapped in C++ (hikyuu), interactive tools based on Python.

  • C++ core library, provides the overall policy framework, while ensuring performance, has considered the support for multi-threading and multi-core processing, in the future to pursue higher computing speed to provide convenience. C++ core library, you can separate use, build their own client tools.
  • Python library (hikyuu), provides the packaging of C++ library, while integrating talib library (such as TA_SMA, corresponding to talib.sma), can be converted with numpy, pandas data structure. It is convenient to use other mature python data analysis tools.
  • hikyuu.interactive Interactive exploration tool, which provides basic mapping functions of K-lines, indicators, system signals, etc., for exploration and backtesting of quantitative strategies.

3. multi-paradigm support, more convenient and free to explore : support both object-oriented and command line programming paradigm. Among them, the command line is more simple, convenient, and free for policy exploration.

4. data storage is extensible : Currently supports local HDF5 format and MySQL storage. HDF5 is used by default, and the data file size is small, the speed is faster, and the backup is convenient.

Example

# Create a mock trading account for backtesting, initial capital of 300,000 
my_tm = crtTM(init_cash = 300000)

# Create a signal indicator (the 5-day EMA is the fast line, the 5-day EMA itself is the 10-day EMA slowest line, buy when the fast line crosses the slow line upward, sell vice versa) 
my_sg = SG_Flex(OP(EMA(n=5)), slow_n=10)

# Fixed buying 1000 shares at a time 
my_mm = MM_FixedCount(1000)

# Create trading system and run 
sys = SYS_Simple(tm = my_tm, sg = my_sg, mm = my_mm)
sys.run(sm['sz000001'], Query(-150))

Open source quantitative trading research framework based on C++/Python插图2

Complete reference:
https://nbviewer.org/github/fasiondog/hikyuu/blob/master/hikyuu/examples/notebook/000-Index.ipynb?flush_cache=True

Installation

  • Preparation before installation

Supported operating system: 64-bit Windows7 and above version, Linux please use the source code to compile and install.

Python environment: > = Python3.5

< p data – track = “34” > note: it is recommended to install package integrates common data science Python release: Anaconda (https://www.anaconda.com/). Domestic users advice from tsinghua mirror site < a class = “PGC – link” href = “https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/” target = “_blank” rel=”noopener noreferrer” data-content=”mp” data-source=”outerLink”>anaconda | The mirror station help| The mirror station | Tsinghua Open Source Mirror Download.

  • pip installation

Installation:

pip install hikyuu

Version upgrade:

pip install hikyuu -U

Note:

1. The talib package cannot be installed in Windows by pip
Download the corresponding wheel package from https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib/ and install it manually.

2. Linux needs to install dependent libraries: libhdf5, libmysqlclient, libsqlite3

Getting started

  • Download data to start

Note: The data download tool needs to use the unrar command. In Linux, install unrar.

pip After Hikyuu is installed, run the hikyuutdx command in the command line terminal to start the data download tool, and download the data as prompted:

Open source quantitative trading research framework based on C++/Python插图3

Note: If the HikyuuTDX command cannot be executed in the command line terminal, go to the Scripts subdirectory in the python installation directory and select the execution file (hikyuutdx.exe).

If you do not want to download the file using the GUI, run the importdata command on the CLI, as shown in the following figure:

Open source quantitative trading research framework based on C++/Python插图4

Note: Because the importdata command uses the configuration file generated by HikyuuTDX, you need to run HikyuuTDX at least once before you execute importdata for the first time.

  • Learn through code examples

You can access the latest code examples from the following URL, which will help you gradually understand and master the use of Hikyuu and the related concepts of systematic trading. During the daily use of Hikyuu, you can find detailed descriptions of the corresponding built-in indicators, policies, and functions in this help to obtain more information.

https://nbviewer.jupyter.org/github/fasiondog/hikyuu/blob/master/hikyuu/examples/notebook/000-Index.ipyn b?flush_cache=True

The above sample code is edited and run using a Jupyter notebook, you can download the sample code from the top right corner of each sample URL and run it directly in the Jupyter notebook open.

Open source quantitative trading research framework based on C++/Python插图5

or find all the examples from “examples/notebook” in the installation directory.

Open source quantitative trading research framework based on C++/Python插图6

If you are not used to using Jupyter notebook, you can also use your favorite Python client tools (such as shell, Spyder, PyCharm, idle, etc.) and learn to run according to the sample code.

  • Run from Python Shell

You can run Hikyuu using any Python client tool. As shown in the following figure, run hikyuu in a Python shell environment in cmd. When copying code from the above example, should be careful to remove code that starts with a “%”, such as “%time” , these are ipython magic code that only works in ipython environments, not normal shells.

Open source quantitative trading research framework based on C++/Python插图7

To run the Hikyuu interactive tool, you need to introduce it first, as follows:

# To use hikyuu in an interactive environment, the first need to introduce hikyuu interactive tools 
from hikyuu.interactive.interactive import  *

Note: Hikyuu itself is a normal Python package, while
Hikyuu. Interactive. Interactive for hikyuu package contains an interactive tool. If you want to develop your own other programs based on the hikyuu package instead of using it as an interactive program, you can refer to it
Hikyuu/interactive/interactive. Py hikyuu normal initialization.

    • Edit and run

with Jupyter notebook

To start Jupyter notebook, just enter the desired working directory in cmd and type the Jupyter notebook command, as shown below:

Open source quantitative trading research framework based on C++/Python插图8

The above command will start the local web service. At this time, you can open a browser (Chrome or Firefox is recommended) and enter the following address:
http://127.0.0.1:8888/tree according to the menu commands in the interface can be like normal code editor editing and running the code.

Open source quantitative trading research framework based on C++/Python插图9

You can read more on your own.

Disclaimer: This article is published by a third party and represents the views of the author only and has nothing to do with this website. This site does not make any guarantee or commitment to the authenticity, completeness and timeliness of this article and all or part of its content, please readers for reference only, and please verify the relevant content. The publication or republication of articles by this website for the purpose of conveying more information does not mean that it endorses its views or confirms its description, nor does it mean that this website is responsible for its authenticity.

Ictcoder Free source code Open source quantitative trading research framework based on C++/Python https://ictcoder.com/kyym/open-source-quantitative-trading-research-framework-based-on-c-python.html

Share free open-source source code

Q&A
  • 1, automatic: after taking the photo, click the (download) link to download; 2. Manual: After taking the photo, contact the seller to issue it or contact the official to find the developer to ship.
View details
  • 1, the default transaction cycle of the source code: manual delivery of goods for 1-3 days, and the user payment amount will enter the platform guarantee until the completion of the transaction or 3-7 days can be issued, in case of disputes indefinitely extend the collection amount until the dispute is resolved or refunded!
View details
  • 1. Heptalon will permanently archive the process of trading between the two parties and the snapshots of the traded goods to ensure that the transaction is true, effective and safe! 2, Seven PAWS can not guarantee such as "permanent package update", "permanent technical support" and other similar transactions after the merchant commitment, please identify the buyer; 3, in the source code at the same time there is a website demonstration and picture demonstration, and the site is inconsistent with the diagram, the default according to the diagram as the dispute evaluation basis (except for special statements or agreement); 4, in the absence of "no legitimate basis for refund", the commodity written "once sold, no support for refund" and other similar statements, shall be deemed invalid; 5, before the shooting, the transaction content agreed by the two parties on QQ can also be the basis for dispute judgment (agreement and description of the conflict, the agreement shall prevail); 6, because the chat record can be used as the basis for dispute judgment, so when the two sides contact, only communicate with the other party on the QQ and mobile phone number left on the systemhere, in case the other party does not recognize self-commitment. 7, although the probability of disputes is very small, but be sure to retain such important information as chat records, mobile phone messages, etc., in case of disputes, it is convenient for seven PAWS to intervene in rapid processing.
View details
  • 1. As a third-party intermediary platform, Qichou protects the security of the transaction and the rights and interests of both buyers and sellers according to the transaction contract (commodity description, content agreed before the transaction); 2, non-platform online trading projects, any consequences have nothing to do with mutual site; No matter the seller for any reason to require offline transactions, please contact the management report.
View details

Related Article

make a comment
No comments available at the moment
Official customer service team

To solve your worries - 24 hours online professional service