| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- from __future__ import annotations
- from dragon_strategy_config import StrategyConfig
- def deep_oversold_base_entry(*, a1: float, b1: float, c1: float, config: StrategyConfig) -> bool:
- if (
- config.deep_oversold_filter1_c1_low < c1 < config.deep_oversold_filter1_c1_high
- and a1 > config.deep_oversold_filter1_a1_min
- and b1 < config.deep_oversold_filter1_b1_max
- ):
- return False
- if (
- config.deep_oversold_filter2_c1_low < c1 < config.deep_oversold_filter2_c1_high
- and a1 > config.deep_oversold_filter2_a1_min
- and b1 > config.deep_oversold_filter2_b1_min
- ):
- return False
- return (
- c1 < config.deep_oversold_entry_c1_max
- and a1 > config.deep_oversold_entry_a1_min
- and b1 > config.deep_oversold_entry_b1_min
- )
- def deep_oversold_subtype(*, a1: float, b1: float, c1: float) -> str:
- if b1 > 0:
- return "positive_b1_rebound"
- if c1 < 11 and a1 < -0.05 and b1 < -0.08:
- return "deep_capitulation"
- if c1 < 12 and b1 < -0.06:
- return "classic_oversold"
- if c1 >= 15 or a1 > -0.03 or b1 > -0.03:
- return "shallow_false_start"
- return "mixed_oversold"
- def deep_oversold_requires_confirmation(
- *,
- subtype: str,
- ql_buy: bool,
- config: StrategyConfig,
- ) -> bool:
- if not config.deep_oversold_confirm_weak_with_ql:
- return False
- if subtype not in {"positive_b1_rebound", "shallow_false_start"}:
- return False
- if ql_buy:
- return False
- return True
- def deep_oversold_selective_veto(
- *,
- subtype: str,
- c1: float,
- b1: float,
- ql_buy: bool,
- config: StrategyConfig,
- ) -> bool:
- if (
- subtype == "positive_b1_rebound"
- and config.deep_oversold_selective_positive_b1_c1_max > 0
- and c1 < config.deep_oversold_selective_positive_b1_c1_max
- ):
- return True
- if (
- subtype == "shallow_false_start"
- and config.deep_oversold_selective_shallow_c1_min > 0
- and c1 >= config.deep_oversold_selective_shallow_c1_min
- and b1 > config.deep_oversold_selective_shallow_b1_min
- ):
- return True
- if (
- subtype == "mixed_oversold"
- and config.deep_oversold_selective_mixed_c1_max > 0
- and c1 < config.deep_oversold_selective_mixed_c1_max
- and (not config.deep_oversold_selective_mixed_require_no_ql or not ql_buy)
- ):
- return True
- return False
|