Hikyuu Quant Framework is an open source quantitative trading research framework based on C++/Python, used for strategy analysis and backtesting (currently mainly used in the domestic A-share market). Its core idea is based on the current mature systematic trading method, abstracting the entire systematic trading into seven components: strategy, system effective conditions, signal indicator, stop loss/take profit strategy, capital management strategy, profit target strategy, and slip spread algorithm. You can build a strategic asset library of these components separately, and freely combine them in actual research to observe the effectiveness, stability of the system and the effectiveness of a single type of strategy.
Project address:
- https://github.com/fasiondog/hikyuu
- https://gitee.com/fasiondog/hikyuu
- https://gitcode.com/hikyuu/hikyuu
Project homepage: https://hikyuu.org/
Help documentation: https://hikyuu.readthedocs.io/zh-cn/latest/index.html
Getting started: https://nbviewer.org/github/fasiondog/hikyuu/blob/master/hikyuu/examples/notebook/000-Index.ipynb?flush_cache=True
Policy component library: https://gitee.com/fasiondog/hikyuu_hub
Thanks to the Hikyuu Ubuntu virtual machine environment provided by netizens, Baidu Netdisk download (extraction code: https://pan.baidu.com/s/1CAiUWDdgV0c0VhPpe4AgVw?pwd=ht8j
Example:
#创建模拟交易账户进行回测,初始资金30万
my_tm = crtTM ( init_cash = 300000 )
#创建信号指示器(以5日EMA为快线,5日EMA自身的10日EMA作为慢线,快线向上穿越慢线时买入,反之卖出)
my_sg = SG_Flex ( EMA ( CLOSE (), n = 5 ), slow_n = 10 )
#固定每次买入1000股
my_mm = MM_FixedCount ( 1000 )
#创建交易系统并运行
sys = SYS_Simple ( tm = my_tm , sg = my_sg , mm = my_mm )
sys . run ( sm [ 'sz000001' ], Query ( - 150 ))
See the full example: https://nbviewer.jupyter.org/github/fasiondog/hikyuu/blob/master/hikyuu/examples/notebook/000-Index.ipynb?flush_cache=True
Why choose Hikyuu?
- The combination is flexible and the strategy asset library is constructed in a classified manner . Hikyuu has made a good abstraction of the systematic trading method, including nine strategic components: market environment judgment strategy, system effective conditions, signal indicator, stop loss/take profit strategy, capital management strategy, profit target strategy, slip spread algorithm, trading object selection strategy, and capital allocation strategy. You can build your own strategy library on this basis and perform flexible combinations and testing. When exploring strategies, you can focus more on the performance and impact of a certain aspect of the strategy. Its main functional modules are as follows:

- Performance guarantee, create your own exclusive application. Currently, the project contains 3 main components: a core library based on C++, a Python library (hikyuu) that wraps C++, and an interactive tool based on Python.
- AMD 7950x Test: The entire A-share market (19.13 million daily K-line) only loads all daily lines to calculate the 20-day MA and finds the final MA accumulation sum. The first execution of data loading takes 6 seconds, and the calculation takes 166 milliseconds after data loading is completed. See: Performance Test
- The C++ core library provides an overall strategy framework. While ensuring performance, it has considered support for multi-threading and multi-core processing, and provides convenience for higher computing speeds in the future. The C++ core library can be separated and used separately and build your own client tools.
- The Python library (hikyuu) provides packaging for C++ libraries, and integrates the talib library (such as TA_SMA, corresponding to talib.SMA), which can be converted with numpy and pandas data structures, providing convenience for the use of other mature python data analysis tools.
- hikyuu.interactive interactive exploration tool provides basic drawing functions of K-lines, indicators, system signals, etc., for exploration and backtesting of quantitative strategies.
- The code is concise, and it is more convenient and free to explore . It also supports object-oriented and command-line programming paradigms. Among them, when the command line explores strategy, the code is concise, more convenient and free.
- Security, freedom, and privacy, build your own exclusive cloud quantization platform. Combining the powerful capabilities of Python + Jupyter and cloud servers, you can build your own exclusive cloud quantization platform. Deploy Jupyter on a cloud server, access your own cloud platform anytime, anywhere, and immediately realize your new ideas, as shown in the figure below to access your own cloud platform through your mobile phone. Combining Python's powerful and mature data analysis and artificial intelligence tools (such as numpy, scipy, pandas, and TensorFlow) to build a more powerful artificial intelligence platform.
- The data storage method is extensible. Currently, it supports local HDF5 format and MySQL storage. HDF5 is used by default, and the data files are small in size, faster in speed and more convenient in backup. As of April 21, 2017, the Shanghai Stock Exchange daily data file 149M, Shenzhen Stock Exchange daily data file 184M, and the 5-minute line data each have less than 2G.
Want to learn more about Hikyuu? Please use the following methods to contact:
Join the knowledge planet
More examples sharing with programmatic transactions (your join will be considered a donation to the project). The author only guarantees that he/she will answer questions and answers to users of Knowledge Planet, and other channels will depend on the situation. (Coupons may be issued from time to time at the end of the official account article)

Follow the official account:

Join the WeChat group (please indicate "Join hikyuu"):

QQ communication group: 114910869, or scan the code to join

Project dependency instructions
Hikyuu directly relies on the following open source projects (projects that are indirectly depended by the following projects) and thanks to all open source authors for their contributions:
| name | Project gallery | License |
|---|
| xmake | https://github.com/xmake-io/xmake | Apache 2.0 |
| hdf5 | https://github.com/HDFGroup/hdf5 | hdf5 license |
| mysql(client) | https://github.com/mysql/mysql-server | mysql license |
| fmt | https://github.com/fmtlib/fmt | fmt license |
| spdlog | https://github.com/gabime/spdlog | MIT |
| sqlite | https://www.sqlite.org/ | sqlite license |
| flatbuffers | https://github.com/google/flatbuffers | Apache 2.0 |
| nng | https://github.com/nanomsg/nng | MIT |
| nlohmann_json | https://github.com/nlohmann/json | MIT |
| boost | https://www.boost.org/ | Boost Software License |
| python | https://www.python.org/ | Python license |
| pybind11 | https://github.com/pybind/pybind11 | pybind11 license |
| gzip-hpp | https://github.com/mapbox/gzip-hpp | BSD-2-Clause license |
| doctest | https://github.com/doctest/doctest | MIT |