Code Monkey home page Code Monkey logo

hftbattle's Introduction

Off-line development package

We have prepared an off-line C++ and Python strategy development package. It has a kit containing libraries and files that are sufficient to develop and test strategies on your computer.

Download it using the following command (Git must be installed):

git clone https://github.com/hftbattle/hftbattle.git

More on how to use Off-line Development Package:

Dependency management

Here you can find dependency management suggestions for the following operating systems:

Ubuntu

Run packages_ubuntu.sh to install dependencies:

sudo ./packages_ubuntu.sh

The script installs g++, CMake and Python 2:

sudo apt-get update && sudo apt-get install g++ cmake python --yes

macOS

Run packages_mac.sh to install dependencies:

./packages_mac.sh

The script installs:

  • Apple LLVM compiler (you can find detailed installation instruction here):

    xcode-select --install
  • Homebrew package manager:

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • CMake, JsonCpp and Python 2:

    brew install cmake jsoncpp python

Windows

It's essential to have the following to run local pack under Windows:

  • TDM64-GCC compiler at least version 5.1.0:

    You may download it here. Note that you need TDM64-gcc.

  • CMake at least version 2.8.4:

    You may install CLion, or download CMake from the official website.

  • Python 2.7:

    You may download it here.

Make sure that paths to cmake.exe, python.exe, g++.exe and mingw32-make.exe/make.exe are added to PATH environment variable.

Market data

The package repository contains a data folder with the first several hours of market data (configuration file line "day": "2016.09.02") of the trading symbol.

That's enough to:

  • make sure your code compiles successfully
  • debug your strategy

To check out the core ideas of the strategy you may download data for a complete trading day "2016.09.01" from here.

You may do it manually: just unzip the file into the root directory or use download.py script from the repository root.

./download.py

The script will download the file data.zip and unzip it into the data folder.

To test the strategy on the complete trading day you should change the value of the field day to "2016.09.01" in the configuration file.

Execution of your strategy

This chapter describes execution of your strategy:

We will assume, that your strategy and folder are called user_strategy. Read here about creating new strategies.

Execution in command line

You need to:

  • compile all the strategies you have:

    ./build.py

    This will create libraries for your strategies in the build folder.

  • run a simulation.

    ./run.py user_strategy

CLion usage

To launch simulation in CLion you need to:

  • specify executable file:

    open Run > Edit configurations, specify executable file in the root of directory as Executable:

    • mac_launcher for macOS
    • windows_launcher for Windows
    • linux_launcher for Linux
  • specify path to your configuration file in the arguments of command line:

    in the same tab Run > Edit configurations you need to fill Program arguments with relative path to configuration file of your strategy. For example:

    strategies/user_strategy/user_strategy.json
  • start building the project and simulating strategy by pressing Run button.

Strategy adding

Once you decide to try more ideas and develop more strategies, using the one strategy - one file approach may become neccessary. Let’s have a look at how to add new strategies in the off-line development package.

Creating a new C++ strategy

1. Create a strategy folder

  • In the strategies folder create a copy of the sample_strategy folder
  • Choose a name of your strategy.

Let’s call it strategy_name.

  • Rename the new folder with json and cpp files inside with the strategy_name, strategy_name.json, strategy_name.cpp respectively.

2. Register your strategy

Once the files are copied you need to edit cpp file.

Register your new strategy with the following command at the end of the cpp file:

REGISTER_CONTEST_STRATEGY(UserStrategy, strategy_name)

Let’s say your folder, .json-file and the strategy are called best_strategy_ever. You will therefore need to add the following line at the end of the file best_strategy_ever.cpp:

REGISTER_CONTEST_STRATEGY(UserStrategy, best_strategy_ever)

This is necessary due to specifics of the simulator’s dynamic linkage process of the strategies.

3. Update CMake configuration

  • Those of you who work in cli run the following script build.py:
    ./build.py
  • Those working in CLion, go to Tools > CMake > Reload CMake Project.

Creating a new Python strategy

Unfortunately, there is currently no way to create new folders for Python strategies. Please write your strategy in the strategies/python_strategy/python_strategy.py file. You may find out here how to run the strategy.

hftbattle's People

Contributors

nmakeenkov avatar agul avatar mathbunnyru avatar wasylf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.