fix: add TRADING_DAY_ID write to runtime config and improve test coverage

Changes:
- Write TRADING_DAY_ID to runtime config after creating trading_day record in BaseAgent
- Fix datetime deprecation warnings by replacing datetime.utcnow() with datetime.now(timezone.utc)
- Add test for trading_day_id=None fallback path to verify runtime config lookup works correctly

This ensures trade tools can access trading_day_id from runtime config when not explicitly passed.
This commit is contained in:
2025-11-04 09:32:07 -05:00
parent 7d9d093d6c
commit e7fe0ab51b
3 changed files with 88 additions and 3 deletions

View File

@@ -16,7 +16,7 @@ sys.path.insert(0, project_root)
from tools.price_tools import get_open_prices
import json
from api.database import get_db_connection
from datetime import datetime
from datetime import datetime, timezone
mcp = FastMCP("TradeTools")
@@ -158,7 +158,7 @@ def _buy_impl(symbol: str, amount: int, signature: str = None, today_date: str =
if trading_day_id is None:
raise ValueError("trading_day_id not found in runtime config")
created_at = datetime.utcnow().isoformat() + "Z"
created_at = datetime.now(timezone.utc).isoformat()
cursor.execute("""
INSERT INTO actions (
@@ -273,7 +273,7 @@ def _sell_impl(symbol: str, amount: int, signature: str = None, today_date: str
if trading_day_id is None:
raise ValueError("trading_day_id not found in runtime config")
created_at = datetime.utcnow().isoformat() + "Z"
created_at = datetime.now(timezone.utc).isoformat()
cursor.execute("""
INSERT INTO actions (