account_position_risk
Analyze overall holding risk for your OKX account across margin, futures, swaps, and options to monitor portfolio exposure and manage trading positions effectively.
Instructions
Obtain the overall holding risk of the OKX account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instType | No | Instrument type: `MARGIN`: 币币杠杆/`SWAP`: 永续合约/`FUTURES`: 交割合约/`OPTION`: 期权. Optional, all by default if not passed |
Implementation Reference
- mcp_okx/account.py:282-285 (registration)Registers the account_position_risk tool with the FastMCP server using the @mcp.tool decorator, providing title and description.@mcp.tool( title="Get account position risk", description="Obtain the overall holding risk of the OKX account", )
- mcp_okx/account.py:286-315 (handler)The handler function for account_position_risk tool. Accepts optional instType parameter with schema description. Calls OKX AccountAPI.get_position_risk(instType), handles error response, and attaches a detailed _response_schema string describing the output fields.def account_position_risk( instType: str = Field("", description="Instrument type: " "`MARGIN`: 币币杠杆/" "`SWAP`: 永续合约/" "`FUTURES`: 交割合约/" "`OPTION`: 期权. " "Optional, all by default if not passed"), ): resp = ACCOUNT.get_position_risk(instType) or {} if int(resp.get("code", 0)): return resp resp["_response_schema"] = """ adjEq: Adjusted / Effective equity in USD. Applicable to Multi-currency margin and Portfolio margin balData: Detailed asset information in all currencies balData.ccy: Currency balData.eq: Equity of currency balData.disEq: Discount equity of currency in USD posData: Detailed position information in all currencies posData.mgnMode: Margin mode: cross/isolated posData.instId: Instrument ID, e.g. BTC-USDT-SWAP posData.pos: Quantity of positions contract. In the isolated margin mode, when doing manual transfers, a position with pos of 0 will be generated after the deposit is transferred posData.posSide: Position side: long/short net (FUTURES/SWAP/OPTION: positive pos means long position and negative pos means short position. MARGIN: posCcy being base currency means long position, posCcy being quote currency means short position.) posData.posCcy: Position currency, only applicable to MARGIN positions posData.ccy: Currency used for margin posData.notionalCcy: Notional value of positions in coin posData.notionalUsd: Notional value of positions in USD """ return resp
- mcp_okx/__init__.py:25-25 (registration)Calls account.add_tools(mcp) which executes the decorators to register the account_position_risk tool and other account tools.account.add_tools(mcp)
- mcp_okx/account.py:287-292 (schema)Input schema definition for the instType parameter using Pydantic Field, describing possible instrument types.instType: str = Field("", description="Instrument type: " "`MARGIN`: 币币杠杆/" "`SWAP`: 永续合约/" "`FUTURES`: 交割合约/" "`OPTION`: 期权. " "Optional, all by default if not passed"),
- mcp_okx/account.py:297-314 (schema)Output response schema documentation attached to the response as _response_schema, detailing fields like adjEq, balData, posData etc.resp["_response_schema"] = """ adjEq: Adjusted / Effective equity in USD. Applicable to Multi-currency margin and Portfolio margin balData: Detailed asset information in all currencies balData.ccy: Currency balData.eq: Equity of currency balData.disEq: Discount equity of currency in USD posData: Detailed position information in all currencies posData.mgnMode: Margin mode: cross/isolated posData.instId: Instrument ID, e.g. BTC-USDT-SWAP posData.pos: Quantity of positions contract. In the isolated margin mode, when doing manual transfers, a position with pos of 0 will be generated after the deposit is transferred posData.posSide: Position side: long/short net (FUTURES/SWAP/OPTION: positive pos means long position and negative pos means short position. MARGIN: posCcy being base currency means long position, posCcy being quote currency means short position.) posData.posCcy: Position currency, only applicable to MARGIN positions posData.ccy: Currency used for margin posData.notionalCcy: Notional value of positions in coin posData.notionalUsd: Notional value of positions in USD """