mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-11 05:07:25 -04:00
fix: resolve async execution and position storage issues
- Fix async call in model_day_executor.py by wrapping with asyncio.run() Resolves RuntimeWarning where run_trading_session coroutine was never awaited - Remove register_agent() call in API mode to prevent file-based position storage Position data is now stored exclusively in SQLite database (jobs.db) - Update test mocks to use AsyncMock for async run_trading_session method This fixes production deployment issues: 1. Trading sessions now execute properly (async bug) 2. No position files created, database-only storage 3. All tests pass Closes issue with no trades being executed in production
This commit is contained in:
@@ -14,7 +14,7 @@ Tests verify:
|
||||
|
||||
import pytest
|
||||
import json
|
||||
from unittest.mock import Mock, patch, MagicMock
|
||||
from unittest.mock import Mock, patch, MagicMock, AsyncMock
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ def create_mock_agent(positions=None, last_trade=None, current_prices=None,
|
||||
mock_agent.get_current_prices.return_value = current_prices or {}
|
||||
mock_agent.get_reasoning_steps.return_value = reasoning_steps or []
|
||||
mock_agent.get_tool_usage.return_value = tool_usage or {}
|
||||
mock_agent.run_trading_session.return_value = session_result or {"success": True}
|
||||
# run_trading_session is async, so use AsyncMock
|
||||
mock_agent.run_trading_session = AsyncMock(return_value=session_result or {"success": True})
|
||||
|
||||
return mock_agent
|
||||
|
||||
|
||||
Reference in New Issue
Block a user