| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- from __future__ import annotations
- from dragon_strategy_config import StrategyConfig
- def glued_high_weak_rebound_subtype(
- *,
- a1: float,
- b1: float,
- c1: float,
- ql_buy: bool,
- config: StrategyConfig,
- ) -> str:
- if c1 > config.glued_high_weak_rebound_high_c1 and b1 < config.glued_high_weak_rebound_high_b1:
- return "high_zone_weak_b1"
- if c1 > config.glued_high_weak_rebound_mid_c1 and b1 < config.glued_high_weak_rebound_mid_b1:
- return "mid_zone_very_weak_b1"
- if (
- ql_buy
- and config.glued_high_weak_rebound_ql_c1_low < c1 < config.glued_high_weak_rebound_ql_c1_high
- and b1 < config.glued_high_weak_rebound_ql_b1
- and a1 > config.glued_high_weak_rebound_ql_a1
- ):
- return "ql_rebound_weak_followthrough"
- return ""
- def glued_followthrough_pending_allowed(
- *,
- subtype: str,
- config: StrategyConfig,
- ) -> bool:
- if not config.glued_followthrough_pending_enabled:
- return False
- if subtype == "mid_zone_very_weak_b1":
- return config.glued_followthrough_allow_mid_zone_very_weak_b1
- if subtype == "high_zone_weak_b1":
- return config.glued_followthrough_allow_high_zone_weak_b1
- if subtype == "ql_rebound_weak_followthrough":
- return config.glued_followthrough_allow_ql_rebound_weak_followthrough
- return False
- def evaluate_glued_followthrough_confirmation(
- *,
- active: bool,
- subtype: str,
- in_position: bool,
- kdj_sell: bool,
- ql_sell: bool,
- bars_waited: int,
- ql_buy: bool,
- close: float,
- signal_close: float,
- b1: float,
- signal_b1: float,
- config: StrategyConfig,
- ) -> tuple[str, str, bool]:
- if not active or not subtype:
- return "NONE", "", False
- if in_position:
- return "NONE", "", True
- if kdj_sell or ql_sell:
- return "NONE", "", True
- if bars_waited > config.glued_followthrough_confirm_window_bars:
- return "NONE", "", True
- if bars_waited < 1:
- return "NONE", "", False
- if config.glued_followthrough_require_ql_buy_reconfirm and not ql_buy:
- return "NONE", "", False
- if config.glued_followthrough_require_close_break_signal_close and close <= signal_close:
- return "NONE", "", False
- if config.glued_followthrough_require_b1_repair and (b1 - signal_b1) < config.glued_followthrough_b1_repair_min:
- return "NONE", "", False
- return "BUY", f"glued_followthrough_reentry_buy:confirmed_{subtype}", True
|