头图

WonderTrader2.png

Preface

Yesterday I see WonderTrader of star , actually has 400 +, and it is a bit contrary to the author's surprise, after all WonderTrader never had formal promotion. The author would like to express my sincere thanks to every friend WonderTrader
From the WonderTrader to now, for various reasons, the Linux under 061b6a932da829 have not kept up. Plus author Linux limited experience in the development of the next, so Linux version retained under a lot of problems. The Linux use under gcc compiled, at the time the link, and does not check whether all symbolic links are successful, resulting in many problems can only be checked out at run time.
Just recently, a friend wanted to change wtpy to cython version wtcy . It needs mingw environment, and there are also some requirements for the underlying adaptation. A long time ago, some users put forward the request of Clion compilation to the author, but at that time, the author did not advance because of the busy work.
Some time ago, I took this opportunity to sort out all the codes related to cross-platform compilation. So there is the MinGW Environment Compilation WonderTrader Strategy ".

The main content of this paper is describes the process using MinGW compiled WonderTrader source code under Windows .

MinGW-w64 Environmental preparation

The first thing to install is MinGW-w64

  • MinGW-w64 official website of 061b6a932da95f and click to download
    MinGW-w64下载
  • Select MinGW-w64-build and open
    选择MinGW-w64-builds
  • Then jump to Sourceforge start downloading
    跳转到Souceforge开始下载
  • The pop-up download dialog box selects the path where the installation file is stored
    开始下载MinGW-w64安装程序
  • After the download is complete, run the installer
    运行安装程序
  • Setting items should be noted: thread model Threads should select posix , otherwise the compilation of boost will fail. Then click "Next" to start downloading
    配置选项
  • After the installation is complete, open the installation library, double-click to run mingw-w64.bat
    运行mingw-w64.bat
  • In the opened console, execute the following command. If the version number of GCC MinGW environment is successful

    $ gcc -v

    测试gcc

Three party library compilation

WonderTrader has tried to reduce dependencies, there are still some indispensable dependent libraries. The author has provided pre-compiled dependency libraries vs2017 , ubuntu18.04 , centos7 and centos8 in the shared network disk before. But MinGW is a new compilation environment, so the dependent library still needs to be recompiled.
The author's consistent style is: third-party library can be statically linked, never dynamic link . The advantage of this is that the final release package does not require so many additional dynamic libraries, and the disadvantage is that the final compiled file is relatively large. The compilation methods described below are all output static libraries.
Before compiling, and to MSVC compiler environment, the need to create a new environment variable MyDependsGcc , and set the value of dependent libraries save directory, such as E: \ mingw9deps. include subdirectory can directly copy include directory of the MSVC dependent library. The .a lib subdirectory needs to be compiled and generated according to the steps described below.

Compile boost 1.72.0

boost library for C++ developers does not need me to say much, boost is actually more convenient. WonderTrader depends on the version 1.72.0 .

  • First run bootstrap.bat b2.exe program will be automatically generated.
  • Then execute the command line in the boost

    $ b2.exe --build-type=minimal --with-chrono --with-date_time --with-filesystem --with-regex --with-thread toolset=gcc architecture=x86 address-model=64 variant=release link=static threading=multi stage

    boost编译

  • After having compiled to stage/lib where you can see the generated .a files
    boost编译
  • Finally, remove the tail "-mgw81-mt-x64-1_72" of the .a E:\mingw9deps\lib directory

nanomsg 1.1.5

nanomsg is the WonderTrader , encapsulated in the WtMsgQue module, as the core message queue component that WonderTrader WonderTrader uses the version 1.1.5 . Readers can download it by themselves or download it from a shared cloud disk.

  • After decompression, open the CMakeLists.txt file
    打开CMakeLists.txt
  • According to the screenshot below, change NN_STATIC_LIB to ON , and all other items to OFF
    修改配置选项
  • Use the cmake command to generate makefile

    $ cmake -G "MinGW Makefiles"

    执行cmake

  • Finally execute the mingw32-make command to generate nanomsg
    生成nanomsg
  • After completion of generation, will libnanomsg.a copied to E:\mingw9deps\lib directory

curl 7.70

curl is a library that is very frequently used. WonderTrader itself does not rely on curl , but the trading API of Yisheng, the author originally had a second authorization mechanism when docking foreign futures, which needed to be transferred through the mailbox. The second authorization code, so curl is used. curl API, you don’t actually need to compile 061b6a932dae2b. WonderTrader uses the version 7.70 .

  • curl is relatively simple, you only need to enter the lib , execute the following command, and wait for the compilation to end.

    $ mingw32-make -f Makefile.m32

    编译libcurl

  • After having compiled the lib directory libcurl.a copied to E:\mingw9deps\lib directory

dlfcn-win32 1.3.0

dlfcn is built-in under Linux , which is the dl module. But the dl module is not built-in in the MinGW environment, so you need to compile the implementation of Windows dlfcn

  • Write config.mak file

    BUILD_STATIC=yes
    CC=gcc
    AR=ar
    RANLIB=ranlib

    编写config

  • Execute the mingw32-make command to compile
    编译dlfcn
  • The resulting libdl.a copied to E:\mingw9deps\lib directory, dlfcn.h copied to E:\mingw9deps\include directory

Pre-compiled library download

After introducing the compilation method of each dependent library, the author also provides a pre-compiled package, which you can download by yourself according to your needs.
共享网盘
Shared network disk link:
https://pan.baidu.com/s/1Bdxh_PgjqHMzuGjl9ernhg
Extraction code: d6bh

Clion+MinGW configuration

Clion is 061b6a932db02a that has become popular in recent years and is IDE by JetBrains . In recent years, many people have started to use Clion develop the C++ program. The author will briefly introduce how Clion configures the MinGW compilation environment to compile WonderTrader .
Clion , the author will not repeat it here. It is worth mentioning that Clion is a commercial software for a fee, it provides free accounts for open source project participants. The author also applies for a free account in this way.

  • Open WonderTrader source directory src , Clion will automatically parse CMakeLists.txt as a solution
    打开WonderTrader工程
  • File menu, select Setting to configure, and select the configuration Toolchains in the pop-up window. Clion will automatically scan the MinGW environment. If MinGW is not the default, move it to the first one and set it as the default so that the compilation environment of MinGW
    配置Toolchains
  • Then configure the compilation mode in the CMake tab, the default is Debug
    CMake配置项
  • After completing the above settings, select Build Project command in the Build menu to start generating the entire project
    Build Project
    Clion编译完成

VSCode+MinGW configuration

Similarly, we can also in VSCode use MinGW compiled WonderTrader .

  • First of all, we need VSCode , as shown in the figure below. CMake Tools is a core plug-in, and the calling methods for subsequent compilation and configuration are provided by this plug-in.
    插件安装
  • After the plug-in is installed, an operation button will appear in the status bar. First, you need to select the compilation component, as shown in the figure below:
    选择编译组件
  • After selecting the compilation components, configure the compilation mode to be Debug or Release
    选择编译模式
  • Finally, click the " Build " button to start building the entire project
    开始生成
    生成结束

Some tips

The previous MinGW WonderTrader under the 061b6a932db2ae environment does not seem difficult, and it is actually the same. WonderTrader It turns out that many codes have some problems in cross-platform compatibility, so the author seemed very embarrassed when tossing, but at the same time, the author also learned a lot.

  • For example, originally Windows was developed only with MSVC , but the GCC compiler was only used on Linux , so many conditional compilation instructions in the code such as:

    #IF _WIN32
    //...
    #ELSE _UNIX
    //...
    #ENDIF 

    In the original WonderTrader, it can be equivalent to:

    #IF _MSC_VER
    //...
    #ELSE _GNUC
    //...
    #ENDIF 

    After reorganizing this time, the conditional compilation related to the compiler is completely separated from the conditional compilation related to the platform.

  • GCC compiled object file compared to MSVC compiled object file to be much larger. The author estimates that MinGW is a simulated Linux environment after all, and cannot directly reference the Windows , so many dependencies must all be compiled into the target file.
  • MinGW compilation speed of MSVC is much slower than that of 061b6a932db389, and the time spent is basically more than twice MSVC
  • GCC in Windows when the link under, or to check whether dependency links all successful, so can you find some problems related dependencies during compilation.
  • In short, I still do not suggest that you MinGW environment compiled WonderTrader , after all MSVC with them is not bad.

Concluding remarks

WonderTrader has been open source for about 20 months. The author is very happy that more and more people pay attention to WonderTrader , use WonderTrader , and more and more people participate in the 161b6a932db40 The author also met many new friends WonderTrader
Recently, many friends asked me commercialization plan of 161b6a932db429 WonderTrader , but the author did not think too much. WonderTrader is an open source project, and it is a quantitative platform that has already carried out large-scale real trading, and the core part is very stable. WonderTrader will improve the future direction of application scenarios, and it is difficult to reconstruct the core part. So I think that everyone should not worry about WonderTrader will erode the functions of the open source part if it is commercialized, because WonderTrader is no longer reserved.

Finally, another wave of ads

161b6a932db458 github : https://github.com/wondertrader/wondertrader

WonderTrader official website address: https://wondertrader.github.io

161b6a932db489 github : https://github.com/wondertrader/wtpy


WonderTrader2.png


WonderTrader
31 声望23 粉丝