test_search_long_short_fusion_with_calendar.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import importlib.util
  2. import sys
  3. from pathlib import Path
  4. def load_module():
  5. path = Path(__file__).resolve().parents[1] / "scripts" / "search_long_short_fusion_with_calendar.py"
  6. spec = importlib.util.spec_from_file_location("search_long_short_fusion_with_calendar", path)
  7. assert spec is not None
  8. module = importlib.util.module_from_spec(spec)
  9. assert spec.loader is not None
  10. sys.modules[spec.name] = module
  11. spec.loader.exec_module(module)
  12. return module
  13. def test_report_text_handles_empty_selection():
  14. module = load_module()
  15. pandas = __import__("pandas")
  16. text = module.report_text("cmd", [], pandas.DataFrame(), pandas.DataFrame(), pandas.DataFrame())
  17. assert "No selected candidates" in text
  18. def test_empty_output_column_contracts_are_declared():
  19. module = load_module()
  20. assert module.HORIZON_COLUMNS == [
  21. "name",
  22. "kind",
  23. "horizon",
  24. "start",
  25. "end",
  26. "total_return",
  27. "annualized_return",
  28. "max_drawdown",
  29. "calmar",
  30. "improved_vs_no_calendar",
  31. "delta_total_return",
  32. "delta_calmar",
  33. "delta_max_drawdown",
  34. ]
  35. assert module.MONTHLY_COLUMNS == ["name", "kind", "month", "start_equity", "end_equity", "return"]