Skip to main content

How to use in commandline

  1. pip install ada-prosperity3-backtest. Or, if you have already installed it, remember to upgrade frequently because the package is still in development, and there will be data update during the contest.

  2. The following commands can be used:

  • ada-prosperity3-backtest script.py --round x [--day y] [--save_dir dir_to_save] [--infix infix_of_saved_file_name]

    This will run script.py for you on round x day y. If --day is not specified, it will run on all days. The backtest tool should show you some information in the terminal.

    Currently, we only support round 0 day 0, which is the tutorial round.

  1. After running, you should see a ada_backtest folder (or the --save_dir you specified) at the place you run the commandline, and inside there is a log folder contaning backtest logs, which is compatible with the log output from the website, and a script folder containing the script you run backtest on, with some additional comments at the beginning as a summary of the backtest result. The files are named mmdd_HHMMSS_RxDy_infixhashid.log/py, where mmdd is the month & date, HHMMSS is the hour, minute and second, RxDy means day y of round x, infix is the infix specified by you (if applicable), and hashid is the hash of the script.

  2. Iterate your algorithm accordingly!

How to use in .ipynb

from ada_prosperity3_backtest.backtest import run_backtest_with_round_and_day
from ada_prosperity3_backtest.backtest import SaveConfig
save_config = SaveConfig(
    script = None, # will automatically extract the script to save using the inspect module
    infix = 'trivial_strategy', # will appear in the name of the saved file
    save_dir = 'my_backtest', # the folder to save
)
result = run_backtest_with_round_and_day(trader, round, day, save_config)
'''
Arguments:
    trader: Trader, your strategy
    round: int
    day: int
    save_config: SaveConfig class, consisting of save_config.script (the strategy script string to save), save_config.infix (the infix of saving file) and save_config.save_dir (the directory of the save).
Returns:
    result: BacktestResult, consisting of:
        result.pnls, a list of dictionary, the breakdown of accumulated pnls for each product in each turn.
        result.sandbox_logs: list[dict], the sandbox logs, containing your model's output.
        result.prices_df: pandas.DataFrame, the price history from the simulation.
        result.trades_df: pandas.DataFrame, the trade history from the simulation.
'''

Example on tutorial round:

from ada_prosperity3_backtest.backtest import run_backtest_with_round_and_day
result = run_backtest_with_round_and_day(trader, 0, 0)

WARNING: the back-up code under this calling method is automatically generated from trader, and is not guaranteed to be identical as your original code. Take your own risk when using!

How it simulates

The backtest is based on the history prices and trades. For each timestamp, assume the timestamp is $t$, the following will happen:

  1. A TradingState will be passed onto your trading algorithm. The state consists of:
  • Order depths based on the history prices at $t$.

  • Trades, both own trades and market trades, based on the trades simulated iat $t-1$.

  • Positions based on the position of the state at $t-1$, and the trades simulated at $t-1$.

  • And some other variables, also produced in the simulation.

  1. Your Trader.run will be called.

  2. According to the response of your Trader.run, for each product, the following will happen:

  • Your position and order quantity will be checked. If not satisfying the position limit, all orders will be canceled.

  • Your trades will try to match with the current order depth. Successful matches will result in immediate changes.

  • The history trades at $t$ will both try to match the current order depth and your orders, based on the price-time order. That is, we match the orders by price, and if at the same price both orders from order_depth and your own order exist, order_depth will be matched first because those orders are placed before you.

  1. During the simulation above, your own trades (happened in the current timestamp and ready to be passed to your algorithm for the next timestamp) are generated. The leftover trades from the next timestamp will be the market trades in the state passed to your algorithm in the next timestamp.

Pros and cons

The following are some pros and cons of this backtester.

Pros:

  1. Strict price-order match of incoming trades, so that at the same price the market order depth will be first filled, then yours, simulating the situation that their orders have a higher priority than you.

  2. Backup of your code, so that you know what to submit if you would like to rely on the metric of this backtester.

Cons:

  1. Still in development, and not tested in real contests. This may lead to some instability.

  2. The backtester may underestimate your performance, because you actively trading in the contest will likely trigger more trades with you, giving you more profit, or because of other reasons.

  3. The backtester may also overestimate your performance, because of overfitting or other reasons.

According to our available data (n<10), the website result in the tutorial round seems to be around 110%-140% of the result of this backtester. You can take 125% as an estimation.

TODO List

  • Generate log files that are compatible with the log files from the website backtest.

    • First part: lambda logs

    • Second part: Prices history

    • Third part: Trades history

  • Support running on all days at the same time.

  • Support running on .ipynb or regular python files.

  • Support data from Prosperity2 to test the usage at a larger scale.

  • Support conversions.

  • Support secret spices and secret bots, which allows users to customize.

  • Optimization of speed: pre-compile something, and pre-process the csv files to reduce the loading time.

Metadata

Release files for ada-prosperity3-backtest 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ada-prosperity3-backtest 0.1.6
File Size Uploaded Provenance Actions
ada_prosperity3_backtest-0.1.6.tar.gz 51.6 kB Without provenance Details for ada_prosperity3_backtest-0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ada-prosperity3-backtest 0.1.6
File Interpreter ABI Platform Actions
ada_prosperity3_backtest-0.1.6-py3-none-any.whl Python 3 none any Details for ada_prosperity3_backtest-0.1.6-py3-none-any.whl

Total release size: 107.5 kB

Release files / ada_prosperity3_backtest-0.1.6.tar.gz

Download URL ada_prosperity3_backtest-0.1.6.tar.gz
Size 51.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b9ef5d138b321b64ad74838d16aca2a7088971a8e4cbb58c22bdbd22ab6028a5
BLAKE2b-256 checksum
How to use checksums
0af343f5b218821d821bcab0157ba420eefa8a5d84cc8483c23d2d52a66d373b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / ada_prosperity3_backtest-0.1.6-py3-none-any.whl

Download URL ada_prosperity3_backtest-0.1.6-py3-none-any.whl
Size 55.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf649a1649b909f6d0a712a2967b877fcb150695eab788312a02a5d6674b354a
BLAKE2b-256 checksum
How to use checksums
dca9e6abc6622924e58f27caf89e80a1fbd8cbc8966277e25dc5d4b7f9df964e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Security for ada-prosperity3-backtest 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page