Skip to main content
Glama
Habinar

MCP Paradex Server

by Habinar

paradex_create_order

Execute trading orders on Paradex with precision, allowing control over order type, size, price, and execution parameters. Ideal for entering positions, managing risk with stop-loss or take-profit orders, and implementing complex strategies.

Instructions

Execute trades on Paradex with precise control over all order parameters. Use this tool when you need to: - Enter a new position based on your trading strategy - Set limit orders at specific price levels - Create stop-loss or take-profit orders for risk management - Implement complex trading strategies with conditional orders This is the primary tool for executing your trading decisions on Paradex, with full control over order type, size, price, and execution parameters. Example use cases: - Setting limit orders at key support/resistance levels - Placing stop-limit orders to manage risk on existing positions - Executing market orders for immediate entry or exit - Creating reduce-only orders to ensure you don't flip position direction Succesful response indicates that orders were queued for execution. Check order status using order id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
client_idYesClient-specified order ID.
instructionNoInstruction for order execution.GTC
market_idYesMarket identifier.
order_sideYesOrder side.
order_typeYesOrder type.
priceYesOrder price (required for LIMIT orders).
reduce_onlyNoReduce-only flag.
sizeYesOrder size.
trigger_priceYesTrigger price for stop limit orders.

Implementation Reference

  • Main handler function for the paradex_create_order tool. Decorated with @server.tool for registration. Validates inputs via Annotated Pydantic fields, constructs Order object, submits via Paradex client, and returns formatted OrderState.
    @server.tool(name="paradex_create_order") async def create_order( market_id: Annotated[str, Field(description="Market identifier.")], order_side: Annotated[OrderSideEnum, Field(description="Order side.")], order_type: Annotated[OrderTypeEnum, Field(description="Order type.")], size: Annotated[float, Field(description="Order size.")], price: Annotated[float, Field(description="Order price (required for LIMIT orders).")], trigger_price: Annotated[float, Field(description="Trigger price for stop limit orders.")], instruction: Annotated[ InstructionEnum, Field(default="GTC", description="Instruction for order execution.") ], reduce_only: Annotated[bool, Field(default=False, description="Reduce-only flag.")], client_id: Annotated[str, Field(description="Client-specified order ID.")], ctx: Context = None, ) -> dict: """ Execute trades on Paradex with precise control over all order parameters. Use this tool when you need to: - Enter a new position based on your trading strategy - Set limit orders at specific price levels - Create stop-loss or take-profit orders for risk management - Implement complex trading strategies with conditional orders This is the primary tool for executing your trading decisions on Paradex, with full control over order type, size, price, and execution parameters. Example use cases: - Setting limit orders at key support/resistance levels - Placing stop-limit orders to manage risk on existing positions - Executing market orders for immediate entry or exit - Creating reduce-only orders to ensure you don't flip position direction Succesful response indicates that orders were queued for execution. Check order status using order id. """ client = await get_authenticated_paradex_client() o = Order( market=market_id, order_side=OrderSide(order_side), order_type=OrderType(order_type), size=Decimal(str(size)), client_id=client_id, limit_price=Decimal(str(price)) if price else Decimal(0), reduce_only=reduce_only, instruction=instruction, trigger_price=Decimal(str(trigger_price)) if trigger_price else None, ) response = client.submit_order(o) order: OrderState = OrderState(**response) result = { "description": OrderState.__doc__.strip() if OrderState.__doc__ else None, "fields": OrderState.model_json_schema(), "results": order, } return result
  • Tool registration decorator specifying the name 'paradex_create_order'.
    @server.tool(name="paradex_create_order")
  • Enum definitions (Literals) for tool input parameters: OrderTypeEnum, InstructionEnum, OrderSideEnum.
    # Define allowed order types OrderTypeEnum = Literal[ "MARKET", "LIMIT", "STOP_LIMIT", "STOP_MARKET", "TAKE_PROFIT_LIMIT", "TAKE_PROFIT_MARKET", "STOP_LOSS_MARKET", "STOP_LOSS_LIMIT", ] # Define allowed instruction types InstructionEnum = Literal["GTC", "IOC", "POST_ONLY"] OrderSideEnum = Literal["BUY", "SELL"]
  • Pydantic model OrderState used for output schema and validation in the tool response.
    class OrderState(BaseModel): """Order state model representing the current state of an order on Paradex.""" id: Annotated[str, Field(description="Unique order identifier generated by Paradex")] account: Annotated[str, Field(description="Paradex Account")] market: Annotated[str, Field(description="Market")] side: Annotated[str, Field(description="Order side")] type: Annotated[str, Field(description="Order type")] size: Annotated[float, Field(description="Order size")] remaining_size: Annotated[float, Field(description="Remaining size of the order")] price: Annotated[float, Field(description="Order price. 0 for MARKET orders")] status: Annotated[str, Field(description="Order status")] created_at: Annotated[int, Field(description="Order creation time")] last_updated_at: Annotated[ int, Field(description="Order last update time. No changes once status=CLOSED") ] timestamp: Annotated[int, Field(description="Order signature timestamp")] cancel_reason: Annotated[ str, Field(description="Reason for order cancellation if it was closed by cancel") ] client_id: Annotated[ str, Field(description="Client order id provided by the client at order creation") ] seq_no: Annotated[ int, Field( description="Unique increasing number that is assigned to this order update and changes on every order update" ), ] instruction: Annotated[str, Field(description="Execution instruction for order matching")] avg_fill_price: Annotated[str, Field(description="Average fill price of the order")] stp: Annotated[str, Field(description="Self Trade Prevention mode")] received_at: Annotated[ int, Field(description="Timestamp in milliseconds when order was received by API service") ] published_at: Annotated[ int, Field(description="Timestamp in milliseconds when order was sent to the client") ] flags: Annotated[list[str], Field(description="Order flags, allow flag: REDUCE_ONLY")] trigger_price: Annotated[str, Field(description="Trigger price for stop order")]
  • Helper function to retrieve or create an authenticated ParadexApiClient instance, used in the handler to submit orders.
    async def get_authenticated_paradex_client() -> ParadexApiClient: """ Get or initialize the authenticated Paradex client. Returns: Paradex: The initialized Paradex client. Raises: ValueError: If the required configuration is not set. """ client = await get_paradex_client() if client.account is None: raise ValueError("Paradex client is not authenticated") return client async def api_call( client: ParadexApiClient, path: str, params: dict[str, Any] | None = None ) -> dict[str, Any]: """ Make a direct API call to Paradex. Args: client: The Paradex client instance. path: The API path to call. params: Optional parameters for the API call. Returns: Dict[str, Any]: The response from the API call. """ try: logger.info(f"Calling {path} with params: {params}")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Habinar/mcp-paradex-py'

If you have feedback or need assistance with the MCP directory API, please join our Discord server