bzdww

Get answers and suggestions for various questions from here

Vn.trader Ubuntu runtime environment to build a tutorial

cms
I have been busy lately and have no time to write. The author of this is a business support company of the vn.py project. The article was published in Wien's party forum , the main content is about the vn.py project discussion and some quantitative industry-related recruitment information, may wish to take a look.

Prepare Ubuntu

It is recommended to use a new clean Ubuntu environment (if you must use the old environment, if you are unfortunate enough to fall back to this step), the environment I use here is as follows:

  • Version: Ubuntu 16.04 LTS
  • Language: Simplified Chinese
  • Time zone: Shanghai
  • Hardware: VirtualBox virtual machine (64-bit, 4G memory allocated)

Install Anaconda

Download Python 2.7 version of Linux 64-Bit Anaconda on Continuum website . The file after downloading here is Anaconda2-4.0.0-Linux-x86_64.sh.

Open Terminal, go to the directory where the file is located, and enter the following command:


bash Anaconda2-4.0.0-Linux-x86_64.sh

In addition to the last option, you can press Enter all the way to the last setting. If you want to add Anaconda to the PATH of bash, please choose yes. After the installation is successful, as shown below:

Next, restart the system, open Python after running Terminal, as shown in the following figure, the installation is successful (note that there is Anaconda related information in the top display):


Install other dependencies

Use pip to install MongoDB driver and Qt black theme, be careful not to add sudo:


pip install pymongo qdarkstyle

Use apt-get to install the API related tools:


sudo apt-get install git build-essential libboost-all-dev python-dev cmake

Run vn.trader

Use git to download the vn.py framework from Github:


git clone http://github.com/vnpy/vnpy.git

When finished, switch to the vn.trader folder (cd vnpy/vn.trader) and enter the command:


python vtMain.py

Dangdang ~~~~, the deep and introverted black main interface appeared:

Note that there are only CTP, LTS, and OANDA interfaces in the connection options under the menu bar system. This is because the Ubuntu version of vn.ctp and vn.lts is only compiled in the current project, and vn.oanda is pure Python based on REST API. Interfaces can be used directly across platforms.


to sum up

After trying to use Ubuntu, I have to admit that Linux is more friendly than Windows in programming. Users who have seen the vn.py Windows development environment build tutorial should remember that the steps are quite cumbersome (boost accounts for a considerable part), and Ubuntu There are basically only three steps: install Anaconda, pip, and apt-get. The pure command line operation is very cool.

After installing the above environment, users who want to toss their own API can enter the vn.ctp folder and type:


./build.sh

Then it is compiled, it is very cool (of course, when writing CMakeLists.txt is still very troublesome), the compiled interface is in the build/lib folder.