}
# (natr_multiplier_fraction, stake_percent, color)
- _FINAL_EXIT_STAGE: Final[tuple[float, float, str]] = (1.0, 1.0, "deepskyblue")
+ _FINAL_EXIT_STAGE_PARAMS: Final[tuple[float, float, str]] = (
+ 1.0,
+ 1.0,
+ "deepskyblue",
+ )
+
+ # Stage index of the final full exit: one past the last partial stage.
+ _FINAL_EXIT_STAGE_INDEX: Final[int] = (
+ max(partial_exit_stages.keys(), default=-1) + 1
+ )
_TAKE_PROFIT_ORDER_TAG_PREFIX: Final[str] = "take_profit_"
f" stage {stage}: natr_multiplier_fraction={format_number(natr_multiplier_fraction)}, stake_percent={format_number(stake_percent)}, color={color}"
)
- final_stage = max(QuickAdapterV3.partial_exit_stages.keys(), default=-1) + 1
+ final_stage = QuickAdapterV3._FINAL_EXIT_STAGE_INDEX
logger.info(
- f"Final Exit Stage: stage {final_stage}: natr_multiplier_fraction={format_number(QuickAdapterV3._FINAL_EXIT_STAGE[0])}, stake_percent={format_number(QuickAdapterV3._FINAL_EXIT_STAGE[1])}, color={QuickAdapterV3._FINAL_EXIT_STAGE[2]}"
+ f"Final Exit Stage: stage {final_stage}: natr_multiplier_fraction={format_number(QuickAdapterV3._FINAL_EXIT_STAGE_PARAMS[0])}, stake_percent={format_number(QuickAdapterV3._FINAL_EXIT_STAGE_PARAMS[1])}, color={QuickAdapterV3._FINAL_EXIT_STAGE_PARAMS[2]}"
)
logger.info("Protections:")
QuickAdapterV3._TAKE_PROFIT_ORDER_TAG_PREFIX
)
)
- final_stage = max(QuickAdapterV3.partial_exit_stages.keys(), default=-1) + 1
- return min(n_filled_take_profit_exits, final_stage)
+ return min(n_filled_take_profit_exits, QuickAdapterV3._FINAL_EXIT_STAGE_INDEX)
@staticmethod
@lru_cache(maxsize=128)
natr_multiplier_fraction = (
QuickAdapterV3.partial_exit_stages[exit_stage][0]
if exit_stage in QuickAdapterV3.partial_exit_stages
- else QuickAdapterV3._FINAL_EXIT_STAGE[0]
+ else QuickAdapterV3._FINAL_EXIT_STAGE_PARAMS[0]
)
take_profit_distance = self.get_take_profit_distance(
df, trade, natr_multiplier_fraction
trade_exit_stage = QuickAdapterV3.get_trade_exit_stage(trade)
- for take_profit_stage, (_, _, color) in self.partial_exit_stages.items():
+ for take_profit_stage in QuickAdapterV3.partial_exit_stages:
if take_profit_stage < trade_exit_stage:
continue
"end": end_date,
"y_start": partial_take_profit_price,
"y_end": partial_take_profit_price,
- "color": color,
+ "color": QuickAdapterV3.partial_exit_stages[take_profit_stage][2],
"line_style": "solid",
"width": 1,
"label": f"Take Profit {take_profit_stage}",
}
annotations.append(take_profit_line_annotation)
- final_stage = max(self.partial_exit_stages.keys(), default=-1) + 1
+ final_stage = QuickAdapterV3._FINAL_EXIT_STAGE_INDEX
final_take_profit_price = self.get_take_profit_price(
dataframe, trade, final_stage
)
"end": end_date,
"y_start": final_take_profit_price,
"y_end": final_take_profit_price,
- "color": QuickAdapterV3._FINAL_EXIT_STAGE[2],
+ "color": QuickAdapterV3._FINAL_EXIT_STAGE_PARAMS[2],
"line_style": "solid",
"width": 1,
"label": f"Take Profit {final_stage}",