From 9b98594c07ba10d2cc083a152e16cc59cbc7c112 Mon Sep 17 00:00:00 2001 From: OpenSquared Date: Mon, 22 Jun 2026 17:11:23 +0200 Subject: [PATCH] =?UTF-8?q?fix:=203=20bugs=20from=20system=20logs=20?= =?UTF-8?q?=E2=80=94=20timedelta,=20scoring=20IndexError,=20lxml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - database.py: add timedelta to datetime import (used in get_recent_economic_surprises, was raising NameError) - ai_analyzer.py: scoring split was searching French string 'Retourne UNIQUEMENT ce JSON valide:' but prompt is now in English 'Return ONLY this valid JSON:' — caused IndexError crashing every cycle - requirements.txt: add lxml>=5.0.0 (yfinance earnings_dates dependency, was silently failing all 23 ticker fetches every hour) Co-Authored-By: Claude Sonnet 4.6 --- backend/requirements.txt | 1 + backend/services/ai_analyzer.py | 4 +++- backend/services/database.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/requirements.txt b/backend/requirements.txt index 429cf19..ff46e02 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -18,3 +18,4 @@ python-multipart==0.0.12 apscheduler==3.10.4 pytz==2024.2 ta==0.11.0 +lxml>=5.0.0 diff --git a/backend/services/ai_analyzer.py b/backend/services/ai_analyzer.py index c7b053a..4388384 100644 --- a/backend/services/ai_analyzer.py +++ b/backend/services/ai_analyzer.py @@ -738,7 +738,9 @@ Return ONLY this valid JSON: # Extract the return-schema portion from `user` so batches use the identical full schema # (includes bucket id/label/max definitions that GPT-4o needs to populate correctly) - _return_schema = user.split("Retourne UNIQUEMENT ce JSON valide:\n", 1)[1] + _split_key = "Return ONLY this valid JSON:\n" + _parts = user.split(_split_key, 1) + _return_schema = _parts[1] if len(_parts) == 2 else user # Build lessons feedback block for the scorer lessons_header = "" diff --git a/backend/services/database.py b/backend/services/database.py index 91190d2..edbe761 100644 --- a/backend/services/database.py +++ b/backend/services/database.py @@ -4,7 +4,7 @@ SQLite persistence layer for portfolio positions, custom patterns, and config. import sqlite3 import json import os -from datetime import datetime +from datetime import datetime, timedelta from typing import List, Dict, Any, Optional DB_PATH = os.path.join(os.path.dirname(__file__), "..", "data", "geooptions.db")