dragon_deep_oversold_confirmation.py 962 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from __future__ import annotations
  2. from datetime import date
  3. from typing import Optional
  4. def should_increment_pending(
  5. *,
  6. active: bool,
  7. subtype: str,
  8. origin_date: Optional[date],
  9. row_date: date,
  10. ) -> bool:
  11. if not active or not subtype or origin_date is None:
  12. return False
  13. return row_date != origin_date
  14. def evaluate_pending_confirmation(
  15. *,
  16. active: bool,
  17. subtype: str,
  18. in_position: bool,
  19. kdj_sell: bool,
  20. ql_sell: bool,
  21. bars_waited: int,
  22. window_bars: int,
  23. ql_buy: bool,
  24. ) -> tuple[str, str, bool]:
  25. if not active or not subtype:
  26. return "NONE", "", False
  27. if in_position:
  28. return "NONE", "", True
  29. if kdj_sell or ql_sell:
  30. return "NONE", "", True
  31. if bars_waited > window_bars:
  32. return "NONE", "", True
  33. if bars_waited >= 1 and ql_buy:
  34. return "BUY", f"deep_oversold_rebound_buy:confirmed_{subtype}", True
  35. return "NONE", "", False