mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-16 04:41:15 +00:00
chore: refactor buy/sell spaces slightly
This commit is contained in:
@@ -70,8 +70,7 @@ class HyperOptimizer:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, config: Config, data_pickle_file: Path) -> None:
|
def __init__(self, config: Config, data_pickle_file: Path) -> None:
|
||||||
self.buy_space: list[DimensionProtocol] = []
|
self.spaces: dict[str, list[DimensionProtocol]] = {}
|
||||||
self.sell_space: list[DimensionProtocol] = []
|
|
||||||
self.protection_space: list[DimensionProtocol] = []
|
self.protection_space: list[DimensionProtocol] = []
|
||||||
self.roi_space: list[DimensionProtocol] = []
|
self.roi_space: list[DimensionProtocol] = []
|
||||||
self.stoploss_space: list[DimensionProtocol] = []
|
self.stoploss_space: list[DimensionProtocol] = []
|
||||||
@@ -167,10 +166,10 @@ class HyperOptimizer:
|
|||||||
"""
|
"""
|
||||||
result: dict = {}
|
result: dict = {}
|
||||||
|
|
||||||
if HyperoptTools.has_space(self.config, "buy"):
|
for indicator in self.spaces.keys():
|
||||||
result["buy"] = round_dict({p.name: params.get(p.name) for p in self.buy_space}, 13)
|
result[indicator] = round_dict(
|
||||||
if HyperoptTools.has_space(self.config, "sell"):
|
{p.name: params.get(p.name) for p in self.spaces.get(indicator, [])}, 13
|
||||||
result["sell"] = round_dict({p.name: params.get(p.name) for p in self.sell_space}, 13)
|
)
|
||||||
if HyperoptTools.has_space(self.config, "protection"):
|
if HyperoptTools.has_space(self.config, "protection"):
|
||||||
result["protection"] = round_dict(
|
result["protection"] = round_dict(
|
||||||
{p.name: params.get(p.name) for p in self.protection_space}, 13
|
{p.name: params.get(p.name) for p in self.protection_space}, 13
|
||||||
@@ -234,13 +233,10 @@ class HyperOptimizer:
|
|||||||
self.backtesting.enable_protections = True
|
self.backtesting.enable_protections = True
|
||||||
self.protection_space = self.custom_hyperopt.protection_space()
|
self.protection_space = self.custom_hyperopt.protection_space()
|
||||||
|
|
||||||
if HyperoptTools.has_space(self.config, "buy"):
|
for indicator in ["buy", "sell"]:
|
||||||
logger.debug("Hyperopt has 'buy' space")
|
if HyperoptTools.has_space(self.config, indicator):
|
||||||
self.buy_space = self.custom_hyperopt.buy_indicator_space()
|
logger.debug(f"Hyperopt has '{indicator}' space")
|
||||||
|
self.spaces[indicator] = self.custom_hyperopt.get_indicator_space(indicator)
|
||||||
if HyperoptTools.has_space(self.config, "sell"):
|
|
||||||
logger.debug("Hyperopt has 'sell' space")
|
|
||||||
self.sell_space = self.custom_hyperopt.sell_indicator_space()
|
|
||||||
|
|
||||||
if HyperoptTools.has_space(self.config, "roi"):
|
if HyperoptTools.has_space(self.config, "roi"):
|
||||||
logger.debug("Hyperopt has 'roi' space")
|
logger.debug("Hyperopt has 'roi' space")
|
||||||
@@ -259,8 +255,7 @@ class HyperOptimizer:
|
|||||||
self.max_open_trades_space = self.custom_hyperopt.max_open_trades_space()
|
self.max_open_trades_space = self.custom_hyperopt.max_open_trades_space()
|
||||||
|
|
||||||
self.dimensions = (
|
self.dimensions = (
|
||||||
self.buy_space
|
[s for space in self.spaces.values() for s in space]
|
||||||
+ self.sell_space
|
|
||||||
+ self.protection_space
|
+ self.protection_space
|
||||||
+ self.roi_space
|
+ self.roi_space
|
||||||
+ self.stoploss_space
|
+ self.stoploss_space
|
||||||
|
|||||||
Reference in New Issue
Block a user