Giter VIP home page Giter VIP logo

imc-prosperity-2-backtester's Introduction

IMC Prosperity 2 Backtester

Build Status PyPI Version

This repository contains a backtester IMC Prosperity 2 algorithms. The output it generates closely matches the format of the output generated by the official submission environment and is therefore compatible with my IMC Prosperity 2 Visualizer (assuming your code contains the visualizer's required prerequisites as explained on the visualizer's homepage).

Usage

Basic usage:

# Install the latest version of the backtester
$ pip install -U prosperity2bt

# Run the backtester on an algorithm using all data from round 0
$ prosperity2bt <path to algorithm file> 0

Run pip install -U prosperity2bt again when you want to update the backtester to the latest version.

Some more usage examples:

# Backtest on all days from round 1
$ prosperity2bt example/starter.py 1

# Backtest on round 1 day 0
$ prosperity2bt example/starter.py 1-0

# Backtest on round 1 day -1 and round 1 day 0
$ prosperity2bt example/starter.py 1--1 1-0

# Backtest on all days from rounds 1 and 2
$ prosperity2bt example/starter.py 1 2

# You get the idea

# Merge profit and loss across days
$ prosperity2bt example/starter.py 1 --merge-pnl

# Automatically open the result in the visualizer when done
# Assumes your algorithm logs in the visualizer's expected format
$ prosperity2bt example/starter.py 1 --vis

# Write algorithm output to custom file
$ prosperity2bt example/starter.py 1 --out example.log

# Backtest on custom data
# Requires the value passed to `--data` to be a path to a directory that is similar in structure to https://github.com/jmerle/imc-prosperity-2-backtester/tree/master/prosperity2bt/resources
$ prosperity2bt example/starter.py 1 --data prosperity2bt/resources

# Print trader's output to stdout while running
# This may be helpful when debugging a broken trader
$ prosperity2bt example/starter.py 1 --print

# Only match orders against order depths, not against market trades
$ prosperity2bt example/starter.py 1 --no-trades-matching

Order Matching

Orders placed by Trader.run at a given timestamp are matched against the order depths and market trades of that timestamp's state. Order depths take priority, if an order can be filled completely using volume in the relevant order depth, market trades are not considered. If not, the backtester matches your order against the timestamp's market trades. In this case the backtester assumes that for each trade, the buyer and the seller of the trade are willing to trade with you instead at the trade's price and volume. Market trades are matched at the price of your orders, e.g. if you place a sell order for €9 and there is a market trade for €10, the sell order is matched at €9 (even though there is a buyer willing to pay €10, this appears to be consistent with what the official Prosperity environment does).

Limits are enforced before orders are matched to order depths. If for a product your position would exceed the limit, assuming all your orders would get filled, all your orders for that product get canceled.

Development

If you want to make changes to the backtester, clone (or fork and clone) this repository and run pip install -e . in the project's root. This installs the project in editable mode, so any changes you make are automatically taken into account the next time you run prosperity2bt.

imc-prosperity-2-backtester's People

Contributors

jmerle avatar

Stargazers

Armaan Kapoor 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.