quantlab-factor-agent 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. factor_agent/KUNQUANT_LICENSE +201 -0
  2. factor_agent/__init__.py +8 -0
  3. factor_agent/_acceptance_model.py +93 -0
  4. factor_agent/_admission.py +168 -0
  5. factor_agent/_expression_fold.py +48 -0
  6. factor_agent/_feedback.py +399 -0
  7. factor_agent/_max_drawdown.py +51 -0
  8. factor_agent/_model_cache.py +100 -0
  9. factor_agent/_scheduler.py +35 -0
  10. factor_agent/acceptance.py +808 -0
  11. factor_agent/accepted/__init__.py +1 -0
  12. factor_agent/aggregations.py +122 -0
  13. factor_agent/campaign.py +797 -0
  14. factor_agent/candidate.py +51 -0
  15. factor_agent/config.py +651 -0
  16. factor_agent/derived.py +98 -0
  17. factor_agent/evaluator.py +1096 -0
  18. factor_agent/events.py +343 -0
  19. factor_agent/exported.py +177 -0
  20. factor_agent/gate/__init__.py +359 -0
  21. factor_agent/gate/_canonical.py +331 -0
  22. factor_agent/gate/_checks.py +85 -0
  23. factor_agent/gate/_constraints.py +85 -0
  24. factor_agent/gate/_dimension.py +177 -0
  25. factor_agent/gate/_originality.py +146 -0
  26. factor_agent/gate/_sandbox.py +105 -0
  27. factor_agent/gate/graph.py +223 -0
  28. factor_agent/gate/stages.py +383 -0
  29. factor_agent/gate/vocabulary.py +1097 -0
  30. factor_agent/ledger.py +85 -0
  31. factor_agent/llm/__init__.py +0 -0
  32. factor_agent/llm/_common.py +18 -0
  33. factor_agent/llm/_raw.py +78 -0
  34. factor_agent/llm/anthropic.py +100 -0
  35. factor_agent/llm/base.py +124 -0
  36. factor_agent/llm/claude_code.py +101 -0
  37. factor_agent/llm/log.py +74 -0
  38. factor_agent/llm/openai_compatible.py +113 -0
  39. factor_agent/llm/replay.py +59 -0
  40. factor_agent/llm/scripted.py +39 -0
  41. factor_agent/period_lag.py +91 -0
  42. factor_agent/prompts.py +557 -0
  43. factor_agent/researcher.py +615 -0
  44. factor_agent/scoring.py +143 -0
  45. factor_agent/segments.py +184 -0
  46. factor_agent/session.py +500 -0
  47. factor_agent/snapshot.py +219 -0
  48. factor_agent/web/__init__.py +7 -0
  49. factor_agent/web/_acceptance.py +145 -0
  50. factor_agent/web/_config.py +51 -0
  51. factor_agent/web/_diagnosis.py +110 -0
  52. factor_agent/web/_files.py +78 -0
  53. factor_agent/web/_health.py +207 -0
  54. factor_agent/web/_ic.py +27 -0
  55. factor_agent/web/_ledger.py +293 -0
  56. factor_agent/web/_memory.py +42 -0
  57. factor_agent/web/_results.py +77 -0
  58. factor_agent/web/_round.py +219 -0
  59. factor_agent/web/_trials.py +112 -0
  60. factor_agent/web/app.py +118 -0
  61. factor_agent/web/run_view.py +329 -0
  62. factor_agent/web/static/assets/index-9QjjJgl3.css +1 -0
  63. factor_agent/web/static/assets/index-iOE9ei_S.js +74 -0
  64. factor_agent/web/static/index.html +13 -0
  65. factor_agent/zoo.py +136 -0
  66. quantlab_factor_agent-0.1.0.dist-info/METADATA +172 -0
  67. quantlab_factor_agent-0.1.0.dist-info/RECORD +72 -0
  68. quantlab_factor_agent-0.1.0.dist-info/WHEEL +5 -0
  69. quantlab_factor_agent-0.1.0.dist-info/entry_points.txt +2 -0
  70. quantlab_factor_agent-0.1.0.dist-info/licenses/LICENSE +21 -0
  71. quantlab_factor_agent-0.1.0.dist-info/licenses/factor_agent/KUNQUANT_LICENSE +201 -0
  72. quantlab_factor_agent-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,51 @@
1
+ """A factor candidate as the proposer writes it: a stated mechanism and the KunQuant code."""
2
+
3
+ import dataclasses
4
+ from collections.abc import Collection
5
+ from dataclasses import dataclass
6
+
7
+
8
+ @dataclass(frozen=True)
9
+ class Candidate:
10
+ """One proposed factor.
11
+
12
+ ``code`` is a Python body over the vocabulary's operators that ends by
13
+ assigning the factor to ``alpha``. A candidate states no direction:
14
+ which way it predicts is read from its training IC.
15
+ """
16
+
17
+ hypothesis: str
18
+ mechanism_type: str
19
+ horizon_rationale: str
20
+ description: str
21
+ code: str
22
+
23
+ @classmethod
24
+ def from_dict(cls, item: dict, mechanism_types: Collection[str]) -> "Candidate":
25
+ """Build a candidate from the proposer's JSON object, whose type must be one of ``mechanism_types``.
26
+
27
+ Raises
28
+ ------
29
+ ValueError
30
+ If a field is missing or extra, ``mechanism_type`` is not one of
31
+ ``mechanism_types``, or a field is not a string.
32
+ """
33
+ if not isinstance(item, dict):
34
+ raise ValueError(f"a candidate must be a JSON object, got {type(item).__name__}")
35
+ names = [field.name for field in dataclasses.fields(cls)]
36
+ missing = [name for name in names if name not in item]
37
+ extra = sorted(set(item) - set(names))
38
+ if missing or extra:
39
+ raise ValueError(f"candidate fields: missing {missing}, unexpected {extra}")
40
+ if item["mechanism_type"] not in mechanism_types:
41
+ raise ValueError(
42
+ f"mechanism_type {item['mechanism_type']!r} is not one of {list(mechanism_types)}"
43
+ )
44
+ for name in names:
45
+ if not isinstance(item[name], str):
46
+ raise ValueError(f"{name} must be a string, got {type(item[name]).__name__}")
47
+ return cls(**{name: item[name] for name in names})
48
+
49
+ def to_dict(self) -> dict:
50
+ """Return the candidate as the JSON object it was parsed from."""
51
+ return dataclasses.asdict(self)