> ## Documentation Index
> Fetch the complete documentation index at: https://dexbuilder.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 設定持倉模式

> 開啓或關閉雙向持倉模式

開啓或關閉雙向持倉模式。


## OpenAPI

````yaml openapi/perpdex-zh-TW.yaml POST /dex_futures/{settle}/dual_mode
openapi: 3.0.3
info:
  title: DexBuilder PerpDEX API
  version: 1.0.0
  description: DexBuilder PerpDEX REST API。
servers:
  - url: https://api.dexbuilder.com/api/v1
    description: DexBuilder PerpDEX REST API
security:
  - DexBuilderKey: []
    DexBuilderTimestamp: []
    DexBuilderSignature: []
tags:
  - name: 行情
    description: 永續合約公開行情與市場資料
  - name: 風險資料
    description: 風險限額與市場強平資料
  - name: 帳戶
    description: 帳戶與費率
  - name: 持倉
    description: 持倉查詢與管理
  - name: 訂單
    description: 訂單、成交與批量交易
paths:
  /dex_futures/{settle}/dual_mode:
    post:
      tags:
        - 持倉
      summary: 設定持倉模式
      description: 開啓或關閉雙向持倉模式。切換前需確保沒有持倉及掛單。
      operationId: setPerpPositionMode
      parameters:
        - $ref: '#/components/parameters/Settle'
        - name: dual_mode
          in: query
          required: true
          description: 是否開啓雙向持倉模式
          schema:
            type: boolean
      responses:
        '200':
          description: 設定成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Account'
components:
  parameters:
    Settle:
      name: settle
      in: path
      required: true
      description: 結算幣種
      schema:
        type: string
        enum:
          - usdt
      example: usdt
  schemas:
    Account:
      type: object
      properties:
        user:
          type: integer
          format: int64
          description: 使用者 ID
        currency:
          type: string
          description: 結算幣種
        total:
          type: string
          description: 帳戶權益
        unrealised_pnl:
          type: string
          description: 未實現盈虧
        position_margin:
          type: string
          description: 持倉保證金
        order_margin:
          type: string
          description: 委託保證金
        available:
          type: string
          description: 可用餘額
        in_dual_mode:
          type: boolean
          description: 是否為雙向持倉模式
        cross_available:
          type: string
          description: 全倉可用餘額
        cross_margin_balance:
          type: string
          description: 全倉保證金餘額
      additionalProperties: true
  securitySchemes:
    DexBuilderKey:
      type: apiKey
      in: header
      name: KEY
      description: DexBuilder API Key
    DexBuilderTimestamp:
      type: apiKey
      in: header
      name: Timestamp
      description: Unix 時間戳（秒），與目前時間差不得超過 60 秒
    DexBuilderSignature:
      type: apiKey
      in: header
      name: SIGN
      description: 使用 API Secret 對簽名字串執行 HMAC-SHA512 後的十六進制簽名

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.