3.2. Hàm chỉ số báo cáo tài chính
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.
fi_dict = client.FundamentalAnalysis().get_ratios(
tickers=tickers,
years=years,
quarters=quarters,
type=type,
fields=fields
)
Tham số:
tickers
Danh sách mã được viết in hoa.
str hoặc list
Có
years
Năm của kỳ báo cáo, có thể chọn nhiều năm bằng cách liệt kê list các năm ra
list[int]
Có
quarters
Quý của kỳ báo cáo, nếu không truyền mặc định lấy báo cáo tài chính của năm dựa trên tham số year, có thể chọn nhiều quý bằng cách liệt kê list các quý ra
list[int]
None
Không
type
1 trong 2 giá trị (‘consolidated’ hoặc ‘separate’). 'consolidated' là báo cáo tài chính hợp nhất, 'separate' là báo cáo tài chính công ty mẹ
str
Có
fields
Trường dữ liệu cần lấy (không truyền sẽ lấy hết). Biến fields có thể truyền theo dạng đường dẫn phân cấp cách nhau bằng dấu chấm (ProfitabilityRatio'.'ROA' – Lấy chỉ số ROA) hoặc truyền thẳng sections là node cần lấy ('ROA').
str
None
Không
Class nhận dữ liệu là FundamentalAnalysis và có phương thức nhận dữ liệu là get_ratios()
### pseudocode
import json
fi_dict = client.FundamentalAnalysis().get_ratios(
tickers=tickers,
years=[2024],
quarters=[4],
type="consolidated"
)
print(json.dumps(fi_dict, indent=4))
Ví dụ lấy dữ liệu full chỉ số báo cáo tài chính hợp nhất của 4 quý trong năm 2024 của mã HPG
import json
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']
fi_dict = client.FundamentalAnalysis().get_ratios(
tickers=tickers,
years=[2024],
quarters=[1,2,3,4],
type="consolidated"
)
print(json.dumps(fi_dict, indent=4))
Ví dụ lấy dữ liệu nhóm chỉ số báo cáo tài chính KHẢ NĂNG SINH LỢI dựa trên báo cáo tài chính hợp nhất của 4 quý năm 2024 của mã HPG
import json
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']
fi_dict = client.FundamentalAnalysis().get_ratios(
tickers=tickers,
years=[2024],
quarters=[1,2,3,4],
type="consolidated",
fields=["ProfitabilityRatio"]
)
print(json.dumps(fi_dict, indent=4))
Ví dụ lấy dữ liệu chỉ số ROA thuộc nhóm chỉ số báo cáo tài chính KHẢ NĂNG SINH LỢI dựa trên báo cáo tài chính hợp của 4 quý năm 2024 của mã HPG
import json
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']
fi_dict = client.FundamentalAnalysis().get_ratios(
tickers=tickers,
years=[2024],
quarters=[1,2,3,4],
type="consolidated",
fields=["ProfitabilityRatio.ROA"]
)
print(json.dumps(fi_dict, indent=4))
Last updated