> 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.10.-dong-deal-doi-voi-phai-sinh.md).

# 7.10. Đóng deal (đối với 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'
)

close_deal = orderbook_der.close_deal(deal_id="10680")
print(close_deal.summary())
```

* Lưu ý: **deal\_id** lấy ở các hàm vị thế phái sinh.

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

```json
{
    'id': 266, 
    'ticker': '41I1FB000', 
    'side': 'Sell', 
    'price': 1805.1, 
    'quantity': 1, 
    'fill_quantity': 0, 
    'average_price': 0.0, 
    'loan_package_id': 2278, 
    'initial_rate': 0.0, 
    'created_date': '29/10/2025 14:43:55', 
    'error': None, 
    'status_code': 200
}
```
