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

# Chi tiết vị thế theo ID



## OpenAPI

````yaml /vi/openapi/dnse.2026-09-10.openapi.yaml get /positions/{positionId}
openapi: 3.0.0
info:
  title: DNSE OpenAPI (2026-09-10)
  version: 2.0.0
  description: DNSE OpenAPI spec
servers:
  - url: https://openapi.dnse.com.vn
    description: Production
  - url: https://sb-openapi.dnse.com.vn
    description: Sanbox
security: []
tags:
  - name: trading
    description: Xác thực và các hoạt động đặt lệnh.
    x-group: Giao dịch
  - name: account
    description: Tài khoản, số dư, khoản vay, lệnh và vị thế.
    x-group: Tài khoản
  - name: market
    description: Thông tin mã chứng khoán, báo giá, OHLC và giao dịch.
    x-group: Dữ liệu thị trường
paths:
  /positions/{positionId}:
    parameters:
      - name: positionId
        in: path
        required: true
        description: 'Id vị thế '
        deprecated: false
        schema:
          type: string
        example: '177410795472387'
    get:
      tags:
        - account
      summary: Chi tiết vị thế theo ID
      operationId: account_getPosition
      parameters:
        - $ref: '#/components/parameters/XApiKey'
        - $ref: '#/components/parameters/XAuxDate'
        - $ref: '#/components/parameters/XSignature'
        - name: marketType
          in: query
          required: true
          description: |-
            Loại thị trường 
            - STOCK: Danh sách Deal cơ sở
            - DERIVATIVE: Danh sách Deal phái sinh
            - BOND: Danh sách Deal trái phiếu
          deprecated: false
          schema:
            $ref: '#/components/schemas/MarketType'
          example: DERIVATIVE
      responses:
        '200':
          description: OK
          headers:
            Content-Length:
              $ref: '#/components/headers/ContentLength'
            Date:
              $ref: '#/components/headers/Date'
            Vary:
              $ref: '#/components/headers/Vary'
            X-Ratelimit-Limit:
              $ref: '#/components/headers/XRateLimitLimit'
            X-Ratelimit-Remaining:
              $ref: '#/components/headers/XRateLimitRemaining'
            X-Ratelimit-Reset:
              $ref: '#/components/headers/XRateLimitReset'
            X-Tyk-Api-Expires:
              deprecated: false
              schema: {}
              example: Thu, 02 Jan 3000 15:04:00 UTC
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PositionDetailResponse'
              example:
                data:
                  id: 177410795472387
                  symbol: 41I1G4000
                  marketType: DERIVATIVE
                  accountNo: '0001179019'
                  status: OPEN
                  loanPackageId: 2278
                  side: NB
                  accumulateQuantity: 6
                  tradeQuantity: 1
                  closedQuantity: 5
                  openQuantity: 1
                  overNightQuantity: 0
                  costPrice: 1834.5
                  averageCostPrice: 1834.5
                  averageClosePrice: 1750.96
                  marketPrice: 1706.1
                  breakEvenPrice: 1834.95691
                  createdDate: '2026-03-23T03:08:32.773651Z'
                  modifiedDate: '2026-03-23T04:07:45.692156Z'
        '400':
          $ref: '#/components/responses/BadRequest'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    XApiKey:
      name: X-Api-Key
      in: header
      required: true
      description: >-
        API key được cấp khi đăng ký dịch vụ DNSE OpenAPI.

        Ví dụ:
        `b3JnOmRuc2UgaWQ6MjdlZTc1MzcxZGFkNTY0NmYzYTM2NDk1ZGE3OGNiOGQgaDptdXJtdXIxMjg=`
      schema:
        type: string
    XAuxDate:
      name: X-Aux-Date
      in: header
      required: true
      description: |-
        Thời gian thực hiện request, dùng trong cơ chế ký request của DNSE.
        Ví dụ: `Sat, 01 May 2026 14:24:23 +0000`
      schema:
        type: string
    XSignature:
      name: X-Signature
      in: header
      required: true
      description: >-
        Chữ ký xác thực request được tạo từ API key secret và X-Aux-Date.

        Ví dụ: `Signature
        keyId="b3JnOmRuc2UgaWQ6MjdlZTc1MzcxZGFkNTY0NmYzYTM2NDk1ZGE3OGNiOGQgaDptdXJtdXIxMjg=",algorithm="hmac-sha256",headers="(request-target)
        x-aux-date",signature="rfbVXHDUi%2B%2FsOkLXle7O17Qm%2F05cbISSR%2BDcFrBHfqQ%3D",nonce="4add8c3264e4492b9f8ecde0cf26b523"`
      schema:
        type: string
  schemas:
    MarketType:
      type: string
      description: |-
        Loại thị trường.

        - `STOCK`: Giao dịch cơ sở
        - `DERIVATIVE`: Giao dịch phái sinh
        - `BOND`: Giao dịch trái phiếu
      enum:
        - STOCK
        - DERIVATIVE
        - BOND
      x-enum-descriptions:
        - Giao dịch cơ sở
        - Giao dịch phái sinh
        - Giao dịch trái phiếu
      x-enum-varnames:
        - STOCK
        - DERIVATIVE
        - BOND
      example: STOCK
    PositionDetailResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/PositionDetail'
        id:
          type: integer
          format: int32
          example: 9589
          description: ID vị thế
        symbol:
          type: string
          example: BVS
          description: Mã chứng khoán
        accountNo:
          type: string
          example: '0001179019'
          description: Số tiểu khoản
        status:
          allOf:
            - $ref: '#/components/schemas/PositionStatus'
          example: OPEN
          description: |-
            Trạng thái của vị thế
            - OPEN: Đang mở
            - PENDING_CLOSE: Chờ đóng
            - CLOSED: Đã đóng
            - ODD_LOT: Lô lẻ (cơ sở)
        loanPackageId:
          type: integer
          format: int32
          example: 5757
          description: Gói vay cơ sở hoặc phái sinh
        side:
          allOf:
            - $ref: '#/components/schemas/OrderSide'
          example: NB
          description: |-
            Loại vị thế
            - NB: Mua
            - NS: Bán
        accumulateQuantity:
          type: integer
          format: int32
          example: 3400
          description: Khối lượng cộng dồn
        tradeQuantity:
          type: integer
          format: int32
          example: 3400
          description: Khối lượng được giao dịch
        closedQuantity:
          type: integer
          format: int32
          example: 0
          description: Khối lượng đã đóng
        openQuantity:
          type: integer
          format: int32
          example: 3400
          description: Khối lượng mở
        costPrice:
          type: integer
          format: int32
          example: 28000
          description: Giá vốn trung bình của khối lượng mở
        averageCostPrice:
          type: integer
          format: int32
          example: 28000
          description: Giá vốn trung bình
        averageClosePrice:
          type: integer
          format: int32
          example: 0
          description: Giá đóng trung bình
        marketPrice:
          type: integer
          format: int32
          example: 25200
          description: Giá thị trường
        breakEvenPrice:
          type: number
          format: double
          example: 28043.4752
          description: Giá hòa vốn
        createdDate:
          type: string
          format: date-time
          example: '2026-07-20T04:22:38.904283Z'
          description: Thời điểm mở
        modifiedDate:
          type: string
          format: date-time
          example: '2026-07-30T11:20:44.65933Z'
          description: Thời điểm cập nhật
    PositionDetail:
      type: object
      properties:
        id:
          type: integer
          format: int64
          example: 177410795472387
          description: ID vị thế
        symbol:
          type: string
          example: 41I1G4000
          description: Mã chứng khoán
        marketType:
          allOf:
            - $ref: '#/components/schemas/MarketType'
          example: DERIVATIVE
          description: |-
            Loại thị trường
            - STOCK: Vị thế cơ sở
            - DERIVATIVE: Vị thế phái sinh
        accountNo:
          type: string
          example: '0001179019'
          description: Số tiểu khoản
        status:
          allOf:
            - $ref: '#/components/schemas/PositionStatus'
          example: OPEN
          description: |-
            Trạng thái của vị thế
            - OPEN: Đang mở
            - PENDING_CLOSE: Chờ đóng
            - CLOSED: Đã đóng
            - ODD_LOT: Lô lẻ (cơ sở)
        loanPackageId:
          type: integer
          format: int32
          example: 2278
          description: Gói vay cơ sở hoặc phái sinh
        side:
          allOf:
            - $ref: '#/components/schemas/OrderSide'
          example: NB
          description: |-
            Loại vị thế
            - NB: Mua
            - NS: Bán
        accumulateQuantity:
          type: integer
          format: int32
          example: 6
          description: Khối lượng cộng dồn
        tradeQuantity:
          type: integer
          format: int32
          example: 1
          description: Khối lượng được giao dịch
        closedQuantity:
          type: integer
          format: int32
          example: 5
          description: Khối lượng đã đóng
        openQuantity:
          type: integer
          format: int32
          example: 1
          description: Khối lượng mở
        overNightQuantity:
          type: integer
          nullable: true
          format: int32
          example: 0
          description: Khối lượng mở qua đêm (dành cho phái sinh)
        costPrice:
          type: number
          format: float
          example: 1834.5
          description: Giá vốn trung bình của khối lượng mở
        averageCostPrice:
          type: number
          format: float
          example: 1834.5
          description: Giá vốn trung bình
        averageClosePrice:
          type: number
          format: double
          example: 1750.96
          description: Giá đóng trung bình
        marketPrice:
          type: number
          format: double
          example: 1706.1
          description: Giá thị trường
        breakEvenPrice:
          type: number
          format: double
          example: 1834.95691
          description: Giá hòa vốn
        createdDate:
          type: string
          format: date-time
          example: '2026-03-23T03:08:32.773651Z'
          description: Thời điểm mở
        modifiedDate:
          type: string
          format: date-time
          example: '2026-03-23T04:07:45.692156Z'
          description: Thời điểm cập nhật
      example:
        id: 177410795472387
        symbol: 41I1G4000
        marketType: DERIVATIVE
        accountNo: '0001179019'
        status: OPEN
        loanPackageId: 2278
        side: NB
        accumulateQuantity: 6
        tradeQuantity: 1
        closedQuantity: 5
        openQuantity: 1
        overNightQuantity: 0
        costPrice: 1834.5
        averageCostPrice: 1834.5
        averageClosePrice: 1750.96
        marketPrice: 1706.1
        breakEvenPrice: 1834.95691
        createdDate: '2026-03-23T03:08:32.773651Z'
        modifiedDate: '2026-03-23T04:07:45.692156Z'
      description: ''
    PositionStatus:
      type: string
      description: |-
        Trạng thái vị thế.

        - `OPEN`: Đang mở
        - `PENDING_CLOSE`: Chờ đóng
        - `CLOSED`: Đã đóng
        - `ODD_LOT`: Lô lẻ (cơ sở)
      enum:
        - OPEN
        - PENDING_CLOSE
        - CLOSED
        - ODD_LOT
      x-enum-descriptions:
        - Đang mở
        - Chờ đóng
        - Đã đóng
        - Lô lẻ (cơ sở)
      x-enum-varnames:
        - OPEN
        - PENDING_CLOSE
        - CLOSED
        - ODD_LOT
      example: OPEN
    OrderSide:
      type: string
      description: |-
        Chiều đặt lệnh hoặc vị thế.

        - `NB`: Mua
        - `NS`: Bán
      enum:
        - NB
        - NS
      x-enum-descriptions:
        - Mua
        - Bán
      x-enum-varnames:
        - BUY
        - SELL
      example: NB
    ErrorBody:
      type: object
      required:
        - status
        - code
        - message
      properties:
        status:
          type: integer
          format: int32
          description: Mã HTTP.
          example: 400
        code:
          type: string
          description: Mã lỗi DNSE.
          example: OA-003
        message:
          type: string
          description: Thông điệp lỗi.
          example: Thông tin nhập không hợp lệ
  headers:
    ContentLength:
      description: Response body size in bytes.
      schema:
        type: integer
      example: 430
    Date:
      description: Response date from the DNSE gateway.
      schema:
        type: string
      example: Wed, 18 Mar 2026 16:17:35 GMT
    Vary:
      description: >-
        Response header indicating the request headers used for content
        negotiation.
      schema:
        type: string
      example: Origin
    XRateLimitLimit:
      description: Maximum number of requests allowed in the current rate-limit window.
      schema:
        type: integer
      example: 300
    XRateLimitRemaining:
      description: Number of requests remaining in the current rate-limit window.
      schema:
        type: integer
      example: 299
    XRateLimitReset:
      description: Unix timestamp at which the current rate-limit window resets.
      schema:
        type: integer
      example: 1773850655
    XRequestId:
      description: Unique identifier assigned to the request by the DNSE gateway.
      schema:
        type: string
      example: unknown
  responses:
    BadRequest:
      description: Yêu cầu không hợp lệ.
      headers:
        Content-Length:
          $ref: '#/components/headers/ContentLength'
        Date:
          $ref: '#/components/headers/Date'
        Vary:
          $ref: '#/components/headers/Vary'
        X-Ratelimit-Limit:
          $ref: '#/components/headers/XRateLimitLimit'
        X-Ratelimit-Remaining:
          $ref: '#/components/headers/XRateLimitRemaining'
        X-Ratelimit-Reset:
          $ref: '#/components/headers/XRateLimitReset'
        X-Request-Id:
          $ref: '#/components/headers/XRequestId'
        X-Tyk-Api-Expires:
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          example:
            status: 400
            code: OA-003
            message: Thông tin nhập không hợp lệ
    InternalError:
      description: Lỗi hệ thống.
      headers:
        Content-Length:
          $ref: '#/components/headers/ContentLength'
        Date:
          $ref: '#/components/headers/Date'
        Vary:
          $ref: '#/components/headers/Vary'
        X-Ratelimit-Limit:
          $ref: '#/components/headers/XRateLimitLimit'
        X-Ratelimit-Remaining:
          $ref: '#/components/headers/XRateLimitRemaining'
        X-Ratelimit-Reset:
          $ref: '#/components/headers/XRateLimitReset'
        X-Request-Id:
          $ref: '#/components/headers/XRequestId'
        X-Tyk-Api-Expires:
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          example:
            status: 500
            code: OA-009
            message: Lỗi hệ thống

````

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