fix(hypotheses): only count successful discovery days in picks_log

This commit is contained in:
Youssef Aitousarrah 2026-04-10 09:50:37 -07:00
parent 1b782b1cd6
commit fe5b8886c0
1 changed files with 39 additions and 23 deletions

View File

@ -64,7 +64,8 @@ def extract_picks(worktree: str, scanner: str) -> list:
data = json.load(f) data = json.load(f)
for item in data.get("final_ranking", []): for item in data.get("final_ranking", []):
if item.get("strategy_match") == scanner: if item.get("strategy_match") == scanner:
picks.append({ picks.append(
{
"date": TODAY, "date": TODAY,
"ticker": item["ticker"], "ticker": item["ticker"],
"score": item.get("final_score"), "score": item.get("final_score"),
@ -72,7 +73,8 @@ def extract_picks(worktree: str, scanner: str) -> list:
"scanner": scanner, "scanner": scanner,
"return_7d": None, "return_7d": None,
"win_7d": None, "win_7d": None,
}) }
)
except Exception as e: except Exception as e:
print(f" Warning: could not read {result_file}: {e}", flush=True) print(f" Warning: could not read {result_file}: {e}", flush=True)
return picks return picks
@ -125,7 +127,13 @@ def run_hypothesis(hyp: dict) -> bool:
try: try:
result = subprocess.run( result = subprocess.run(
[sys.executable, "scripts/run_daily_discovery.py", "--date", TODAY, "--no-update-positions"], [
sys.executable,
"scripts/run_daily_discovery.py",
"--date",
TODAY,
"--no-update-positions",
],
cwd=worktree, cwd=worktree,
check=False, check=False,
) )
@ -171,11 +179,16 @@ def conclude_hypothesis(hyp: dict) -> bool:
else: else:
result = subprocess.run( result = subprocess.run(
[ [
sys.executable, "scripts/compare_hypothesis.py", sys.executable,
"--hypothesis-id", hid, "scripts/compare_hypothesis.py",
"--picks-json", json.dumps(picks), "--hypothesis-id",
"--scanner", scanner, hid,
"--db-path", str(DB_PATH), "--picks-json",
json.dumps(picks),
"--scanner",
scanner,
"--db-path",
str(DB_PATH),
], ],
cwd=str(ROOT), cwd=str(ROOT),
capture_output=True, capture_output=True,
@ -221,12 +234,14 @@ def conclude_hypothesis(hyp: dict) -> bool:
if decision == "accepted": if decision == "accepted":
subprocess.run( subprocess.run(
["gh", "pr", "merge", str(pr), "--squash", "--delete-branch"], ["gh", "pr", "merge", str(pr), "--squash", "--delete-branch"],
cwd=str(ROOT), check=False, cwd=str(ROOT),
check=False,
) )
else: else:
subprocess.run( subprocess.run(
["gh", "pr", "close", str(pr), "--delete-branch"], ["gh", "pr", "close", str(pr), "--delete-branch"],
cwd=str(ROOT), check=False, cwd=str(ROOT),
check=False,
) )
hyp["status"] = "concluded" hyp["status"] = "concluded"
@ -264,7 +279,8 @@ def main():
hypotheses = registry.get("hypotheses", []) hypotheses = registry.get("hypotheses", [])
running = [ running = [
h for h in hypotheses h
for h in hypotheses
if h["status"] == "running" and (not filter_id or h["id"] == filter_id) if h["status"] == "running" and (not filter_id or h["id"] == filter_id)
] ]