# 8.6. Risk Indicators (Chỉ báo rủi ro)

### 8.6.1. Ulcer Index

**Ulcer Index (UI)**, hay **Chỉ số Loét**, là một chỉ báo quản lý rủi ro được phát triển bởi Peter Martin vào năm 1987. Mục đích của nó là đo lường **mức độ và thời gian kéo dài của sự sụt giảm giá (drawdown)** từ mức đỉnh cao nhất trước đó, nhằm định lượng "nỗi đau tâm lý" mà nhà đầu tư phải chịu đựng khi giá giảm.

Không giống như độ lệch chuẩn (Standard Deviation) - vốn coi tất cả các biến động giá (cả tăng và giảm) là rủi ro như nhau, Ulcer Index **chỉ tập trung vào rủi ro giảm giá (downside risk)**.

```python
def ulcer_index(close: pandas.Series, window: int = 14, smoothing_length: int = 14, signal_length: int = 52)
```

**Tham số**

| Tên tham số       | Mô tả                                           | Kiểu dữ liệu  | Giá trị mặc định |
| ----------------- | ----------------------------------------------- | ------------- | ---------------- |
| close             | Cột chứa giá đóng cửa.                          | pandas.Series |                  |
| window            | Số phiên tính trung bình động cho drawdown (%). | int           | 14               |
| smoothing\_length | Số phiên làm mượt Ulcer Index (SMA).            | int           | 14               |
| signal\_length    | Số phiên tính đường tín hiệu (SMA của UI mượt). | int           | 52               |

Ví dụ:

```python
fi = client.FiinIndicator()
df_ui = fi.ulcer_index(df["close"], window=14, smoothing_length=14, signal_length=52)
print(df_ui)
```


---

# 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/8.-danh-sach-chi-so-ta/8.6.-risk-indicators-chi-bao-rui-ro.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.
