Spaces:
Runtime error
Runtime error
Download optimizer/tools.py from mathidot111/First_agent_template: direct link, hf CLI and curl.
- Browser
- Download file 966 Bytes
-
https://huggingface.co/spaces/mathidot111/First_agent_template/resolve/main/optimizer/tools.py
- Command line
-
hf download hf://spaces/mathidot111/First_agent_template/optimizer/tools.py
-
curl -L -o tools.py https://huggingface.co/spaces/mathidot111/First_agent_template/resolve/main/optimizer/tools.py
966 Bytes
| from __future__ import annotations | |
| import json | |
| from smolagents import tool | |
| from market_data.providers import get_price_history | |
| from .vol_optimizer import optimize_volatility_signal | |
| def optimize_volatility_signal_parameters( | |
| symbol: str, | |
| signal: str = "long_vol", | |
| period: str = "3y", | |
| ) -> str: | |
| """Scan simple realized-volatility signal parameters and compare best vs baseline. | |
| Args: | |
| symbol: Yahoo Finance ticker. | |
| signal: long_vol or short_vol. | |
| period: Yahoo Finance history period. | |
| """ | |
| try: | |
| history = get_price_history(symbol, period=period, interval="1d") | |
| result = optimize_volatility_signal(history["Close"], signal=signal) | |
| return json.dumps({"status": "success", "symbol": symbol.upper(), **result}, ensure_ascii=False, indent=2) | |
| except Exception as exc: | |
| return json.dumps({"status": "error", "symbol": symbol, "message": str(exc)}, ensure_ascii=False, indent=2) | |