prosperity2bt


Nameprosperity2bt JSON
Version 0.9.4 PyPI version JSON
download
home_pageNone
SummaryBacktester for IMC Prosperity 2 algorithms
upload_time2024-04-23 15:55:00
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2024 Jasper van Merle Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords imc prosperity backtest backtester
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # IMC Prosperity 2 Backtester

[![Build Status](https://github.com/jmerle/imc-prosperity-2-backtester/workflows/Build/badge.svg)](https://github.com/jmerle/imc-prosperity-2-backtester/actions/workflows/build.yml)
[![PyPI Version](https://img.shields.io/pypi/v/prosperity2bt)](https://pypi.org/project/prosperity2bt/)

This repository contains a backtester [IMC Prosperity 2](https://prosperity.imc.com/) 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](https://github.com/jmerle/imc-prosperity-2-visualizer) (assuming your code contains the visualizer's required prerequisites as explained on the visualizer's homepage).

## Usage

Basic usage:
```sh
# 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:
```sh
# 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

# Skip saving the output log to a file
$ prosperity2bt example/starter.py 1 --no-out

# 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.

## Data Files

Data for the following round is included:
- Round 0: prices and anonymized trades data on AMETHYSTS and STARFRUIT that was used during tutorial submission runs.
- Round 1: prices, anonymized trades, and de-anonymized trades data on AMETHYSTS and STARFRUIT.
- Round 3: prices, anonymized trades, and de-anonymized trades data on CHOCOLATE, STRAWBERRIES, ROSES, and GIFT_BASKET.
- Round 4: prices, anonymized trades, and de-anonymized trades data on COCONUT and COCONUT_COUPON.
- Round 6: prices data that was used during submission runs. Round 6 day X represents the submission data of round X, where X = 0 means the tutorial round.
- Round 7: prices data that was used during end-of-round runs. Round 7 day Y represents the end-of-round data of round Y.

Round 2 (ORCHIDS and conversion observations) is not supported. By default de-anonymized trades data is used if it is available, except when the `--no-names` flag is used.

## Environment Variables

During backtests two environment variables are set for the trader to know the round and day it's being backtested on. The environment variable named `PROSPERITY2BT_ROUND` contains the round number and `PROSPERITY2BT_DAY` contains the day number. Note that these environment variables do not exist in the official submission environment, so make sure the code you submit doesn't require them to be defined.

## 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`.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "prosperity2bt",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "imc, prosperity, backtest, backtester",
    "author": null,
    "author_email": "Jasper van Merle <jaspervmerle@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/28/ea/e74157513a1666e7a03aa82176d10f54d0c6dd31e7f08dde16d82e0a996b/prosperity2bt-0.9.4.tar.gz",
    "platform": null,
    "description": "# IMC Prosperity 2 Backtester\n\n[![Build Status](https://github.com/jmerle/imc-prosperity-2-backtester/workflows/Build/badge.svg)](https://github.com/jmerle/imc-prosperity-2-backtester/actions/workflows/build.yml)\n[![PyPI Version](https://img.shields.io/pypi/v/prosperity2bt)](https://pypi.org/project/prosperity2bt/)\n\nThis repository contains a backtester [IMC Prosperity 2](https://prosperity.imc.com/) 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](https://github.com/jmerle/imc-prosperity-2-visualizer) (assuming your code contains the visualizer's required prerequisites as explained on the visualizer's homepage).\n\n## Usage\n\nBasic usage:\n```sh\n# Install the latest version of the backtester\n$ pip install -U prosperity2bt\n\n# Run the backtester on an algorithm using all data from round 0\n$ prosperity2bt <path to algorithm file> 0\n```\n\nRun `pip install -U prosperity2bt` again when you want to update the backtester to the latest version.\n\nSome more usage examples:\n```sh\n# Backtest on all days from round 1\n$ prosperity2bt example/starter.py 1\n\n# Backtest on round 1 day 0\n$ prosperity2bt example/starter.py 1-0\n\n# Backtest on round 1 day -1 and round 1 day 0\n$ prosperity2bt example/starter.py 1--1 1-0\n\n# Backtest on all days from rounds 1 and 2\n$ prosperity2bt example/starter.py 1 2\n\n# You get the idea\n\n# Merge profit and loss across days\n$ prosperity2bt example/starter.py 1 --merge-pnl\n\n# Automatically open the result in the visualizer when done\n# Assumes your algorithm logs in the visualizer's expected format\n$ prosperity2bt example/starter.py 1 --vis\n\n# Write algorithm output to custom file\n$ prosperity2bt example/starter.py 1 --out example.log\n\n# Skip saving the output log to a file\n$ prosperity2bt example/starter.py 1 --no-out\n\n# Backtest on custom data\n# 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\n$ prosperity2bt example/starter.py 1 --data prosperity2bt/resources\n\n# Print trader's output to stdout while running\n# This may be helpful when debugging a broken trader\n$ prosperity2bt example/starter.py 1 --print\n\n# Only match orders against order depths, not against market trades\n$ prosperity2bt example/starter.py 1 --no-trades-matching\n```\n\n## Order Matching\n\nOrders 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 \u20ac9 and there is a market trade for \u20ac10, the sell order is matched at \u20ac9 (even though there is a buyer willing to pay \u20ac10, this appears to be consistent with what the official Prosperity environment does).\n\nLimits 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.\n\n## Data Files\n\nData for the following round is included:\n- Round 0: prices and anonymized trades data on AMETHYSTS and STARFRUIT that was used during tutorial submission runs.\n- Round 1: prices, anonymized trades, and de-anonymized trades data on AMETHYSTS and STARFRUIT.\n- Round 3: prices, anonymized trades, and de-anonymized trades data on CHOCOLATE, STRAWBERRIES, ROSES, and GIFT_BASKET.\n- Round 4: prices, anonymized trades, and de-anonymized trades data on COCONUT and COCONUT_COUPON.\n- Round 6: prices data that was used during submission runs. Round 6 day X represents the submission data of round X, where X = 0 means the tutorial round.\n- Round 7: prices data that was used during end-of-round runs. Round 7 day Y represents the end-of-round data of round Y.\n\nRound 2 (ORCHIDS and conversion observations) is not supported. By default de-anonymized trades data is used if it is available, except when the `--no-names` flag is used.\n\n## Environment Variables\n\nDuring backtests two environment variables are set for the trader to know the round and day it's being backtested on. The environment variable named `PROSPERITY2BT_ROUND` contains the round number and `PROSPERITY2BT_DAY` contains the day number. Note that these environment variables do not exist in the official submission environment, so make sure the code you submit doesn't require them to be defined.\n\n## Development\n\nIf 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`.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Jasper van Merle  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Backtester for IMC Prosperity 2 algorithms",
    "version": "0.9.4",
    "project_urls": {
        "Changelog": "https://github.com/jmerle/imc-prosperity-2-backtester/releases",
        "Issues": "https://github.com/jmerle/imc-prosperity-2-backtester/issues",
        "Repository": "https://github.com/jmerle/imc-prosperity-2-backtester"
    },
    "split_keywords": [
        "imc",
        " prosperity",
        " backtest",
        " backtester"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8670dacc0c1ffd978f35cb9b10de90b2894972692135e152fc681d2daa657197",
                "md5": "fd561d0b2f3b877b63e7ef5f315e0bc7",
                "sha256": "e66b4df37f8431624da05181eb1aedb87f61bb1f9b194c840ad026fd8e14f2c8"
            },
            "downloads": -1,
            "filename": "prosperity2bt-0.9.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fd561d0b2f3b877b63e7ef5f315e0bc7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 6324014,
            "upload_time": "2024-04-23T15:54:58",
            "upload_time_iso_8601": "2024-04-23T15:54:58.179073Z",
            "url": "https://files.pythonhosted.org/packages/86/70/dacc0c1ffd978f35cb9b10de90b2894972692135e152fc681d2daa657197/prosperity2bt-0.9.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28eae74157513a1666e7a03aa82176d10f54d0c6dd31e7f08dde16d82e0a996b",
                "md5": "d8a1b24dd06680977ac8446fb6049539",
                "sha256": "44c76da56d6351fce7be76acdbc979c573b20946e9796f27a72cb6d89a3af707"
            },
            "downloads": -1,
            "filename": "prosperity2bt-0.9.4.tar.gz",
            "has_sig": false,
            "md5_digest": "d8a1b24dd06680977ac8446fb6049539",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 5999140,
            "upload_time": "2024-04-23T15:55:00",
            "upload_time_iso_8601": "2024-04-23T15:55:00.467862Z",
            "url": "https://files.pythonhosted.org/packages/28/ea/e74157513a1666e7a03aa82176d10f54d0c6dd31e7f08dde16d82e0a996b/prosperity2bt-0.9.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-23 15:55:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jmerle",
    "github_project": "imc-prosperity-2-backtester",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "prosperity2bt"
}
        
Elapsed time: 0.25237s