Developer tips

Cython

Compile in debug

1
make clean
2
export CYTHON_DEBUG=true
3
python setup.py build_ext --inplace
Copied!

Debugging cythonized code

Run your python program with cython debugger :
1
cygdb . -- --args python3-dbg test.py
Copied!

Backtesting data

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 SQLite browser to explore these files.

Pytest

Fatal Python error: Segmentation fault

  • Compile the package in debug
  • Run tests with test.py :
1
import pytest
2
3
if __name__ == '__main__':
4
pytest.main(["tests"])
Copied!
and
1
> cygdb . -- --args python3-dbg test.py
Copied!

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:
1
def _handle_results(self, independent_backtesting, profitability):
2
exchange_manager_ids = get_independent_backtesting_exchange_manager_ids(independent_backtesting)
3
for exchange_manager in get_exchange_managers_from_exchange_ids(exchange_manager_ids):
4
_, run_profitability, _, market_average_profitability, _ = get_profitability_stats(exchange_manager)
5
actual = round(run_profitability, 3)
6
# uncomment this print for building tests
7
# print(f"results: rounded run profitability {actual} market profitability: {market_average_profitability}"
8
# f" expected: {profitability} [result: {actual == profitability}]")
9
assert actual == profitability
Copied!
into
1
def _handle_results(self, independent_backtesting, profitability):
2
exchange_manager_ids = get_independent_backtesting_exchange_manager_ids(independent_backtesting)
3
for exchange_manager in get_exchange_managers_from_exchange_ids(exchange_manager_ids):
4
_, run_profitability, _, market_average_profitability, _ = get_profitability_stats(exchange_manager)
5
actual = round(run_profitability, 3)
6
# uncomment this print for building tests
7
print(f"results: rounded run profitability {actual} market profitability: {market_average_profitability}"
8
f" expected: {profitability} [result: {actual == profitability}]")
9
# assert actual == profitability
Copied!
This will not stop tests on failure and display the current tests results as well as expected values.