mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-04 18:07:24 -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:
@@ -138,11 +138,15 @@ class ModelDayExecutor:
|
||||
|
||||
# Create and inject context with correct values
|
||||
from agent.context_injector import ContextInjector
|
||||
from tools.general_tools import get_config_value
|
||||
trading_day_id = get_config_value('TRADING_DAY_ID') # Get from runtime config
|
||||
|
||||
context_injector = ContextInjector(
|
||||
signature=self.model_sig,
|
||||
today_date=self.date, # Current trading day
|
||||
job_id=self.job_id,
|
||||
session_id=session_id
|
||||
session_id=session_id,
|
||||
trading_day_id=trading_day_id
|
||||
)
|
||||
logger.info(f"[DEBUG] ModelDayExecutor: Created ContextInjector with signature={self.model_sig}, date={self.date}, job_id={self.job_id}, session_id={session_id}")
|
||||
logger.info(f"[DEBUG] ModelDayExecutor: Calling await agent.set_context()")
|
||||
|
||||
Reference in New Issue
Block a user