> For the complete documentation index, see [llms.txt](https://hdsd2.entrade.com.vn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hdsd2.entrade.com.vn/entrade-api/8.-lay-so-lenh.md).

# 8. Lấy sổ lệnh

* **URL:**
  * PROD: <https://services.entrade.com.vn/entrade-api/derivative/orders>
* **Method:** `GET`
* **Description:** Lấy sổ lệnh
* **Parameters: None**
* **Query parameters:**
  * `investorAccountId`: tiểu khoản
  * `_start`: index lấy lệnh đầu tiên
  * `_end`: index lấy lệnh cuối cùng
  * `_sort`: field dùng để sort
  * `_order`: thứ tự
* **Response:**

```
{
    "data": [
        {
            "id": 1110909,
            "side": "NB",
            "investorId": 1000000036,
            "investorAccountId": 1000000036,
            "bankId": 10000,
            "bankAccountId": 1000040,
            "symbol": "VN30F2512",
            "price": 1920.9,
            "quantity": 1,
            "orderType": "LO",
            "orderStatus": "PendingNew",
            "fillQuantity": 0,
            "lastQuantity": 0,
            "lastPrice": 0.0,
            "averagePrice": 0.0,
            "createdDate": "2025-11-27T07:48:27.349Z",
            "modifiedDate": "2025-11-27T07:48:32.495Z",
            "bankMarginPortfolioId": 34,
            "dealId": 0,
            "tradingFee": 0.0,
            "tradingTax": 0.0,
            "orderSecure": 9604500.0,
            "priceSecure": 1920.9,
            "marginRate": 0.05,
            "quantitySecure": 1,
            "leavesQuantity": 0,
            "externalId": "117_1110909_1",
            "error": "CAN_NOT_CANCEL_PENDINGNEW_ORDER_IN_OPEN_SESSION-Cannot cancel Pending New order in Open session",
            "maker": "0013000000",
            "version": 2,
            "type": "DERIVATIVE",
            "fillValue": 0.0
        }
    ],
    "total": 1,
    "start": 0,
    "end": 1
}
```

* **Mô tả các field quan trọng:**
  * `id`: id của lệnh đặt
  * `side`
    * `NB`: Long
    * `NS`: Short
  * `orderStatus`: trạng thái lệnh đặt
    * `PendingNew`: chờ gửi
    * `New`: chờ khớp
    * `PartiallyFilled`: khớp 1 phần
    * `Filled`: khớp
    * `Rejected`: tư chối
    * `Canceled`: huỷ
  * `quantity`: KL lệnh
  * `fillQuantity`: KL khớp
  * `lastQuantity`: KL khớp cuối cùng
  * `averagePrice`: giá trung bình khớp của lệnh
  * `bankMarginPortfolioId`: gói vay của lệnh
  * `price`: giá đặt lệnh
  * `lastPrice`: giá khớp cuối cùng
