> For the complete documentation index, see [llms.txt](https://docs.fiinquant.vn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fiinquant.vn/ham-va-cong-thuc/7.-ham-dat-lenh/7.9.-lay-vi-the.md).

# 7.9. Lấy vị thế

* Cơ sở

```python
username_dnse = 'REPLACE_WITH_YOUR_DNSE_USERNAME'
password_dnse = 'REPLACE_WITH_YOUR_DNSE_PASSWORD'

client_order = client.FiinQuantConnector(
    broker='DNSE',
    username=username_dnse,
    password=password_dnse,
    smart_otp=True
).login()

orderbook = client_order.get_orderbook(
    account_id='0001009212',
    loan_id='13720'
)

positions = orderbook.get_positions()
for i in positions:
    print(i.summary())
```

**Tham số:**

| Tên tham số | Kiểu dữ liệu     | Bắt buộc | Mô tả                                                                                                                         |
| ----------- | ---------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| ticker      | string hoặc None | Không    | Mã chứng khoán cần lọc (ví dụ "HPG", "SSI"). Nếu không truyền, trả về tất cả mã.                                              |
| status      | string hoặc None | Không    | Trạng thái vị thế cần lọc. Có thể là "OPEN" (vị thế đang mở) hoặc "CLOSED" (vị thế đã đóng). Nếu không truyền, trả về tất cả. |
| side        | string hoặc None | Không    | Chiều giao dịch của vị thế. Có thể là "buy" hoặc "sell". Nếu không truyền, trả về cả hai chiều.                               |

Dữ liệu có các thuộc tính:

```json
{
    'id': 6858, 
    'ticker': 'STB', 
    'account_no': '0001009212', 
    'side': 'Buy', 
    'status': 'OPEN', 
    'quantity': 2700, 
    'cost_price': 28783.3333, 
    'market_price': 55600.0, 
    'accumulate_quantity': 2700, 
    'break_even_price': 28868.4237, 
    'realized_profit': 0.0, 
    'unrealized_profit': 72405000.09, 
    'created_date': '26/07/2024 14:23:04', 
    'error': None, 
    'status_code': 200
}
```

* Phái sinh

```python
username_dnse = 'REPLACE_WITH_YOUR_DNSE_USERNAME'
password_dnse = 'REPLACE_WITH_YOUR_DNSE_PASSWORD'

client_order = client.FiinQuantConnector(
    broker='DNSE',
    username=username_dnse,
    password=password_dnse,
    smart_otp=True
).login()

orderbook_der = client_order.get_derivative_orderbook(
    account_id='0001009212',
    loan_id='2278'
)

derivative_positions = orderbook_der.get_positions()
for i in derivative_positions:
    print(i.summary())
```

**Tham số:**

| Tên tham số | Kiểu dữ liệu     | Bắt buộc | Mô tả                                                                                                                         |
| ----------- | ---------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| ticker      | string hoặc None | Không    | Mã chứng khoán cần lọc (ví dụ "HPG", "SSI"). Nếu không truyền, trả về tất cả mã.                                              |
| status      | string hoặc None | Không    | Trạng thái vị thế cần lọc. Có thể là "OPEN" (vị thế đang mở) hoặc "CLOSED" (vị thế đã đóng). Nếu không truyền, trả về tất cả. |
| side        | string hoặc None | Không    | Chiều giao dịch của vị thế. Có thể là "buy" hoặc "sell". Nếu không truyền, trả về cả hai chiều.                               |

Dữ liệu có các thuộc tính:

```json
{
    'id': 10660, 
    'ticker': '41I1FB000', 
    'account_no': '0001009212',
    'side': 'Sell', 
    'status': 'OPEN', 
    'quantity': 2, 
    'cost_price': 2006.675, 
    'market_price': 1940.9, 
    'accumulate_quantity': 6, 
    'break_even_price': 2006.2189,
    'realized_profit': -39795000.0,
    'unrealized_profit': 13155000.0,
    'created_date': '27/10/2025 13:16:41',
    'error': None,
    'status_code': 200
}
```
