mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-02 01:27:24 -04:00
Compare commits
1 Commits
v0.3.0-alp
...
v0.3.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
| 396a2747d3 |
@@ -11,6 +11,7 @@ This module provides:
|
||||
|
||||
import logging
|
||||
import os
|
||||
import asyncio
|
||||
from typing import Dict, Any, Optional, List, TYPE_CHECKING
|
||||
from pathlib import Path
|
||||
|
||||
@@ -118,7 +119,7 @@ class ModelDayExecutor:
|
||||
|
||||
# Run trading session
|
||||
logger.info(f"Running trading session for {self.model_sig} on {self.date}")
|
||||
session_result = agent.run_trading_session(self.date)
|
||||
session_result = asyncio.run(agent.run_trading_session(self.date))
|
||||
|
||||
# Persist results to SQLite
|
||||
self._write_results_to_db(agent, session_result)
|
||||
@@ -211,8 +212,10 @@ class ModelDayExecutor:
|
||||
init_date=config.get("date_range", {}).get("init_date", "2025-10-13")
|
||||
)
|
||||
|
||||
# Register agent (creates initial position if needed)
|
||||
agent.register_agent()
|
||||
# Note: In API mode, we don't call register_agent() because:
|
||||
# - Position data is stored in SQLite database, not files
|
||||
# - Database initialization is handled by JobManager
|
||||
# - File-based position tracking is only for standalone/CLI mode
|
||||
|
||||
return agent
|
||||
|
||||
|
||||
@@ -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