optimiser_functions#

API documentation for tradeexecutor.backtest.optimiser_functions Python module in Trading Strategy.

Module description#

Functions the optimiser would be looking for.

Example:

import logging
from tradeexecutor.backtest.optimiser import perform_optimisation
from tradeexecutor.backtest.optimiser import prepare_optimiser_parameters
from tradeexecutor.backtest.optimiser_functions import optimise_profit, optimise_sharpe
from tradeexecutor.backtest.optimiser import MinTradeCountFilter

# How many Gaussian Process iterations we do
iterations = 6

optimised_results = perform_optimisation(
    iterations=iterations,
    search_func=optimise_profit,
    decide_trades=decide_trades,
    strategy_universe=strategy_universe,
    parameters=prepare_optimiser_parameters(Parameters),  # Handle scikit-optimise search space
    create_indicators=create_indicators,
    result_filter=MinTradeCountFilter(50)
    # Uncomment for diagnostics
    # log_level=logging.INFO,
    # max_workers=1,
)

print(f"Optimise completed, optimiser searched {optimised_results.get_combination_count()} combinations")

Classes#

BalancedSharpeAndMaxDrawdownOptimisationFunction

Try to find a strategy with balanced Sharpe and max drawdown.

RollingSharpeOptimisationFunction

Find a rolling sharpe that's stable and high.

Functions#

optimise_max_drawdown(result)

Search for the lowest max drawdown.

optimise_profit(result)

Search for the best CAGR value.

optimise_sharpe(result)

Search for the best Sharpe value.

optimise_sharpe_and_max_drawdown_ratio(result)

Search for the best sharpe / max drawndown ratio.

optimise_sortino(result)

Search for the best Sortino value.

optimise_win_rate(result)

Search for the best trade win rate.