Skip to content

Commit cf760d4

Browse files
committed
Revert "Merge pull request #25 from paperswithbacktest/codex/improve-llm-to-find-better-trading-strategy"
This reverts commit 57bda36, reversing changes made to d953241.
1 parent a21a983 commit cf760d4

File tree

4 files changed

+11
-48
lines changed

4 files changed

+11
-48
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ python scripts/run_example.py --experiment my_exp
116116
| Data | Zero‑setup loader for any Papers‑With‑Backtest dataset (`pwb_toolbox`) + caching to Feather |
117117
| Strategies | Seed templates with **EVOLVE‑BLOCK** markers that the LLM mutates |
118118
| Evaluator | Deterministic Backtrader walk‑forward, JSON KPIs (Sharpe, CAGR, Calmar, DD) |
119-
| LLM Engine | OpenAI o3 structured‑output chat → JSON diff/patch system; prompts push each child to beat its parent |
120-
| Evolution | Async controller stores a child only when it improves the chosen metric; SQLite hall‑of‑fame, optional MAP‑Elites niches |
119+
| LLM Engine | OpenAI o3 structured‑output chat → JSON diff/patch system |
120+
| Evolution | Async controller, SQLite hall‑of‑fame, optional MAP‑Elites niches |
121121
| Dashboard | (optional) Streamlit live view of metrics & equity curves |
122122

123123
---

alphaevolve/evolution/controller.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -134,26 +134,14 @@ async def _spawn(self, parent_id: str | None, *, prompt: PromptGenome | None = N
134134
logger.error(f"Evaluation failed: {e}")
135135
return
136136

137-
# 5) Persist if improved
138-
parent_metrics = parent.get("metrics") or {}
139-
parent_val = parent_metrics.get(self.metric)
140-
child_val = kpis.get(self.metric)
141-
142-
if child_val is None or parent_val is None or child_val > parent_val:
143-
self.store.insert(
144-
child_code,
145-
kpis,
146-
parent_id=parent["id"],
147-
island=parent.get("island", 0),
148-
)
149-
logger.info("Child stored (%s %.2f)", self.metric, kpis.get(self.metric, 0))
150-
else:
151-
logger.info(
152-
"Discarded child (%s %.2f <= %.2f)",
153-
self.metric,
154-
child_val,
155-
parent_val,
156-
)
137+
# 5) Persist
138+
self.store.insert(
139+
child_code,
140+
kpis,
141+
parent_id=parent["id"],
142+
island=parent.get("island", 0),
143+
)
144+
logger.info("Child stored (%s %.2f)", self.metric, kpis.get(self.metric, 0))
157145

158146
# ------------------------------------------------------------------
159147
# public API

alphaevolve/llm_engine/prompts.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525

2626
SYSTEM_MSG = """\
2727
You are Alpha-Trader Evolution-Engine. You mutate algorithmic-trading
28-
strategies written for Backtrader. Each new iteration should attempt
29-
to outperform its parent based on risk-adjusted metrics. All editable regions are delimited
28+
strategies written for Backtrader. All editable regions are delimited
3029
like this:
3130
3231
# === EVOLVE-BLOCK: <block_name> =================================

tests/test_controller.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -211,27 +211,3 @@ def test_controller_respects_population_limit(tmp_path):
211211
assert store._count() <= 2
212212
finally:
213213
_cleanup(installed)
214-
215-
216-
def test_controller_discards_unimproved_child(tmp_path):
217-
diff = '{"blocks": {"logic": "b = 2"}}'
218-
metrics = {"sharpe": 1.0}
219-
ctrl, store, installed = _setup_controller(tmp_path, diff, metrics)
220-
try:
221-
# first spawn inserts child with sharpe 1.0
222-
asyncio.run(_run_spawn(ctrl))
223-
child_id = store.top_k(k=1)[0]["id"]
224-
225-
# make evaluator return worse metrics
226-
async def evaluate(_code, *, symbols=None):
227-
return {"sharpe": 0.5, "calmar": 0.0, "cagr": 0.0}
228-
229-
sys.modules["alphaevolve.evaluator.backtest"].evaluate = evaluate
230-
231-
# spawn from the existing child
232-
asyncio.run(ctrl._spawn(child_id))
233-
234-
# count should remain 2 since new child discarded
235-
assert store._count() == 2
236-
finally:
237-
_cleanup(installed)

0 commit comments

Comments
 (0)