mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-04 01:57:25 -04:00
feat: migrate trade tools to write to actions table (new schema)
This commit implements Task 1 from the schema migration plan: - Trade tools (buy/sell) now write to actions table instead of old positions table - Added trading_day_id parameter to buy/sell functions - Updated ContextInjector to inject trading_day_id - Updated RuntimeConfigManager to include TRADING_DAY_ID in config - Removed P&L calculation from trade functions (now done at trading_days level) - Added tests verifying correct behavior with new schema Changes: - agent_tools/tool_trade.py: Modified _buy_impl and _sell_impl to write to actions table - agent/context_injector.py: Added trading_day_id parameter and injection logic - api/model_day_executor.py: Updated to read trading_day_id from runtime config - api/runtime_manager.py: Added trading_day_id to config initialization - tests/unit/test_trade_tools_new_schema.py: New tests for new schema compliance All tests passing.
This commit is contained in:
@@ -48,7 +48,8 @@ class RuntimeConfigManager:
|
||||
self,
|
||||
job_id: str,
|
||||
model_sig: str,
|
||||
date: str
|
||||
date: str,
|
||||
trading_day_id: int = None
|
||||
) -> str:
|
||||
"""
|
||||
Create isolated runtime config file for this execution.
|
||||
@@ -57,6 +58,7 @@ class RuntimeConfigManager:
|
||||
job_id: Job UUID
|
||||
model_sig: Model signature
|
||||
date: Trading date (YYYY-MM-DD)
|
||||
trading_day_id: Trading day record ID (optional, can be set later)
|
||||
|
||||
Returns:
|
||||
Path to created runtime config file
|
||||
@@ -79,7 +81,8 @@ class RuntimeConfigManager:
|
||||
"TODAY_DATE": date,
|
||||
"SIGNATURE": model_sig,
|
||||
"IF_TRADE": False,
|
||||
"JOB_ID": job_id
|
||||
"JOB_ID": job_id,
|
||||
"TRADING_DAY_ID": trading_day_id
|
||||
}
|
||||
|
||||
with open(config_path, "w", encoding="utf-8") as f:
|
||||
|
||||
Reference in New Issue
Block a user