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.
- factor_agent/KUNQUANT_LICENSE +201 -0
- factor_agent/__init__.py +8 -0
- factor_agent/_acceptance_model.py +93 -0
- factor_agent/_admission.py +168 -0
- factor_agent/_expression_fold.py +48 -0
- factor_agent/_feedback.py +399 -0
- factor_agent/_max_drawdown.py +51 -0
- factor_agent/_model_cache.py +100 -0
- factor_agent/_scheduler.py +35 -0
- factor_agent/acceptance.py +808 -0
- factor_agent/accepted/__init__.py +1 -0
- factor_agent/aggregations.py +122 -0
- factor_agent/campaign.py +797 -0
- factor_agent/candidate.py +51 -0
- factor_agent/config.py +651 -0
- factor_agent/derived.py +98 -0
- factor_agent/evaluator.py +1096 -0
- factor_agent/events.py +343 -0
- factor_agent/exported.py +177 -0
- factor_agent/gate/__init__.py +359 -0
- factor_agent/gate/_canonical.py +331 -0
- factor_agent/gate/_checks.py +85 -0
- factor_agent/gate/_constraints.py +85 -0
- factor_agent/gate/_dimension.py +177 -0
- factor_agent/gate/_originality.py +146 -0
- factor_agent/gate/_sandbox.py +105 -0
- factor_agent/gate/graph.py +223 -0
- factor_agent/gate/stages.py +383 -0
- factor_agent/gate/vocabulary.py +1097 -0
- factor_agent/ledger.py +85 -0
- factor_agent/llm/__init__.py +0 -0
- factor_agent/llm/_common.py +18 -0
- factor_agent/llm/_raw.py +78 -0
- factor_agent/llm/anthropic.py +100 -0
- factor_agent/llm/base.py +124 -0
- factor_agent/llm/claude_code.py +101 -0
- factor_agent/llm/log.py +74 -0
- factor_agent/llm/openai_compatible.py +113 -0
- factor_agent/llm/replay.py +59 -0
- factor_agent/llm/scripted.py +39 -0
- factor_agent/period_lag.py +91 -0
- factor_agent/prompts.py +557 -0
- factor_agent/researcher.py +615 -0
- factor_agent/scoring.py +143 -0
- factor_agent/segments.py +184 -0
- factor_agent/session.py +500 -0
- factor_agent/snapshot.py +219 -0
- factor_agent/web/__init__.py +7 -0
- factor_agent/web/_acceptance.py +145 -0
- factor_agent/web/_config.py +51 -0
- factor_agent/web/_diagnosis.py +110 -0
- factor_agent/web/_files.py +78 -0
- factor_agent/web/_health.py +207 -0
- factor_agent/web/_ic.py +27 -0
- factor_agent/web/_ledger.py +293 -0
- factor_agent/web/_memory.py +42 -0
- factor_agent/web/_results.py +77 -0
- factor_agent/web/_round.py +219 -0
- factor_agent/web/_trials.py +112 -0
- factor_agent/web/app.py +118 -0
- factor_agent/web/run_view.py +329 -0
- factor_agent/web/static/assets/index-9QjjJgl3.css +1 -0
- factor_agent/web/static/assets/index-iOE9ei_S.js +74 -0
- factor_agent/web/static/index.html +13 -0
- factor_agent/zoo.py +136 -0
- quantlab_factor_agent-0.1.0.dist-info/METADATA +172 -0
- quantlab_factor_agent-0.1.0.dist-info/RECORD +72 -0
- quantlab_factor_agent-0.1.0.dist-info/WHEEL +5 -0
- quantlab_factor_agent-0.1.0.dist-info/entry_points.txt +2 -0
- quantlab_factor_agent-0.1.0.dist-info/licenses/LICENSE +21 -0
- quantlab_factor_agent-0.1.0.dist-info/licenses/factor_agent/KUNQUANT_LICENSE +201 -0
- 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)
|