Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn TradingStrategyUniverse to a slotted class #988

Merged
merged 4 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions tradeexecutor/backtest/optimiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,17 +308,18 @@ def __call__(

if getattr(result, "exception", None) is None: # Legacy pickle compat
opt_result = self.search_func(result)

# Apply result filter and zero out the value for optimiser if needed
if not self.result_filter(result):
opt_result.value = self.filtered_result_value

else:
# The backtest crashed with an exception,
# likely OutOfBalance
opt_result = self.filtered_result_value

# Apply result filter and zero out the value for optimiser if needed
if not self.result_filter(result):
opt_result.value = self.filtered_result_value
opt_result = OptimiserSearchResult(self.filtered_result_value, negative=False)

opt_result.combination = combination
logger.info("Optimiser for combination %s resulted to %s, exiting child process", combination, opt_result.value)
logger.info("Optimiser for combination %s resulted to %s, exception is %s, exiting child process", combination, opt_result.value, result.exception)
return opt_result


Expand Down
2 changes: 1 addition & 1 deletion tradeexecutor/strategy/trading_strategy_universe.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def __post_init__(self):
assert self.start_at is None and self.end_at is None, f"You can only give history_period or backtesting range. We got {self.start_at}, {self.end_at}, {self.history_period}"


@dataclass
@dataclass(slots=True)
class TradingStrategyUniverse(StrategyExecutionUniverse):
"""A trading strategy universe using our own data feeds.

Expand Down
Loading