abort_backtest
Stop a running backtest in the Freqtrade trading bot to halt simulation and free resources for other tasks.
Instructions
Abort currently running backtest task.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- __main__.py:385-389 (handler)The handler function for the abort_backtest tool. It retrieves the Freqtrade REST client from the context and calls the backtest/abort endpoint to abort a running backtest task.
@mcp.tool() def abort_backtest(ctx: Context) -> str: """Abort currently running backtest task.""" client: FtRestClient = ctx.request_context.lifespan_context["client"] return str(_client_get(client, "backtest/abort")) - __main__.py:385-389 (registration)The @mcp.tool() decorator registers the abort_backtest function as an MCP tool with the FastMCP server instance.
@mcp.tool() def abort_backtest(ctx: Context) -> str: """Abort currently running backtest task.""" client: FtRestClient = ctx.request_context.lifespan_context["client"] return str(_client_get(client, "backtest/abort")) - __main__.py:37-47 (helper)Helper utilities for calling Freqtrade REST client methods. _call_client_method provides version compatibility by trying multiple method names, and _client_get wraps it for HTTP GET requests.
def _call_client_method(client: FtRestClient, method_names: List[str], *args, **kwargs): """Call first matching client method to support multiple freqtrade-client versions.""" for method_name in method_names: method = getattr(client, method_name, None) if callable(method): return method(*args, **kwargs) raise AttributeError(f"No supported method found in {method_names}") def _client_get(client: FtRestClient, path: str, params: Dict[str, Any] | None = None): return _call_client_method(client, ["_get"], path, params=params) - __main__.py:6-6 (schema)Import of Context type from MCP FastMCP library, used for type annotation in the abort_backtest function signature to provide access to request context and lifespan-managed client.
from mcp.server.fastmcp import FastMCP, Context