Skip to content
All library documents

Exploring Backtesting Data and Reporting Strategy Test Results

Article OctoBot

Summary

This developer note explains two ways to inspect and work with a trading bot’s strategy tests. It says historical candles collected for backtesting are stored in SQLite files, which can be opened in a database browser to examine the available market data. The note does not describe candle fields, data quality checks, or how exchange history limits affect the dataset.

For strategy tests, it shows how to temporarily print realized and market comparison profitability while commenting out an assertion that would otherwise stop a test when results differ from its expected value. This lets a developer see current outputs while building or updating test expectations. The example is a testing workflow, not a trading method or evidence of strategy performance. Because disabling the assertion allows failing tests to continue, the displayed results still need review before a test is considered valid.

Key ideas

  • Historical backtesting candles are stored in SQLite databases that can be inspected with a browser.
  • A test can print realized profitability and market comparison values to help update strategy checks.
  • Commenting out an assertion allows a test to continue even when its result differs from the expected value.
  • The note gives no guidance on validating data quality or interpreting profitability results.

Tags

Full text
# Developer tips


---
title: "Developer tips"
description: "Profit from our tips to get you quickly started as an OctoBot developer. Explore the SQLite backtesting files using SQLite browser and test your strategies."
sidebar_position: 9
---



# Developer tips

## Backtesting data

[Backtesting](/guides/octobot-usage/backtesting) data files are sqlite database files. When using the regular data collector, these files contain every historical candles the requested exchange is willing to give. You can use a <a href="https://sqlitebrowser.org/" rel="nofollow">SQLite browser</a> to explore these files.

## Strategy tests

To quickly check tentacles strategy tests states or develop a new tentacles strategy test, change the following lines in **octobot/tests/functional_tests/strategy_evaluators_tests/abstract_strategy_test.py**:

```python
def _handle_results(self, independent_backtesting, profitability):
    exchange_manager_ids = get_independent_backtesting_exchange_manager_ids(independent_backtesting)
    for exchange_manager in get_exchange_managers_from_exchange_ids(exchange_manager_ids):
        _, run_profitability, _, market_average_profitability, _ = get_profitability_stats(exchange_manager)
        actual = round(run_profitability, 3)
        # uncomment this print for building tests
        # print(f"results: rounded run profitability {actual} market profitability: {market_average_profitability}"
        #       f" expected: {profitability} [result: {actual ==  profitability}]")
        assert actual == profitability
```

into

```python
def _handle_results(self, independent_backtesting, profitability):
    exchange_manager_ids = get_independent_backtesting_exchange_manager_ids(independent_backtesting)
    for exchange_manager in get_exchange_managers_from_exchange_ids(exchange_manager_ids):
        _, run_profitability, _, market_average_profitability, _ = get_profitability_stats(exchange_manager)
        actual = round(run_profitability, 3)
        # uncomment this print for building tests
        print(f"results: rounded run profitability {actual} market profitability: {market_average_profitability}"
              f" expected: {profitability} [result: {actual ==  profitability}]")
        # assert actual == profitability
```

This will not stop tests on failure and display the current tests results as well as expected values.

Shown in full with attribution under the source's licence. Licence: GPL-3.0

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.