# 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
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fiinquant.vn/ham-va-cong-thuc/7.-ham-dat-lenh/7.9.-lay-vi-the.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
