paradex_orders_history
Retrieve and analyze historical orders, including filled, canceled, and expired trades, to evaluate past trading activity and performance.
Instructions
Get historical orders.
Retrieves the history of orders for the account, including filled, canceled, and expired orders. This is useful for analyzing past trading activity and performance.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end_unix_ms | Yes | End time in unix milliseconds. | |
| market_id | Yes | Filter by market. | |
| start_unix_ms | Yes | Start time in unix milliseconds. |
Implementation Reference
- src/mcp_paradex/tools/orders.py:231-259 (handler)The main handler function for the paradex_orders_history tool. It authenticates a Paradex client, fetches historical orders with specified parameters, validates the response using OrderState model adapter, and returns a formatted result dictionary.@server.tool(name="paradex_orders_history") async def get_orders_history( market_id: Annotated[str, Field(description="Filter by market.")], start_unix_ms: Annotated[int, Field(description="Start time in unix milliseconds.")], end_unix_ms: Annotated[int, Field(description="End time in unix milliseconds.")], ctx: Context = None, ) -> dict: """ Get historical orders. Retrieves the history of orders for the account, including filled, canceled, and expired orders. This is useful for analyzing past trading activity and performance. """ client = await get_authenticated_paradex_client() params = {"market": market_id, "start_at": start_unix_ms, "end_at": end_unix_ms} # Remove None values from params params = {k: v for k, v in params.items() if v is not None} response = client.fetch_orders_history(params=params) if "error" in response: await ctx.error(response) raise Exception(response["error"]) orders_raw: list[dict[str, Any]] = response["results"] orders = order_state_adapter.validate_python(orders_raw) result = { "description": OrderState.__doc__.strip() if OrderState.__doc__ else None, "fields": OrderState.model_json_schema(), "results": orders, } return result
- Schema registration for the paradex_orders_history tool within the paradex_filters_model tool, referencing models.OrderState.model_json_schema() for input/output validation.tool_descriptions = { "paradex_markets": models.MarketDetails.model_json_schema(), "paradex_market_summaries": models.MarketSummary.model_json_schema(), "paradex_open_orders": models.OrderState.model_json_schema(), "paradex_orders_history": models.OrderState.model_json_schema(), "paradex_vaults": models.Vault.model_json_schema(), "paradex_vault_summary": models.VaultSummary.model_json_schema(), } return tool_descriptions[tool_name]