josephchenhk / markets

A small program for backtesting (aka time series cross-validation)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

markets

Git configuration

Configuring a remote for a folk

$ git remote -v # list current configured remote repository for your fork
$ git remote add upstream https://github.com/tbrown122387/markets
$ git remote -v # Verify the new upstream repository you've specified for your fork

Syncing a fork

$ git fetch upstream # Fetch commits and store it in local branch upstream/master
$ git checkout master # Check out your fork's local master branch
$ git merge upstream/master # Merge the changes from upstream/master into your local master

Description

markets is a small event-driven program that backtests trading strategies. It will show the outcome of any strategy can change based on

  • order types
  • market impact/slippage
  • initial wealth

getting started

The example trading strategy tries to maintain equal weights in each of ten instruments. To get started, do the following steps.

  1. to get the library and build it, type the following into a terminal:
git clone https://github.com/tbrown122387/markets.git
cd markets
mkdir bin
sh build_lib.sh
  1. after that, take a look at the example by running
cd example
make
./run_backtest

this will show you what the command line arguments need to be. If you want to run a specific backtest with the example trading strategy using our example data, replace the last line with the following:

./run_backtest 100000 weekly_etfs/ .05 20 market 0 0

If you want to save those results in a text file and analyze them with your favorite statistical software, type the following:

./run_backtest 100000 weekly_etfs/ .05 20 market 0 0 > ~/Desktop/wealth_snapshots.csv

The commissions are handled automatically inside the program. You can also simulate slippage by adjusting the third parameter.

tests

We also have unit tests to make sure everything works. Go into the test directory and type the following

make clean 
make
./run_tests

About

A small program for backtesting (aka time series cross-validation)


Languages

Language:C++ 96.3%Language:Makefile 2.5%Language:R 1.0%Language:Shell 0.2%