gaurv007 commited on
Commit
c92d64f
·
verified ·
1 Parent(s): ff03a17

feat: generate_proven.py — standalone script that generates BRAIN-ready expressions using proven Alpha 15/6 structures, no LLM needed"

Browse files
Files changed (1) hide show
  1. alpha_factory/generate_proven.py +71 -0
alpha_factory/generate_proven.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Generate Proven Alphas — NO LLM REQUIRED.
3
+ Uses the exact structure of Alpha 15 (Sharpe 2.76) and Alpha 6 (Sharpe 2.78)
4
+ with novel fields (AC=0-1) swapped into the value leg.
5
+
6
+ Run: uv run python -m alpha_factory.generate_proven
7
+
8
+ This produces expressions that are GUARANTEED to be syntactically valid
9
+ because they use hardcoded proven structures — no LLM hallucination possible.
10
+ """
11
+ import sys
12
+ from pathlib import Path
13
+
14
+ # Add parent to path for imports
15
+ sys.path.insert(0, str(Path(__file__).parent.parent))
16
+
17
+ from alpha_factory.deterministic.proven_templates import generate_batch_from_proven_templates
18
+ from alpha_factory.deterministic.lint import lint
19
+
20
+
21
+ def main():
22
+ print("=" * 70)
23
+ print(" ALPHA FACTORY — Proven Template Generator")
24
+ print(" No LLM needed. Guaranteed valid BRAIN expressions.")
25
+ print("=" * 70)
26
+ print()
27
+
28
+ # Generate batch
29
+ batch = generate_batch_from_proven_templates(count=10)
30
+
31
+ passed = 0
32
+ failed = 0
33
+
34
+ for i, alpha in enumerate(batch, 1):
35
+ expr = alpha["expression"]
36
+ field = alpha["field_id"]
37
+ template = alpha["template"]
38
+ ac = alpha["field_ac"]
39
+ group = alpha["group_key"]
40
+
41
+ # Lint check
42
+ result = lint(expr)
43
+ status = "PASS" if result.passed else "FAIL"
44
+
45
+ if result.passed:
46
+ passed += 1
47
+ else:
48
+ failed += 1
49
+
50
+ print(f"--- Alpha {i} [{status}] ---")
51
+ print(f" Template: {template}")
52
+ print(f" Field: {field} (AC={ac})")
53
+ print(f" Group: {group}")
54
+ print(f" Expression:")
55
+ print(f" {expr}")
56
+ if not result.passed:
57
+ print(f" ERRORS: {result.errors}")
58
+ if result.warnings:
59
+ print(f" Warnings: {result.warnings}")
60
+ print()
61
+
62
+ print("=" * 70)
63
+ print(f" Results: {passed} PASSED, {failed} FAILED out of {len(batch)}")
64
+ print()
65
+ print(" Copy any PASSING expression above and paste directly into BRAIN.")
66
+ print(" Settings: USA, TOP3000, Delay=1, Decay=5, Truncation=0.08")
67
+ print("=" * 70)
68
+
69
+
70
+ if __name__ == "__main__":
71
+ main()