account_position_risk
Analyze overall holding risk for your OKX account across margin, futures, swaps, and options to monitor portfolio exposure.
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:286-315 (handler)The handler function for the 'account_position_risk' tool. It calls the OKX AccountAPI to get position risk data based on instrument type and attaches a detailed response schema.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/account.py:282-285 (registration)The @mcp.tool decorator registers the account_position_risk tool with FastMCP inside the add_tools function.@mcp.tool( title="Get account position risk", description="Obtain the overall holding risk of the OKX account", )
- mcp_okx/__init__.py:25-25 (registration)Top-level registration call that invokes add_tools from the account module to register all account-related tools, including account_position_risk.account.add_tools(mcp)
- mcp_okx/account.py:297-314 (schema)The response schema documentation string attached to the API response for the account_position_risk tool.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 """