# 1.5. Lấy dữ liệu room NĐTNN

Mô tả cách sử dụng thư viện sau khi người dùng đã đăng nhập. Các ví dụ chi tiết được nêu ra ở cuối chương này.

```
data = client.PriceStatistics().get_foreign(
    tickers=tickers,
    time_filter=time_filter,
    from_date=from_date,
    to_date=to_date
).get_data()
```

**Tham số:**

| Tên tham số  | Mô tả                                                                                                                                                        | Kiểu dữ liệu  | Mặc định       | Bắt buộc |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------- | -------------- | -------- |
| tickers      | Danh sách mã được viết in hoa.                                                                                                                               | str hoặc list |                | Có       |
| time\_filter | Tần suất lấy dữ liệu, có thể lấy dữ liệu theo Ngày, Tuần, Tháng, Quý, Năm. Truyền vào 1 trong 5 giá trị "Daily", "Weekly", "Monthly", "Quarterly", "Yearly". | str           |                | Có       |
| from\_date   | Mốc thời gian lấy dữ liệu xa nhất.                                                                                                                           | str           |                | Có       |
| to\_date     | Mốc thời gian lấy dữ liệu gần nhất.                                                                                                                          | str           | datetime.now() | Không    |

Class nhận dữ liệu là PriceStatistics và có phương thức nhận dữ liệu là get\_foreign()

```python
data = client.PriceStatistics().get_foreign(
    tickers=tickers,
    time_filter="Daily",
    from_date="2025-08-20",
    to_date="2025-08-27"
)
print(data)
```

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

* time\_filter="Daily"

| Tên thuộc tính           | Mô tả                           | Kiểu dữ liệu |
| ------------------------ | ------------------------------- | ------------ |
| ticker                   | Tên mã.                         | str          |
| timestamp                | Thời gian giao dịch             | str          |
| foreignBuyVolumeTotal    | Khối lượng NĐTNN mua vào        | float        |
| foreignSellVolumeTotal   | Khối lượng NĐTNN bán ra         | float        |
| foreignBuyValueTotal     | Giá trị NĐTNN mua vào           | int          |
| foreignSellValueTotal    | Giá trị NĐTNN bán ra            | int          |
| foreignNetVolumeTotal    | Khối lượng NĐTNN mua/bán ròng   | float        |
| foreignNetValueTotal     | Giá trị NĐTNN mua/bán ròng      | int          |
| foreignBuyVolumeMatched  | Khối lượng NĐTNN mua khớp lệnh  | float        |
| foreignSellVolumeMatched | Khối lượng NĐTNN bán khớp lệnh  | float        |
| foreignBuyValueMatched   | Giá trị NĐTNN mua khớp lệnh     | int          |
| foreignSellValueMatched  | Giá trị NĐTNN bán khớp lệnh     | int          |
| foreignBuyVolumeDeal     | Khối lượng NĐTNN mua thỏa thuận | float        |
| foreignSellVolumeDeal    | Khối lượng NĐTNN bán thỏa thuận | float        |
| foreignBuyValueDeal      | Giá trị NĐTNN mua thỏa thuận    | int          |
| foreignSellValueDeal     | Giá trị NĐTNN bán thỏa thuận    | int          |
| foreignCurrentRoom       | Giá trị room hiện hại của NĐTNN | int          |
| foreignTotalRoom         | Giá trị room tối đa của NĐTNN   | int          |
| percentForeignTotalRoom  | % room hiện tại của NĐTNN       | float        |
| foreignOwned             | Giá trị sở hữu của NĐTNN        | int          |
| percentForeignOwned      | % sở hữu của NĐTNN              | float        |

* time\_filter="Weekly"

| Tên thuộc tính           | Mô tả                           | Kiểu dữ liệu |
| ------------------------ | ------------------------------- | ------------ |
| ticker                   | Tên mã.                         | str          |
| week                     | Tuần trong năm                  | int          |
| year                     | Năm                             | int          |
| foreignBuyVolumeTotal    | Khối lượng NĐTNN mua vào        | float        |
| foreignSellVolumeTotal   | Khối lượng NĐTNN bán ra         | float        |
| foreignBuyValueTotal     | Giá trị NĐTNN mua vào           | int          |
| foreignSellValueTotal    | Giá trị NĐTNN bán ra            | int          |
| foreignNetVolumeTotal    | Khối lượng NĐTNN mua/bán ròng   | float        |
| foreignNetValueTotal     | Giá trị NĐTNN mua/bán ròng      | int          |
| foreignBuyVolumeMatched  | Khối lượng NĐTNN mua khớp lệnh  | float        |
| foreignSellVolumeMatched | Khối lượng NĐTNN bán khớp lệnh  | float        |
| foreignBuyValueMatched   | Giá trị NĐTNN mua khớp lệnh     | int          |
| foreignSellValueMatched  | Giá trị NĐTNN bán khớp lệnh     | int          |
| foreignBuyVolumeDeal     | Khối lượng NĐTNN mua thỏa thuận | float        |
| foreignSellVolumeDeal    | Khối lượng NĐTNN bán thỏa thuận | float        |
| foreignBuyValueDeal      | Giá trị NĐTNN mua thỏa thuận    | int          |
| foreignSellValueDeal     | Giá trị NĐTNN bán thỏa thuận    | int          |
| foreignCurrentRoom       | Giá trị room hiện hại của NĐTNN | int          |
| foreignTotalRoom         | Giá trị room tối đa của NĐTNN   | int          |
| percentForeignTotalRoom  | % room hiện tại của NĐTNN       | float        |
| foreignOwned             | Giá trị sở hữu của NĐTNN        | int          |
| percentForeignOwned      | % sở hữu của NĐTNN              | float        |

* time\_filter="Monthly"

| Tên thuộc tính           | Mô tả                           | Kiểu dữ liệu |
| ------------------------ | ------------------------------- | ------------ |
| ticker                   | Tên mã.                         | str          |
| month                    | Tháng trong năm                 | int          |
| year                     | Năm                             | int          |
| foreignBuyVolumeTotal    | Khối lượng NĐTNN mua vào        | float        |
| foreignSellVolumeTotal   | Khối lượng NĐTNN bán ra         | float        |
| foreignBuyValueTotal     | Giá trị NĐTNN mua vào           | int          |
| foreignSellValueTotal    | Giá trị NĐTNN bán ra            | int          |
| foreignNetVolumeTotal    | Khối lượng NĐTNN mua/bán ròng   | float        |
| foreignNetValueTotal     | Giá trị NĐTNN mua/bán ròng      | int          |
| foreignBuyVolumeMatched  | Khối lượng NĐTNN mua khớp lệnh  | float        |
| foreignSellVolumeMatched | Khối lượng NĐTNN bán khớp lệnh  | float        |
| foreignBuyValueMatched   | Giá trị NĐTNN mua khớp lệnh     | int          |
| foreignSellValueMatched  | Giá trị NĐTNN bán khớp lệnh     | int          |
| foreignBuyVolumeDeal     | Khối lượng NĐTNN mua thỏa thuận | float        |
| foreignSellVolumeDeal    | Khối lượng NĐTNN bán thỏa thuận | float        |
| foreignBuyValueDeal      | Giá trị NĐTNN mua thỏa thuận    | int          |
| foreignSellValueDeal     | Giá trị NĐTNN bán thỏa thuận    | int          |
| foreignCurrentRoom       | Giá trị room hiện hại của NĐTNN | int          |
| foreignTotalRoom         | Giá trị room tối đa của NĐTNN   | int          |
| percentForeignTotalRoom  | % room hiện tại của NĐTNN       | float        |
| foreignOwned             | Giá trị sở hữu của NĐTNN        | int          |
| percentForeignOwned      | % sở hữu của NĐTNN              | float        |

* time\_filter="Quarterly"

| Tên thuộc tính           | Mô tả                           | Kiểu dữ liệu |
| ------------------------ | ------------------------------- | ------------ |
| ticker                   | Tên mã.                         | str          |
| quarter                  | Quý trong năm                   | int          |
| year                     | Năm                             | int          |
| foreignBuyVolumeTotal    | Khối lượng NĐTNN mua vào        | float        |
| foreignSellVolumeTotal   | Khối lượng NĐTNN bán ra         | float        |
| foreignBuyValueTotal     | Giá trị NĐTNN mua vào           | int          |
| foreignSellValueTotal    | Giá trị NĐTNN bán ra            | int          |
| foreignNetVolumeTotal    | Khối lượng NĐTNN mua/bán ròng   | float        |
| foreignNetValueTotal     | Giá trị NĐTNN mua/bán ròng      | int          |
| foreignBuyVolumeMatched  | Khối lượng NĐTNN mua khớp lệnh  | float        |
| foreignSellVolumeMatched | Khối lượng NĐTNN bán khớp lệnh  | float        |
| foreignBuyValueMatched   | Giá trị NĐTNN mua khớp lệnh     | int          |
| foreignSellValueMatched  | Giá trị NĐTNN bán khớp lệnh     | int          |
| foreignBuyVolumeDeal     | Khối lượng NĐTNN mua thỏa thuận | float        |
| foreignSellVolumeDeal    | Khối lượng NĐTNN bán thỏa thuận | float        |
| foreignBuyValueDeal      | Giá trị NĐTNN mua thỏa thuận    | int          |
| foreignSellValueDeal     | Giá trị NĐTNN bán thỏa thuận    | int          |
| foreignCurrentRoom       | Giá trị room hiện hại của NĐTNN | int          |
| foreignTotalRoom         | Giá trị room tối đa của NĐTNN   | int          |
| percentForeignTotalRoom  | % room hiện tại của NĐTNN       | float        |
| foreignOwned             | Giá trị sở hữu của NĐTNN        | int          |
| percentForeignOwned      | % sở hữu của NĐTNN              | float        |

* time\_filter="Yearly"

| Tên thuộc tính           | Mô tả                           | Kiểu dữ liệu |
| ------------------------ | ------------------------------- | ------------ |
| ticker                   | Tên mã.                         | str          |
| year                     | Năm                             | int          |
| foreignBuyVolumeTotal    | Khối lượng NĐTNN mua vào        | float        |
| foreignSellVolumeTotal   | Khối lượng NĐTNN bán ra         | float        |
| foreignBuyValueTotal     | Giá trị NĐTNN mua vào           | int          |
| foreignSellValueTotal    | Giá trị NĐTNN bán ra            | int          |
| foreignNetVolumeTotal    | Khối lượng NĐTNN mua/bán ròng   | float        |
| foreignNetValueTotal     | Giá trị NĐTNN mua/bán ròng      | int          |
| foreignBuyVolumeMatched  | Khối lượng NĐTNN mua khớp lệnh  | float        |
| foreignSellVolumeMatched | Khối lượng NĐTNN bán khớp lệnh  | float        |
| foreignBuyValueMatched   | Giá trị NĐTNN mua khớp lệnh     | int          |
| foreignSellValueMatched  | Giá trị NĐTNN bán khớp lệnh     | int          |
| foreignBuyVolumeDeal     | Khối lượng NĐTNN mua thỏa thuận | float        |
| foreignSellVolumeDeal    | Khối lượng NĐTNN bán thỏa thuận | float        |
| foreignBuyValueDeal      | Giá trị NĐTNN mua thỏa thuận    | int          |
| foreignSellValueDeal     | Giá trị NĐTNN bán thỏa thuận    | int          |
| foreignCurrentRoom       | Giá trị room hiện hại của NĐTNN | int          |
| foreignTotalRoom         | Giá trị room tối đa của NĐTNN   | int          |
| percentForeignTotalRoom  | % room hiện tại của NĐTNN       | float        |
| foreignOwned             | Giá trị sở hữu của NĐTNN        | int          |
| percentForeignOwned      | % sở hữu của NĐTNN              | float        |

Ví dụ:

```python
from FiinQuantX import FiinSession

username = 'REPLACE_WITH_YOUR_USER_NAME'
password = 'REPLACE_WITH_YOUR_PASS_WORD'

client = FiinSession(username=username, password=password).login()

tickers = ["HPG", "MWG"]

data = client.PriceStatistics().get_foreign(
    tickers=tickers,
    time_filter="Daily",
    from_date="2025-08-20",
    to_date="2025-08-27"
)
print(data)
```


---

# 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/1.-danh-muc-and-thong-tin-co-ban/1.5.-lay-du-lieu-room-ndtnn.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.
