From 4c1d23a7c8a44e78f561d0ae459b34360f652f34 Mon Sep 17 00:00:00 2001 From: Bill Date: Sun, 2 Nov 2025 22:26:45 -0500 Subject: [PATCH] fix: correct get_db_path() usage to pass base database path The get_db_path() function requires a base_db_path argument to properly resolve PROD vs DEV database paths. Updated all calls to pass "data/jobs.db" as the base path. Changes: - agent_tools/tool_trade.py: Fix 3 occurrences (lines 33, 113, 236) - tools/price_tools.py: Fix 2 occurrences in new database functions - Remove unused get_db_path import from tool_trade.py This fixes TypeError when running simulations: get_db_path() missing 1 required positional argument: 'base_db_path' The get_db_connection() function internally calls get_db_path() to resolve the correct database path based on DEPLOYMENT_MODE. --- agent_tools/tool_trade.py | 7 +++---- tools/price_tools.py | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/agent_tools/tool_trade.py b/agent_tools/tool_trade.py index f25405c..f04dce0 100644 --- a/agent_tools/tool_trade.py +++ b/agent_tools/tool_trade.py @@ -7,7 +7,6 @@ project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, project_root) from tools.price_tools import get_open_prices import json -from tools.deployment_config import get_db_path from api.database import get_db_connection from datetime import datetime mcp = FastMCP("TradeTools") @@ -30,7 +29,7 @@ def get_current_position_from_db(job_id: str, model: str, date: str) -> Tuple[Di Raises: Exception: If database query fails """ - db_path = get_db_path() + db_path = "data/jobs.db" conn = get_db_connection(db_path) cursor = conn.cursor() @@ -110,7 +109,7 @@ def buy(symbol: str, amount: int, signature: str = None, today_date: str = None, if not today_date: return {"error": "Missing required parameter: today_date"} - db_path = get_db_path() + db_path = "data/jobs.db" conn = get_db_connection(db_path) cursor = conn.cursor() @@ -233,7 +232,7 @@ def sell(symbol: str, amount: int, signature: str = None, today_date: str = None if not today_date: return {"error": "Missing required parameter: today_date"} - db_path = get_db_path() + db_path = "data/jobs.db" conn = get_db_connection(db_path) cursor = conn.cursor() diff --git a/tools/price_tools.py b/tools/price_tools.py index 3386fd0..f25b1b0 100644 --- a/tools/price_tools.py +++ b/tools/price_tools.py @@ -320,12 +320,11 @@ def get_today_init_position_from_db( If no position exists: {"CASH": 10000.0} (initial cash) """ import logging - from tools.deployment_config import get_db_path from api.database import get_db_connection logger = logging.getLogger(__name__) - db_path = get_db_path() + db_path = "data/jobs.db" conn = get_db_connection(db_path) cursor = conn.cursor() @@ -385,14 +384,13 @@ def add_no_trade_record_to_db( session_id: Trading session ID """ import logging - from tools.deployment_config import get_db_path from api.database import get_db_connection from agent_tools.tool_trade import get_current_position_from_db from datetime import datetime logger = logging.getLogger(__name__) - db_path = get_db_path() + db_path = "data/jobs.db" conn = get_db_connection(db_path) cursor = conn.cursor()