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 @@
1
+ """Accepted factors exported by ``Acceptance.export``, one generated module each (``GraphFactor`` subclasses)."""
@@ -0,0 +1,122 @@
1
+ """Session aggregations: the operators that reduce each session's intraday bars to one value per stock and day.
2
+
3
+ Each is a marker: a KunQuant operator class that computes nothing itself.
4
+ Candidate code calls it like any operator and the Gate records it as one
5
+ node of the graph, so a graph's identity does not depend on how the
6
+ aggregation is computed; ``factor_agent.session.SessionFactor`` expands it
7
+ into KunQuant accumulators when it builds its function. An operator file
8
+ registers an aggregation like any operator, by its class here.
9
+
10
+ ``WithinSession`` is no aggregation: the stage split wraps each window of
11
+ the intraday stage in it, so the window is missing until it fits in the
12
+ session. Candidate code never calls it.
13
+ """
14
+
15
+ from KunQuant.Op import Builder, CompositiveOp, ConstantOp, OpBase
16
+ from KunQuant.ops import LessThan, Select
17
+
18
+
19
+ class SessionAggregation(OpBase):
20
+ """The base of the session aggregations: a reduction of its inputs over each session's bars."""
21
+
22
+ def __init__(self, *inputs: OpBase) -> None:
23
+ super().__init__(list(inputs), None)
24
+
25
+
26
+ class SessionMean(SessionAggregation):
27
+ """The mean of ``x`` over the session's bars where it has a value; NaN when it has none."""
28
+
29
+ def __init__(self, x: OpBase) -> None:
30
+ super().__init__(x)
31
+
32
+
33
+ class SessionSum(SessionAggregation):
34
+ """The sum of ``x`` over the session's bars where it has a value; 0 when it has none."""
35
+
36
+ def __init__(self, x: OpBase) -> None:
37
+ super().__init__(x)
38
+
39
+
40
+ class SessionCount(SessionAggregation):
41
+ """The number of the session's bars where ``x`` has a value; 0 when it has none."""
42
+
43
+ def __init__(self, x: OpBase) -> None:
44
+ super().__init__(x)
45
+
46
+
47
+ class SessionStd(SessionAggregation):
48
+ """The unbiased standard deviation of ``x`` over the session's bars where it has a value; NaN below two."""
49
+
50
+ def __init__(self, x: OpBase) -> None:
51
+ super().__init__(x)
52
+
53
+
54
+ class SessionSkew(SessionAggregation):
55
+ """The unbiased skewness of ``x`` over the session's bars where it has a value; NaN below three or when constant."""
56
+
57
+ def __init__(self, x: OpBase) -> None:
58
+ super().__init__(x)
59
+
60
+
61
+ class SessionMin(SessionAggregation):
62
+ """The least value of ``x`` in the session; NaN when it has none."""
63
+
64
+ def __init__(self, x: OpBase) -> None:
65
+ super().__init__(x)
66
+
67
+
68
+ class SessionMax(SessionAggregation):
69
+ """The greatest value of ``x`` in the session; NaN when it has none."""
70
+
71
+ def __init__(self, x: OpBase) -> None:
72
+ super().__init__(x)
73
+
74
+
75
+ class SessionFirst(SessionAggregation):
76
+ """The first value of ``x`` present in the session; NaN when it has none."""
77
+
78
+ def __init__(self, x: OpBase) -> None:
79
+ super().__init__(x)
80
+
81
+
82
+ class SessionLast(SessionAggregation):
83
+ """The last value of ``x`` present in the session; NaN when it has none."""
84
+
85
+ def __init__(self, x: OpBase) -> None:
86
+ super().__init__(x)
87
+
88
+
89
+ class SessionWeightedMean(SessionAggregation):
90
+ """The mean of ``x`` weighted by ``w`` over the bars where both have a value; NaN when the weights sum to 0."""
91
+
92
+ def __init__(self, x: OpBase, w: OpBase) -> None:
93
+ super().__init__(x, w)
94
+
95
+
96
+ class SessionCorr(SessionAggregation):
97
+ """The correlation of ``x`` and ``y`` over the bars where both have a value; NaN when one is constant there."""
98
+
99
+ def __init__(self, x: OpBase, y: OpBase) -> None:
100
+ super().__init__(x, y)
101
+
102
+
103
+ class WithinSession(CompositiveOp):
104
+ """``x`` on the bars at least ``bars`` bars into their session, NaN on the session's first ``bars``.
105
+
106
+ ``position`` is the bar's position in its session (quantlab's ``SESSION_POSITION``).
107
+ The stage split (``factor_agent.gate.stages``) wraps each window of the
108
+ intraday stage in it, ``bars`` the bars the window reaches back, its
109
+ inputs' windows included, so the window is missing until it fits in the
110
+ session; KunQuant decomposes it into a ``Select``. Candidate code never
111
+ calls it.
112
+ """
113
+
114
+ def __init__(self, x: OpBase, position: OpBase, bars: int) -> None:
115
+ super().__init__([x, position], [("bars", bars)])
116
+
117
+ def decompose(self, options: dict) -> list[OpBase]:
118
+ b = Builder(self.get_parent())
119
+ with b:
120
+ x, position = self.inputs
121
+ Select(LessThan(position, ConstantOp(float(self.attrs["bars"]))), ConstantOp("nan"), x)
122
+ return b.ops