BalancedSharpeAndMaxDrawdownOptimisationFunction#

API documentation for tradeexecutor.backtest.optimiser_functions.BalancedSharpeAndMaxDrawdownOptimisationFunction Python class in Trading Strategy framework.

class BalancedSharpeAndMaxDrawdownOptimisationFunction[source]#

Bases: object

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

  • Both max drawdown and sharpe are giving weights (by default 50%)

  • Try to find a result where both of these varibles are maxed out

  • You can weight one more than other

  • See also optimise_sharpe_and_max_drawdown_ratio()

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, BalancedSharpeAndMaxDrawdownOptimisationFunction
from tradeexecutor.backtest.optimiser import MinTradeCountFilter

# How many Gaussian Process iterations we do
iterations = 8

optimised_results = perform_optimisation(
    iterations=iterations,
    search_func=BalancedSharpeAndMaxDrawdownOptimisationFunction(sharpe_weight=0.75, max_drawdown_weight=0.25),
    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(150),
    timeout=20*60,
    # Uncomment for diagnostics
    # log_level=logging.INFO,
    # max_workers=1,
)

print(f"Optimise completed, optimiser searched {optimised_results.get_combination_count()} combinations")
__init__(sharpe_weight=0.5, max_drawdown_weight=0.5, max_sharpe=3.0, epsilon=0.01)[source]#
Parameters:
  • sharpe_weight (float) –

  • max_drawdown_weight (float) –

  • max_sharpe (float) –

Methods

__init__([sharpe_weight, ...])

__init__(sharpe_weight=0.5, max_drawdown_weight=0.5, max_sharpe=3.0, epsilon=0.01)[source]#
Parameters:
  • sharpe_weight (float) –

  • max_drawdown_weight (float) –

  • max_sharpe (float) –

__call__(result)[source]#

Call self as a function.

Parameters:

result (GridSearchResult) –

Return type:

OptimiserSearchResult