From 0bb5086df1540ceed8b30df8cd02c0b33cce5b6f Mon Sep 17 00:00:00 2001 From: tianyufan Date: Thu, 30 Oct 2025 14:40:42 +0800 Subject: [PATCH] update tools --- agent_tools/tool_get_price_local.py | 55 +---------------------------- 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/agent_tools/tool_get_price_local.py b/agent_tools/tool_get_price_local.py index 0e4c4c9..1cf9466 100644 --- a/agent_tools/tool_get_price_local.py +++ b/agent_tools/tool_get_price_local.py @@ -8,7 +8,7 @@ from dotenv import load_dotenv load_dotenv() mcp = FastMCP("LocalPrices") - +from tools.general_tools import get_config_value def _workspace_data_path(filename: str) -> Path: base_dir = Path(__file__).resolve().parents[1] @@ -75,61 +75,8 @@ def get_price_local(symbol: str, date: str) -> Dict[str, Any]: return {"error": f"No records found for stock {symbol} in local data", "symbol": symbol, "date": date} - -def get_price_local_function(symbol: str, date: str, filename: str = "merged.jsonl") -> Dict[str, Any]: - """Read OHLCV data for specified stock and date from local JSONL data. - - Args: - symbol: Stock symbol, e.g. 'IBM' or '600243.SHH'. - date: Date in 'YYYY-MM-DD' format. - filename: Data filename, defaults to 'merged.jsonl' (located in data/ under project root). - - Returns: - Dictionary containing symbol, date and ohlcv data. - """ - try: - _validate_date(date) - except ValueError as e: - return {"error": str(e), "symbol": symbol, "date": date} - - data_path = _workspace_data_path(filename) - if not data_path.exists(): - return {"error": f"Data file not found: {data_path}", "symbol": symbol, "date": date} - - with data_path.open("r", encoding="utf-8") as f: - for line in f: - if not line.strip(): - continue - doc = json.loads(line) - meta = doc.get("Meta Data", {}) - if meta.get("2. Symbol") != symbol: - continue - series = doc.get("Time Series (Daily)", {}) - day = series.get(date) - if day is None: - sample_dates = sorted(series.keys(), reverse=True)[:5] - return { - "error": f"Data not found for date {date}. Please verify the date exists in data. Sample available dates: {sample_dates}", - "symbol": symbol, - "date": date - } - return { - "symbol": symbol, - "date": date, - "ohlcv": { - "buy price": day.get("1. buy price"), - "high": day.get("2. high"), - "low": day.get("3. low"), - "sell price": day.get("4. sell price"), - "volume": day.get("5. volume"), - }, - } - - return {"error": f"No records found for stock {symbol} in local data", "symbol": symbol, "date": date} - if __name__ == "__main__": # print("a test case") - # print(get_price_local_function("AAPL", "2025-10-16")) port = int(os.getenv("GETPRICE_HTTP_PORT", "8003")) mcp.run(transport="streamable-http", port=port)