Dữ liệu và Panel
- 🇻🇳 Tiếng Việt
- 🇬🇧 English
- 🇰🇷 한국어
- 🇨🇳 中文
Hàm của chiến lược (signals, rank, weights, filter) và của bộ lọc (columns, filter) nhận dữ liệu d; phân tích lấy d từ await data.bars(…). Trang này liệt kê mọi trường của d — tên chính xác, ý nghĩa, đơn vị — cùng cách tính trên Panel. Dữ liệu có từ khi nào, cập nhật lúc nào, dùng theo ngày công bố ra sao: xem Dữ liệu và mô phỏng khớp lệnh.
Panel: bảng mã × phiên
Mỗi trường của d là một Panel — bảng số mỗi hàng là một mã, mỗi cột là một phiên giao dịch (theo lịch phiên của VNINDEX):
d.close 04/01/2016 05/01/2016 … 14/10/2026
FPT 7.77 7.77 … 57.10
HPG 2.56 2.54 … 20.80
VNM 45.04 44.69 … 57.90
Giá là giá điều chỉnh: FPT năm 2016 hiện 7,77 vì đã trừ các đợt chia cổ tức, cổ phiếu thưởng sau đó; phiên gần nhất giá điều chỉnh bằng giá khớp thật.
- Thiếu dữ liệu là
NaN(trước khi niêm yết, sau khi ngừng giao dịch, kỳ chưa có số). Phiên tạm ngừng giao dịch giữ giá đóng cửa trước, KL 0. - Điều kiện là Panel 1 / 0 /
NaN(đúng / sai / chưa biết):d.close.gt(ta.sma(d.close, 200))cho 1 khi giá trên MA200. Logicand,or,nottheo ba trạng thái:0 and NaN = 0,1 or NaN = 1, còn lại cóNaNthì raNaN. Khi mô phỏng,NaNđược coi như sai. - Phép tính trên cả bảng cùng lúc, kết quả là Panel mới cùng hình:
d.close.div(d.high.highest(250)).sub(1)là khoảng cách tới đỉnh 52 tuần của mọi mã, mọi phiên. - Panel một hàng (VNINDEX trong
d.bench, chuỗi vĩ môd.macro(…), kết quảsumAcross()) tự mở rộng khi tính với Panel nhiều mã:d.close.gt(0).and(d.bench.close.gt(ta.sma(d.bench.close, 200)))là Panel nhiều mã. Thứ Studio nhận lại (exit,score, cột và điều kiện của bộ lọc) phải là Panel nhiều mã — trả thẳng Panel một hàng thì chỉ mã đầu tiên của rổ nhận đúng giá trị, kết quả sai. - Số lưu dạng số thực 32 bit (khoảng 7 chữ số có nghĩa, sai số tương đối cỡ 10⁻⁷) — đủ cho giá, tỷ lệ, giá trị tiền.
Giá và khối lượng
| Trường | Ý nghĩa | Đơn vị |
|---|---|---|
d.open, d.high, d.low, d.close | Giá mở cửa, cao nhất, thấp nhất, đóng cửa đã điều chỉnh theo cổ tức, chia tách | nghìn đồng (chỉ số: điểm) |
d.volume | KL khớp lệnh, số gốc (chưa điều chỉnh theo chia tách) | cổ phiếu |
d.volumeAdj | KL khớp đã điều chỉnh theo chia tách = volume × adjRatio — so sánh được qua các đợt chia tách | cổ phiếu |
d.tradable | 1 nếu phiên có khớp lệnh, 0 nếu tạm ngừng / không khớp | — |
d.value | GT khớp ước tính = close × volume × 1000 | đồng |
d.ret | Lợi nhuận phiên = close ÷ close phiên trước − 1 | tỷ lệ |
d.value dùng giá điều chỉnh nên ở kỳ xa thấp hơn GT đã giao dịch thật của mã có chia cổ tức cổ phiếu sau đó; cần GT thật dùng d.valueExact (dưới đây).
Giá gốc và giao dịch chi tiết
| Trường | Ý nghĩa | Đơn vị |
|---|---|---|
d.closeRaw | Giá đóng cửa gốc, chưa điều chỉnh (nến tạm: giá đang khớp) | nghìn đồng |
d.basic | Giá tham chiếu gốc | nghìn đồng |
d.avgPrice | Giá bình quân phiên, gốc | nghìn đồng |
d.valueExact | Tổng GT giao dịch gồm thỏa thuận | đồng |
d.dealVolume | KL khớp lệnh, gốc | cổ phiếu |
d.putthroughVolume, d.putthroughValue | KL / GT giao dịch thỏa thuận | cổ phiếu / đồng |
d.adjRatio | Hệ số điều chỉnh lũy kế: giá điều chỉnh = giá gốc ÷ adjRatio | — |
Các trường chi tiết, khối ngoại, số lệnh: phiên có giao dịch mà nguồn không có số thì ghi 0 (riêng propNet để NaN).
Khối ngoại, tự doanh, số lệnh
| Trường | Ý nghĩa | Đơn vị |
|---|---|---|
d.foreignBuyVolume, d.foreignSellVolume | KL nhà đầu tư nước ngoài mua / bán | cổ phiếu |
d.foreignBuyValue, d.foreignSellValue | GT nhà đầu tư nước ngoài mua / bán | đồng |
d.foreignNet | GT khối ngoại mua ròng = mua − bán | đồng |
d.foreignNetVolume | KL khối ngoại mua ròng | cổ phiếu |
d.foreignRoom | Room khối ngoại còn lại | cổ phiếu |
d.propNet | GT tự doanh công ty chứng khoán mua ròng (từ 12/2019) | đồng |
d.buyCount, d.sellCount | Số lệnh đặt mua / đặt bán | lệnh |
d.buyVolume, d.sellVolume | KL đặt mua / đặt bán | cổ phiếu |
Số liệu của phiên hôm nay có sau 19:00; trước đó các ô của phiên chưa chốt là NaN. Bộ lọc dùng khối ngoại, tự doanh nên đặt includeToday: false và fillna(0) trước khi cộng dồn:
// Khối ngoại mua ròng 20 phiên so với GT giao dịch của chính mã
const flow = d.foreignNet.fillna(0).rolling(20).sum().div(d.value.rolling(20).sum());
BCTC theo ngày công bố
Giá trị của BCTC mới nhất đã dùng được trư ớc phiên đó (quý hoặc năm, xem quy tắc ngày dùng được), giữ nguyên tới báo cáo kế tiếp.
| Trường | Ý nghĩa | Đơn vị |
|---|---|---|
d.eps | EPS cơ bản 4 quý gần nhất | đồng / cổ phiếu |
d.bvps | Giá trị sổ sách mỗi cổ phiếu | đồng |
d.roe, d.roa | ROE, ROA 4 quý gần nhất | tỷ lệ (0,15 = 15%) |
d.grossMargin | Biên lợi nhuận gộp 4 quý | tỷ lệ |
d.revenueGrowth | Doanh thu thuần của quý so cùng kỳ | tỷ lệ |
d.profitGrowth | LNST cổ đông mẹ của quý so cùng kỳ | tỷ lệ |
d.debtToEquity | Nợ phải trả (tổng nợ, gồm nợ không chịu lãi) / vốn chủ sở hữu | lần |
d.fScore | Piotroski F-Score 0–9, chỉ từ BCTC năm | điểm |
d.reportNew | 1 ở phiên đầu tiên một BCTC mới (quý, năm) được dùng, 0 ở phiên khác | — |
d.pe | P/E = giá gốc × 1.000 ÷ EPS 4 quý; NaN khi EPS ≤ 0 | lần |
d.pb | P/B = giá gốc × 1.000 ÷ giá trị sổ sách; NaN khi ≤ 0 | lần |
d.earningsYield | Lợi suất lợi nhuận = EPS ÷ (giá gốc × 1.000) — nghịch đảo P/E, dùng được cả khi lỗ | tỷ lệ |
P/E, P/B tính theo giá từng phiên (trong phiên: giá đang khớp) và EPS, giá trị sổ sách đã công bố — khác d.fin("PE") là P/E tại ngày kết thúc kỳ báo cáo. Ngân hàng, công ty chứng khoán, bảo hiểm thường để trống debtToEquity, fScore, biên lợi nhuận.
d.fin: 72 chỉ tiêu BCTC
d.fin("Khóa", { ttm, period, ago }) trả Panel một chỉ tiêu theo ngày công bố (tên khoá của FireAnt, không phân biệt hoa thường). Mỗi phiên lấy kỳ mới nhất đã dùng được trước phiên của chỉ tiêu đó.
| Tuỳ chọn | Ý nghĩa |
|---|---|
period | "quarter" (mặc định): BCTC quý; "year": BCTC năm. Chỉ tiêu chỉ có ở BCTC năm (FCF, PiotroskiFScore) tự dùng "year" |
ttm: true | Cộng 4 quý liên tiếp gần nhất — chỉ với chỉ tiêu "Quý"; thiếu một quý thì NaN |
ago: n | Lùi n kỳ so với kỳ mới nhất (0–20): quý ago: 4 = cùng kỳ năm trước; năm ago: 1 = năm trước |
Cột Số cho biết số liệu ở BCTC quý là gì: Quý — phát sinh trong quý (kỳ năm là cả năm), cộng 4 quý bằng ttm; 4 quý — đã tính trên 4 quý gần nhất ngay trong báo cáo quý; Cuối kỳ — số dư, chỉ số tại ngày kết thúc kỳ; So cùng kỳ; Năm — chỉ có ở BCTC năm. Tiền tính theo đồng.
// LNST cổ đông mẹ của quý so cùng kỳ (bỏ kỳ trước ≤ 0 để tăng trưởng không đổi dấu)
const lnst = (ago) => d.fin("ParentCompanyShareholderProfitAfterTax", { ago });
const growth = lnst(0).div(lnst(4).where(lnst(4).gt(0))).sub(1);
// Dòng tiền kinh doanh 4 quý so với LNST 4 quý (chất lượng lợi nhuận)
const cashRatio = d.fin("CashflowFromOperatingActivity", { ttm: true }).div(d.fin("ProfitAfterTax", { ttm: true }));
// ROE thấp nhất của 3 BCTC năm gần nhất
const roeY = (k) => d.fin("ROE", { period: "year", ago: k });
const roeMin3 = roeY(0).min(roeY(1)).min(roeY(2));
Trong phân tích, khai báo trước các chỉ tiêu trong fields của data.bars, dạng fin:Khóa kèm hậu tố :ttm, :year, :agoN: data.bars(universe("HOSE"), { fields: ["fin:NetSale:ttm", "fin:NetSale:ttm:ago4", "fin:FCF"] }).
Kết quả kinh doanh (số của quý; kỳ năm là cả năm)
| Khóa | Ý nghĩa | Số |
|---|---|---|
NetSale | Doanh thu thuần | Quý |
TotalRevenue | Doanh thu bán hàng và dịch vụ (trước giảm trừ) | Quý |
CostOfGoodSold | Giá vốn hàng bán (số dương) | Quý |
GrossProfit | Lợi nhuận gộp | Quý |
SellingExpense | Chi phí bán hàng | Quý |
ManagingExpense | Chi phí quản lý doanh nghiệp | Quý |
FinancialExpense | Chi phí tài chính | Quý |
InterestExpense | Chi phí lãi vay | Quý |
ProfitFromFinancialActivity | Lợi nhuận hoạt động tài chính | Quý |
NetProfitFromOperatingActivity | Lợi nhuận thuần từ hoạt động kinh doanh | Quý |
EBIT | Lợi nhuận trước lãi vay và thuế | Quý |
EBITDA | EBITDA | Quý |
DepreciationAndAmortization | Khấu hao | Quý |
ProfitBeforeTax | Lợi nhuận trước thuế | Quý |
ProfitAfterTax | Lợi nhuận sau thuế | Quý |
ParentCompanyShareholderProfitAfterTax | LNST của cổ đông công ty mẹ | Quý |
Bảng cân đối (số dư cuối kỳ)
| Khóa | Ý nghĩa | Số |
|---|---|---|
TotalAsset | Tổng tài sản | Cuối kỳ |
TotalCurrentAsset | Tài sản ngắn hạn | Cuối kỳ |
Cash | Tiền (không gồm tương đương tiền) | Cuối kỳ |
CashEquivalent | Các khoản tương đương tiền | Cuối kỳ |
ShortTermFinancialInvestment | Đầu tư tài chính ngắn hạn (gồm tiền gửi có kỳ hạn) | Cuối kỳ |
TotalShortTermReceivable | Phải thu ngắn hạn | Cuối kỳ |
TotalInventory | Hàng tồn kho | Cuối kỳ |
FixedAsset | Tài sản cố định | Cuối kỳ |
TotalDebt | Nợ phải trả (tổng nợ, gồm nợ không chịu lãi) | Cuối kỳ |
TotalShortTermDebt | Nợ ngắn hạn | Cuối kỳ |
TotalLongTermDebt | Nợ dài hạn | Cuối kỳ |
ShortTermInterestBearingDebt | Vay ngắn hạn (chịu lãi) | Cuối kỳ |
LongTermInterestBearingDebt | Vay dài hạn (chịu lãi) | Cuối kỳ |
StockHolderEquity | Vốn chủ sở hữu | Cuối kỳ |
RetainedProfit | Lợi nhuận chưa phân phối | Cuối kỳ |
WorkingCapital | Vốn lưu động = tài sản ngắn hạn − nợ ngắn hạn | Cuối kỳ |
Lưu chuyển tiền
| Khóa | Ý nghĩa | Số |
|---|---|---|
CashflowFromOperatingActivity | Lưu chuyển tiền thuần từ hoạt động kinh doanh | Quý |
CashflowFromInvestingActivity | Lưu chuyển tiền thuần từ hoạt động đầu tư | Quý |
CashflowFromFinancingActivity | Lưu chuyển tiền thuần từ hoạt động tài chính | Quý |
CAPEX | Chi mua sắm tài sản cố định 4 quý (số dương) | 4 quý |
FCF | Dòng tiền tự do | Năm |
Mỗi cổ phiếu, định giá tại ngày kết thúc kỳ
| Khóa | Ý nghĩa | Số |
|---|---|---|
ShareAtPeriodEnd | Số cổ phiếu lưu hành cuối kỳ (cổ phiếu) | Cuối kỳ |
MarketCapAtPeriodEnd | Vốn hóa tại ngày kết thúc kỳ | Cuối kỳ |
BasicEPS | EPS cơ bản 4 quý (đồng / cổ phiếu) | 4 quý |
DilutedEPS | EPS pha loãng 4 quý | 4 quý |
BookValuePerShare | Giá trị sổ sách mỗi cổ phiếu | Cuối kỳ |
SalePerShare | Doanh thu 4 quý mỗi cổ phiếu | 4 quý |
CashDividend | Cổ tức tiền mỗi cổ phiếu của năm gần nhất | 4 quý |
DividendYield | Tỷ suất cổ tức tiền theo giá cuối kỳ (tỷ lệ) | 4 quý |
PayoutRatio | Tỷ lệ chi trả cổ tức (tỷ lệ) | 4 quý |
PE | P/E theo giá cuối kỳ (giá từng phiên: d.pe) | 4 quý |
PB | P/B theo giá cuối kỳ (giá từng phiên: d.pb) | Cuối kỳ |
PS | P/S theo giá cuối kỳ | 4 quý |
EVOverEBITDA | EV/EBITDA theo giá cuối kỳ | 4 quý |
Hiệu quả, biên lợi nhuận (4 quý)
| Khóa | Ý nghĩa | Số |
|---|---|---|
ROE | ROE (tỷ lệ) | 4 quý |
ROA | ROA | 4 quý |
ROIC | ROIC | 4 quý |
ROCE | ROCE | 4 quý |
GrossMargin | Biên lợi nhuận gộp | 4 quý |
EBITMargin | Biên EBIT | 4 quý |
OperatingMargin | Biên lợi nhuận hoạt động | 4 quý |
PreTaxMargin | Biên lợi nhuận trước thuế | 4 quý |
TotalAssetTurnover | Vòng quay tổng tài sản (lần) | 4 quý |
InventoryTurnover | Vòng quay hàng tồn kho | 4 quý |
ReceivableTurnover | Vòng quay khoản phải thu | 4 quý |
InterestCoverageRatio | Khả năng trả lãi = EBIT ÷ chi phí lãi vay | 4 quý |
Thanh khoản, đòn bẩy (cuối kỳ)
| Khóa | Ý nghĩa | Số |
|---|---|---|
CurrentRatio | Thanh toán hiện hành (lần) | Cuối kỳ |
QuickRatio | Thanh toán nhanh | Cuối kỳ |
TotalDebtOverEquity | Nợ phải trả ÷ vốn chủ sở hữu | Cuối kỳ |
TotalDebtOverAsset | Nợ phải trả ÷ tổng tài sản (tỷ lệ) | Cuối kỳ |
Tăng trưởng so cùng kỳ năm trước, điểm
| Khóa | Ý nghĩa | Số |
|---|---|---|
SaleGrowth | Doanh thu thuần của quý so cùng kỳ | So cùng kỳ |
ProfitGrowth | LNST cổ đông mẹ của quý so cùng kỳ | So cùng kỳ |
BasicEPSGrowth | EPS 4 quý so cùng kỳ | So cùng kỳ |
PiotroskiFScore | Piotroski F-Score 0–9 | Năm |
ManufacturingZScore | Altman Z-Score doanh nghiệp sản xuất | Cuối kỳ |
NonManufacturingZScore | Altman Z-Score doanh nghiệp phi sản xuất | Cuối kỳ |
TotalDebtlà tổng nợ phải trả, gồm cả nợ không chịu lãi; nợ vay =ShortTermInterestBearingDebt+LongTermInterestBearingDebt.Cashkhông gồmCashEquivalent.- Ngân hàng, công ty chứng khoán, bảo hiểm dùng mẫu BCTC riêng: nhiều chỉ tiêu để trống (giá vốn, tồn kho, EBIT, nợ vay…) hoặc mang nghĩa khác. Cộng các chỉ tiêu có thể trống thì
fillna(0)từng phần, và chỉ so trong cùng nhóm ngành. - Thiếu một quý trong 4 quý liên tiếp (doanh nghiệp chỉ công bố bán niên, năm) thì
ttmraNaN— dùngperiod: "year". period: "year"là số kiểm toán, dùng được từ ngày có số đó (thường cuối tháng 3, có khi tới tháng 7); trước ngày đó vẫn là năm trước.- Máy chủ chưa có một chỉ tiêu thì kết quả có ghi chú Máy chủ dữ liệu chưa có chỉ tiêu BCTC … — để trống.
Cổ tức, sự kiện quyền, trần / sàn
| Trường | Ý nghĩa | Đơn vị |
|---|---|---|
d.cashDividend | Cổ tức tiền ở phiên GDKHQ (phiên kế tiếp nếu ngày đó nghỉ); 0 ở phiên khác | đồng / cổ phiếu |
d.dividendYield | Tỷ suất cổ tức tiền 12 tháng = tổng cashDividend 250 phiên ÷ (giá gốc × 1.000); cần 250 phiên dữ liệu trước đó | tỷ lệ |
d.exRights | 1 ở phiên GDKHQ có điều chỉnh giá (cổ tức, chia tách, phát hành quyền) | — |
d.ceiling, d.floor | Giá trần, sàn của phiên (đã điều chỉnh như giá) | nghìn đồng |
d.atCeiling, d.atFloor | 1 nếu đóng cửa ở giá trần / sàn | — |
Cộng đồng và tin tức
| Trường | Ý nghĩa |
|---|---|
d.newsCount | Số tin tức gắn mã trong ngày |
d.postCount | Số bài viết cộng đồng FireAnt nhắc mã trong ngày |
d.postAuthors | Số người viết khác nhau nhắc mã trong ngày |
d.postLikes, d.postReplies | Tổng lượt thích, trả lời của các bài viết đó |
d.bullishPosts, d.bearishPosts | Số bài người đăng chọn cảm xúc tích cực / tiêu cực |
Có từ 28/01/2021; ngày không có bài là 0, trước 2021 là NaN. Số của phiên hôm nay có sau lượt cập nhật khoảng 19:10 (lịch cập nhật); trước đó ô của phiên hôm nay là NaN, nên dùng fillna(0) trước khi tính cửa sổ trượt. Mức bàn tán có ý nghĩa khi so với chính mã đó: ví dụ d.postCount.fillna(0).rolling(5).mean().div(d.postCount.fillna(0).rolling(60).mean()) là số bài 5 phiên gấp bao nhiêu lần bình thường.
Giao dịch nội bộ và cổ đông lớn
| Trường | Ý nghĩa | Đơn vị |
|---|---|---|
d.insiderBuy, d.insiderSell | KL cá nhân nội bộ, người liên quan, cổ đông lớn đã mua / bán, ghi ở phiên thứ 3 sau ngày thực hiện; 0 ở phiên khác | cổ phiếu |
d.insiderBuyPlan, d.insiderSellPlan | KL cá nhân đăng ký mua / bán, ghi ở phiên đầu được giao dịch | cổ phiếu |
d.holderBuy, d.holderSell | KL tổ chức (cổ đông lớn, công ty mẹ, quỹ) đã mua / bán, như insiderBuy | cổ phiếu |
d.insiderNet | insiderBuy − insiderSell | cổ phiếu |
d.insiderNetValue | insiderNet × giá gốc của phiên | đồng |
d.stateOwnership | Tỷ lệ sở hữu nhà nước (0–1) — ảnh chụp hiện tại | tỷ lệ |
d.foreignMajorOwnership | Tổng tỷ lệ của cổ đông lớn nước ngoài — ảnh chụp hiện tại | tỷ lệ |
d.founderOwnership | Tổng tỷ lệ của cổ đông sáng lập — ảnh chụp hiện tại | tỷ lệ |
d.majorOwnership | Tổng tỷ lệ của các cổ đông được công bố; 1 − majorOwnership ≈ tự do chuyển nhượng — ảnh chụp hiện tại | tỷ lệ |
d.majorHolders | Số cổ đông được công bố — ảnh chụp hiện tại | cổ đông |
Năm có dữ liệu giao dịch nội bộ, phiên không có giao dịch là 0. Năm trường ảnh chụp chỉ có từ ngày danh sách cổ đông được cập nhật, trước đó NaN — dùng cho bộ lọc hôm nay, không dùng cho backtest (xem Giao dịch nội bộ và cổ đông lớn).
// GT cá nhân nội bộ mua ròng 60 phiên, tỷ đồng
const insider60 = d.insiderNetValue.fillna(0).rolling(60).sum().div(1e9);
d.macro: 108 chuỗi vĩ mô
d.macro("mã") trả Panel một hàng (như d.bench, tự mở rộng khi tính với Panel nhiều mã): số đã biết ở từng phiên — kỳ mới nhất đã công bố trước phiên, số sửa dùng từ ngày có bản sửa (quy tắc).
// Chỉ nắm cổ phiếu khi lãi suất liên ngân hàng qua đêm dưới 4% và lạm phát dưới 4,5%
signals: (d) => {
const ok = d.macro("ib_on").lt(4).and(d.macro("cpi_yoy").lt(4.5));
const up = d.close.gt(ta.sma(d.close, 50));
return { entry: up.and(ok), exit: up.not().or(ok.not()) };
},
- Điều kiện vĩ mô chỉ đặt trong
entrythì chỉ chặn lúc mua; muốn bán khi vĩ mô xấu đi, đưa điều kiện ngược vàoexitnhư trên. Với chiến lược xoay vòng, đặt điều kiện vàofilter: kỳ tái cân bằng không mã nào đạt thì danh mục về tiền mặt. - Chuỗi tính bằng % là số phần trăm (
gdp_yoy7.1 nghĩa là 7,1%): định dạng"percent"nhân 100, nên chia 100 trước khi vẽ hay so với lợi nhuận —d.macro("gdp_yoy").div(100). - Trong phân tích, khai báo trong
fieldsdạngmacro:mã:data.bars("VNINDEX", { fields: ["macro:cpi_yoy", "macro:ib_on"] }). - Kỳ phân tích có khoảng trống, chuỗi bắt đầu muộn hoặc ngừng có số thì kết quả có ghi chú Chuỗi vĩ mô "…"…; trong khoảng thiếu, giá trị giữ nguyên số cũ. Mã không có trong danh mục: ghi chú Không có chuỗi vĩ mô "…" và chuỗi để trống.
Cột Dùng được từ là lúc số đầu tiên được công bố, tức có trong backtest (chuỗi tháng, quý, năm: tháng công bố; chuỗi ngày: ngày công bố); đủ từ — lúc có số trở lại sau khoảng trống dài cuối cùng (đo ngày 19/10/2026). Mốc này có thể muộn hơn kỳ của số: tín dụng, M2 kỳ 01/2025 công bố 24/03/2025 nên ghi 03/2025.
Tăng trưởng
| Mã | Chuỗi | Đơn vị | Kỳ | Dùng được từ |
|---|---|---|---|---|
gdp_yoy | Tăng trưởng GDP quý (so cùng kỳ) | % | quý | 03/2018 |
gdp_ytd_yoy | Tăng trưởng GDP lũy kế từ đầu năm (so cùng kỳ) | % | quý | 12/2000 · đủ từ 12/2010 |
gdp_agri_yoy | GDP nông, lâm nghiệp và thủy sản (so cùng kỳ) | % | quý | 03/2018 |
gdp_industry_yoy | GDP công nghiệp và xây dựng (so cùng kỳ) | % | quý | 03/2018 |
gdp_mfg_yoy | GDP công nghiệp chế biến, chế tạo (so cùng kỳ) | % | quý | 03/2018 |
gdp_services_yoy | GDP dịch vụ (so cùng kỳ) | % | quý | 03/2018 |
gdp_nominal_q | GDP quý theo giá hiện hành | nghìn tỷ đồng | quý | 03/2018 |
gdp_real_q | GDP quý theo giá so sánh | nghìn tỷ đồng | quý | 03/2018 |
gdp_real_ytd | GDP lũy kế theo giá so sánh | nghìn tỷ đồng | quý | 03/2018 |
gdp_agri_q | GDP nông, lâm nghiệp và thủy sản (giá so sánh) | nghìn tỷ đồng | quý | 03/2018 |
gdp_agri_ytd | GDP nông, lâm nghiệp và thủy sản lũy kế | nghìn tỷ đồng | quý | 03/2018 |
gdp_construction_q | GDP xây dựng (giá so sánh) | nghìn tỷ đồng | quý | 03/2018 |
gdp_construction_ytd | GDP xây dựng lũy kế | nghìn tỷ đồng | quý | 03/2018 |
gdp_mfg_q | GDP công nghiệp chế biến, chế tạo (giá so sánh) | nghìn tỷ đồng | quý | 03/2018 |
gdp_mfg_ytd | GDP công nghiệp chế biến, chế tạo lũy kế | nghìn tỷ đồng | quý | 03/2018 |
gdp_mining_q | GDP khai khoáng (giá so sánh) | nghìn tỷ đồng | quý | 03/2018 |
gdp_mining_ytd | GDP khai khoáng lũy kế | nghìn tỷ đồng | quý | 03/2018 |
gdp_public_admin_q | GDP quản lý nhà nước, an ninh quốc phòng (giá so sánh) | nghìn tỷ đồng | quý | 03/2018 |
gdp_public_admin_ytd | GDP quản lý nhà nước, an ninh quốc phòng lũy kế | nghìn tỷ đồng | quý | 03/2018 |
gdp_services_q | GDP dịch vụ (giá so sánh) | nghìn tỷ đồng | quý | 03/2018 |
gdp_services_ytd | GDP dịch vụ lũy kế | nghìn tỷ đồng | quý | 03/2018 |
gdp_transport_q | GDP vận tải, kho bãi (giá so sánh) | nghìn tỷ đồng | quý | 03/2018 |
gdp_transport_ytd | GDP vận tải, kho bãi lũy kế | nghìn tỷ đồng | quý | 03/2018 |
gdp_utility_q | GDP sản xuất, phân phối điện, khí đốt (giá so sánh) | nghìn tỷ đồng | quý | 03/2018 |
gdp_utility_ytd | GDP sản xuất, phân phối điện, khí đốt lũy kế | nghìn tỷ đồng | quý | 03/2018 |
invest_q | Vốn đầu tư thực hiện toàn xã hội quý | nghìn tỷ đồng | quý | 03/2014 · đủ từ 03/2018 |
invest_yoy | Vốn đầu tư toàn xã hội quý (so cùng kỳ) | % | quý | 03/2014 · đủ từ 03/2018 |
public_invest | Vốn đầu tư thực hiện từ ngân sách nhà nước tháng | nghìn tỷ đồng | tháng | 01/2000 |
public_invest_ytd_yoy | Vốn ngân sách nhà nước lũy kế (so cùng kỳ) | % | tháng | 03/2000 · đủ từ 02/2011 |
weo_gdp_growth | Tăng trưởng GDP thực (IMF WEO) | % | năm | 04/1990 |
weo_gdp_usd | GDP danh nghĩa (IMF WEO) | tỷ USD | năm | 09/2003 |
weo_gdp_pc | GDP bình quân đầu người (IMF WEO) | USD | năm | 09/2003 |
weo_gdp_pc_ppp | GDP bình quân đầu người theo sức mua (IMF WEO) | USD PPP | năm | 09/2003 |
weo_gov_debt | Nợ chính phủ / GDP (IMF WEO) | % | năm | 10/2010 |
wb_gfcf | Tích lũy tài sản cố định | nghìn tỷ đồng | năm | 07/1996 |
Sản xuất và doanh nghiệp
| Mã | Chuỗi | Đơn vị | Kỳ | Dùng được từ |
|---|---|---|---|---|
wb_inventory | Biến động tồn kho | nghìn tỷ đồng | năm | 07/1996 |
iip_yoy | Chỉ số sản xuất công nghiệp (so cùng kỳ) | % | tháng | 06/2011 |
iip_mfg_yoy | IIP chế biến, chế tạo (so cùng kỳ) | % | tháng | 07/2012 |
iip_mining_yoy | IIP khai khoáng (so cùng kỳ) | % | tháng | 07/2012 |
iip_power_yoy | IIP sản xuất và phân phối điện (so cùng kỳ) | % | tháng | 07/2012 |
electricity | Điện sản xuất | tỷ kWh | tháng | 04/2007 · đủ từ 07/2007 |
crude_oil | Dầu thô khai thác | nghìn tấn | tháng | 04/2007 · đủ từ 07/2007 |
steel | Thép cán | nghìn tấn | tháng | 01/2000 · đủ từ 01/2013 |
cement | Xi măng | triệu tấn | tháng | 01/2000 |
firms_new_ytd | Doanh nghiệp thành lập mới (lũy kế) | doanh nghiệp | tháng | 11/2017 |
firms_return_ytd | Doanh nghiệp quay lại hoạt động (lũy kế) | doanh nghiệp | tháng | 09/2016 |
firms_suspended_ytd | Doanh nghiệp tạm ngừng kinh doanh (lũy kế) | doanh nghiệp | tháng | 09/2016 |
firms_dissolved_ytd | Doanh nghiệp giải thể (lũy kế) | doanh nghiệp | tháng | 09/2018 |
Lạm phát và giá
| Mã | Chuỗi | Đơn vị | Kỳ | Dùng được từ |
|---|---|---|---|---|
weo_inflation | Lạm phát bình quân năm (IMF WEO) | % | năm | 04/1990 |
cpi_yoy | CPI (so cùng kỳ) | % | tháng | 01/2000 |
cpi_mom | CPI (so tháng trước) | % | tháng | 01/2000 |
cpi_ytd_avg | CPI bình quân từ đầu năm (so cùng kỳ) | % | tháng | 09/2007 |
cpi_vs_dec | CPI so tháng 12 năm trước | % | tháng | 01/2000 |
cpi_core_yoy | Lạm phát cơ bản (so cùng kỳ) | % | tháng | 01/2015 |
cpi_food_yoy | CPI hàng ăn và dịch vụ ăn uống (so cùng kỳ) | % | tháng | 05/2006 |
cpi_transport_yoy | CPI giao thông (so cùng kỳ) | % | tháng | 11/2009 |
gold_index_yoy | Chỉ số giá vàng (so cùng kỳ) | % | tháng | 01/2000 |
usd_index_yoy | Chỉ số giá đô la Mỹ (so cùng kỳ) | % | tháng | 01/2000 |
cpi_index | CPI (chỉ số, nối qua các kỳ gốc) | điểm | tháng | 01/2000 |
ppi_yoy | Giá sản xuất công nghiệp (so cùng kỳ) | % | quý | 03/2011 · đủ từ 12/2012 |
export_price_yoy | Giá xuất khẩu hàng hóa (so cùng kỳ) | % | quý | 03/2018 |
import_price_yoy | Giá nhập khẩu hàng hóa (so cùng kỳ) | % | quý | 03/2018 |
petrol_ron95 | Giá xăng RON 95 (vùng 1) | đồng/lít | ngày | 09/10/2008 |
diesel | Giá dầu điêzen 0,05S (vùng 1) | đồng/lít | ngày | 03/12/2008 |
Tiền tệ và lãi suất
| Mã | Chuỗi | Đơn vị | Kỳ | Dùng được từ |
|---|---|---|---|---|
ib_on | Lãi suất liên ngân hàng qua đêm | % | ngày | 06/01/2014 |
ib_1w | Lãi suất liên ngân hàng 1 tuần | % | ngày | 06/01/2014 |
ib_2w | Lãi suất liên ngân hàng 2 tuần | % | ngày | 06/01/2014 |
ib_1m | Lãi suất liên ngân hàng 1 tháng | % | ngày | 06/01/2014 |
ib_3m | Lãi suất liên ngân hàng 3 tháng | % | ngày | 06/01/2014 |
ib_6m | Lãi suất liên ngân hàng 6 tháng | % | ngày | 06/01/2014 · đủ từ 30/06/2014 |
ib_9m | Lãi suất liên ngân hàng 9 tháng | % | ngày | 06/01/2014 |
ib_vol_on | Doanh số liên ngân hàng qua đêm | nghìn tỷ đồng | ngày | 06/01/2014 |
ib_vol_1w | Doanh số liên ngân hàng 1 tuần | nghìn tỷ đồng | ngày | 06/01/2014 |
ib_vol_2w | Doanh số liên ngân hàng 2 tuần | nghìn tỷ đồng | ngày | 06/01/2014 |
ib_vol_1m | Doanh số liên ngân hàng 1 tháng | nghìn tỷ đồng | ngày | 06/01/2014 |
ib_vol_3m | Doanh số liên ngân hàng 3 tháng | nghìn tỷ đồng | ngày | 06/01/2014 |
ib_vol_6m | Doanh số liên ngân hàng 6 tháng | nghìn tỷ đồng | ngày | 06/01/2014 · đủ từ 30/06/2014 |
ib_vol_9m | Doanh số liên ngân hàng 9 tháng | nghìn tỷ đồng | ngày | 06/01/2014 |
omo_injection | Bơm tiền qua thị trường mở (trúng thầu trong ngày) | nghìn tỷ đồng | ngày | 22/04/2025 · đủ từ 05/11/2025 |
omo_outstanding | Dư nợ thị trường mở cuối ngày | nghìn tỷ đồng | ngày | 18/02/2026 |
credit_ytd | Tăng trưởng tín dụng từ đầu năm | % | tháng | 02/2015 · đủ từ 03/2025 |
credit | Dư nợ tín dụng đối với nền kinh tế | nghìn tỷ đồng | tháng | 02/2015 · đủ từ 03/2025 |
m2_ytd | Tổng phương tiện thanh toán tăng từ đầu năm | % | tháng | 03/2025 · đủ từ 05/2026 |
m2 | Tổng phương tiện thanh toán | nghìn tỷ đồng | tháng | 03/2025 |
usd_vcb_sell | USD/VND bán ra (Vietcombank) | đồng | ngày | 01/02/2020 |
usd_vcb_buy | USD/VND mua chuyển khoản (Vietcombank) | đồng | ngày | 01/02/2020 |
usd_imf | USD/VND cuối tháng (IMF) | đồng | tháng | 02/1995 |
fx_reserves | Dự trữ quốc tế không kể vàng | tỷ USD | tháng | 04/1995 · đủ từ 03/2001 |
wb_deposit_rate | Lãi suất tiền gửi bình quân năm | % | năm | 07/1994 · đủ từ 07/1998 |
wb_lending_rate | Lãi suất cho vay bình quân năm | % | năm | 07/1994 · đủ từ 07/1997 |
Thương mại và vốn ngoại
| Mã | Chuỗi | Đơn vị | Kỳ | Dùng được từ |
|---|---|---|---|---|
terms_of_trade_yoy | Tỷ giá thương mại hàng hóa (so cùng kỳ) | % | quý | 06/2015 |
export | Xuất khẩu hàng hóa tháng | tỷ USD | tháng | 03/2009 · đủ từ 05/2014 |
import | Nhập khẩu hàng hóa tháng | tỷ USD | tháng | 03/2009 |
trade_balance | Cán cân thương mại hàng hóa tháng | tỷ USD | tháng | 03/2009 · đủ từ 05/2014 |
fdi_new_ytd | FDI đăng ký cấp mới (lũy kế) | tỷ USD | tháng | 03/2001 · đủ từ 05/2019 |
fdi_adjusted_ytd | FDI đăng ký điều chỉnh (lũy kế) | tỷ USD | tháng | 05/2019 |
tourists | Khách quốc tế đến Việt Nam | nghìn lượt | tháng | 03/2001 |
current_account | Cán cân vãng lai quý | tỷ USD | quý | 06/2025 |
weo_ca_gdp | Cán cân vãng lai / GDP (IMF WEO) | % | năm | 04/1990 |
wb_external_debt | Nợ nước ngoài | tỷ USD | năm | 07/1982 |
Tiêu dùng
| Mã | Chuỗi | Đơn vị | Kỳ | Dùng được từ |
|---|---|---|---|---|
wb_consumption | Tiêu dùng cuối cùng của hộ gia đình | nghìn tỷ đồng | năm | 07/1996 |
retail_yoy | Tổng mức bán lẻ hàng hóa, dịch vụ (so cùng kỳ) | % | tháng | 01/2004 · đủ từ 09/2018 |
retail | Tổng mức bán lẻ hàng hóa, dịch vụ tháng | nghìn tỷ đồng | tháng | 01/2004 · đủ từ 01/2013 |
Lao động và dân số
| Mã | Chuỗi | Đơn vị | Kỳ | Dùng được từ |
|---|---|---|---|---|
weo_population | Dân số (IMF WEO) | triệu người | năm | 09/2006 |
unemployment | Tỷ lệ thất nghiệp trong độ tuổi lao động | % | quý | 04/2013 |
youth_unemployment | Tỷ lệ thất nghiệp thanh niên 15–24 tuổi | % | quý | 04/2013 |
underemployment | Tỷ lệ thiếu việc làm trong độ tuổi lao động | % | quý | 04/2013 |
labour_force | Lực lượng lao động từ 15 tuổi | nghìn người | quý | 04/2013 |
Một số chuỗi thiếu cùng một tháng mỗi năm (nguồn không công bố riêng kỳ đó); trong tháng thiếu, d.macro giữ số của kỳ trước: cpi_mom không có tháng 1 (báo cáo tháng 1 chỉ có số so tháng 12, tức cpi_vs_dec); cpi_vs_dec không có tháng 12; cpi_ytd_avg không có tháng 1, 3, 12; public_invest_ytd_yoy không có tháng 12 và tháng 1; fdi_new_ytd, fdi_adjusted_ytd và firms_*_ytd không có tháng 12. GDP theo giá so sánh đổi năm gốc từ quý 1/2026: không so mức GDP qua mốc này.
Hai nhóm chuỗi ngày có số thưa theo bản chất: petrol_ron95, diesel chỉ có số ở ngày điều chỉnh giá (khoảng 25 lần mỗi năm), giữa hai lần điều chỉnh d.macro giữ giá cũ — đúng giá bán lẻ lúc đó; ib_9m, ib_vol_9m chỉ có số ở phiên có giao dịch kỳ hạn 9 tháng (khoảng một phần năm số phiên, năm 2026 có những đoạn trống hơn một tháng) — nên dùng kỳ hạn ngắn hơn.
d.bench, d.meta và thông tin khác
| Thành phần | Ý nghĩa |
|---|---|
d.bench.open … d.bench.volume | Chỉ số so sánh (mặc định VNINDEX; chiến lược đổi bằng benchmark), Panel một hàng cùng lịch phiên. Có trong chiến lược và phân tích, không có trong bộ lọc |
d.symbols | Danh sách mã theo thứ tự hàng |
d.days | Ngày của từng phiên: số ngày kể từ 01/01/1970 (dùng với dates.*) |
d.meta[i] | Thông tin mã thứ i — bảng dưới |
d.partialLast | true khi phiên cuối là nến tạm của phiên đang giao dịch |
d.asOf | Phiên cuối đã chốt dữ liệu |
d.field("tên") | Lấy trường theo tên dạng chữ, ví dụ d.field("foreignNet") |
Thuộc tính của d.meta[i] | Ý nghĩa |
|---|---|
symbol, name | Mã, tên doanh nghiệp |
exchange | Sàn: "HSX" (HOSE), "HNX", "UPCOM"; mã đã hủy niêm yết không rõ sàn cũ thì "" |
type | Loại mã: "stock" (cổ phiếu, ETF), "index", "futures", "warrant" |
icb, industry, industryShort, sector | Mã ngành ICB, tên ngành, tên ngành ngắn ("Chứng khoán", "Bất động sản"…), nhóm ngành cấp trên |
shares | Số cổ phiếu lưu hành |
adv20 | GTGD bình quân 20 phiên hiện tại (đồng) |
price, marketCap | Giá (nghìn đồng), vốn hóa (đồng) hiện tại |
listFrom, listTo, delistedAt | Chỉ có ở rổ theo thời điểm: khoảng ngày mã thuộc rổ, phiên giao dịch cuối của mã đã hủy niêm yết |
Phép tính trên Panel
Phép tính trả về Panel mới; tham số là số hoặc Panel khác. Đủ chữ ký, cách xử lý NaN: Tham chiếu hàm.
| Nhóm | Hàm |
|---|---|
| Số học | add sub mul div (chia 0 → NaN) pow min max neg abs log exp sqrt sign round clip(lo, hi) |
So sánh (1 / 0 / NaN) | gt gte lt lte eq neq between(a, b) |
| Logic | and or not · where(điềuKiện, giáTrịKhác) · fillna(v) · ffill(giớiHạn?) · isNaN notNaN |
| Theo thời gian (từng mã) | shift(n ≥ 0) · diff(n) · pct(n) · cumsum cumprod cummax cummin · ewm(span) · highest(n) lowest(n) |
| Cửa sổ trượt | rolling(n).mean() .sum() .std() .var() .min() .max() .count() .rank() .zscore() |
| Sự kiện | crossAbove(x) crossBelow(x) · barsSince() · hold(n) |
| Cắt ngang (giữa các mã, từng phiên) | rank() zscore() demean() bucket(q) topN(n) bottomN(n) · sumAcross() meanAcross() countAcross() |
| Lấy giá trị | last() · at(ngày) · values("FPT") · row(i) · get(i, t) · pick([mã]) · range(từ, đến) |
| Đổi tần suất | resample("week" | "month" | "quarter" | "year") rồi .last() .first() .sum() .mean() .max() .min() |
Công thức hay dùng:
| Muốn tính | Viết |
|---|---|
| KL so với bình quân 20 phiên | d.volume.div(d.volume.rolling(20).mean()) |
| Khoảng cách tới đỉnh 52 tuần | d.close.div(d.high.highest(250)).sub(1) |
| Đà tăng 6 tháng, bỏ tháng gần nhất | d.close.shift(21).pct(105) |
| Hạng đà tăng trong rổ (0 → 1) | d.close.pct(126).rank() |
| Biến động 60 phiên, nhóm thấp nhất 60% rổ | d.ret.rolling(60).std().rank().lte(0.6) |
| Giá vượt đỉnh 20 phiên trước đó | d.close.gt(d.high.highest(20).shift(1)) |
| MA50 vừa cắt lên MA200 trong 10 phiên gần nhất | ta.sma(d.close, 50).crossAbove(ta.sma(d.close, 200)).hold(9) |
| Số phiên từ khi có BCTC mới | d.reportNew.eq(1).barsSince() |
| P/E so với 5 năm của chính mã (0 = rẻ nhất) | d.pe.rolling(1250).rank() |
| Tiền mặt ròng (tiền + đầu tư ngắn hạn − nợ vay) | d.fin("Cash").fillna(0).add(d.fin("CashEquivalent").fillna(0)).add(d.fin("ShortTermFinancialInvestment").fillna(0)).sub(d.fin("ShortTermInterestBearingDebt").fillna(0)).sub(d.fin("LongTermInterestBearingDebt").fillna(0)) |
| VNINDEX trên MA200 (áp cho mọi mã) | d.close.gt(0).and(d.bench.close.gt(ta.sma(d.bench.close, 200))) |
| Tỷ lệ mã trong rổ trên MA50 | d.close.gt(ta.sma(d.close, 50)).meanAcross() |
| Lợi nhuận theo tháng | d.close.resample("month").last().pct(1) |
rolling(n) là cửa sổ nghiêm ngặt: cần đủ n giá trị liên tiếp không NaN mới có kết quả (mã mới niêm yết chưa có MA200 trong 200 phiên đầu). std() của cửa sổ trượt là độ lệch chuẩn tổng thể (chia n, như Bollinger); ewm(span) khởi đầu bằng trung bình của span giá trị đầu.
Tránh nhìn trước tương lai
Tín hiệu ở phiên t chỉ được dùng dữ liệu tới hết phiên t. SDK chặn từ gốc và Studio kiểm tra lại mỗi lần backtest (cách kiểm tra).
| Sai | Đúng |
|---|---|
d.close.shift(-1) — giá phiên sau (báo lỗi ngay) | Tín hiệu cuối phiên t, Studio tự khớp ở phiên t + 1 |
d.close.gt(d.close.mean()) — trung bình của cả bảng, cả lịch sử | d.close.gt(d.close.rolling(250).mean()) hoặc cummax() |
| Chuẩn hoá bằng giá trị lớn nhất của cả chuỗi | rolling(n).zscore(), rolling(n).rank() |
Chọn mã theo thông tin hôm nay (.where((m) => m.marketCap > 1e13)) cho backtest dài | .liquid(…), .top(n) — xét theo từng thời điểm |
stats.forward(giá, 20) làm tín hiệu | Chỉ dùng forward trong phân tích để đo kết quả sau sự kiện |
Tự dựng Panel
Cần tính theo vòng lặp (gom nhóm ngành, logic phức tạp) thì tính trên mảng rồi dựng lại Panel cùng lịch phiên:
// Điểm = đà tăng của mã, chỉ cho mã thuộc 3 ngành có đà tăng trung bình cao nhất ở từng phiên
const mom = d.close.pct(126);
const groups = new Map();
d.meta.forEach((m, i) => groups.set(m.industry, [...(groups.get(m.industry) ?? []), i]));
const rows = d.symbols.map(() => new Float32Array(d.days.length).fill(NaN));
for (let t = 0; t < d.days.length; t++) {
const ranked = [...groups.values()]
.map((idx) => ({ idx, avg: stats.mean(idx.map((i) => mom.get(i, t))) }))
.filter((g) => Number.isFinite(g.avg))
.sort((a, b) => b.avg - a.avg);
for (const g of ranked.slice(0, 3)) for (const i of g.idx) rows[i][t] = mom.get(i, t);
}
const score = Panel.fromRows(d.symbols, d.days, rows);
Panel.fromRows(tênHàng, ngày, mảngCácHàng) dựng Panel từ mảng (mỗi hàng dài bằng d.days); Panel.full(tênHàng, ngày, giáTrị) dựng Panel một giá trị. Trong phân tích, Panel.fromRows(["Tên"], d.days, [mảng]) giúp vẽ một chuỗi tự tính theo trục ngày.
Strategy functions (signals, rank, weights, filter) and screener functions (columns, filter) receive the data d; an analysis gets d from await data.bars(…). This page lists every field of d — exact name, meaning, unit — and how to compute on a Panel. For when the data starts, when it is updated and how it is used by publication date, see Data and order-fill simulation.
Panel: tickers × sessions
Each field of d is a Panel — a table of numbers where each row is a ticker and each column is a trading session (following the VNINDEX session calendar):
d.close 04/01/2016 05/01/2016 … 14/10/2026
FPT 7.77 7.77 … 57.10
HPG 2.56 2.54 … 20.80
VNM 45.04 44.69 … 57.90
Prices are adjusted prices: FPT in 2016 shows 7.77 because later cash dividends and bonus shares have been subtracted; in the latest session the adjusted price equals the actual matched price.
- Missing data is
NaN(before listing, after trading stops, periods with no figures yet). A suspended session keeps the previous close, with Vol 0. - A condition is a Panel of 1 / 0 /
NaN(true / false / unknown):d.close.gt(ta.sma(d.close, 200))gives 1 when the price is above MA200. The logicand,or,notis three-valued:0 and NaN = 0,1 or NaN = 1; anything else involvingNaNyieldsNaN. In simulation,NaNis treated as false. - Operations run on the whole table at once, and the result is a new Panel of the same shape:
d.close.div(d.high.highest(250)).sub(1)is the distance to the 52-week high for every ticker and every session. - A single-row Panel (VNINDEX in
d.bench, a macro seriesd.macro(…), the result ofsumAcross()) broadcasts automatically when combined with a multi-ticker Panel:d.close.gt(0).and(d.bench.close.gt(ta.sma(d.bench.close, 200)))is a multi-ticker Panel. What Studio receives back (exit,score, screener columns and conditions) must be a multi-ticker Panel — if you return a single-row Panel directly, only the first ticker in the universe gets the right value, and the result is wrong. - Numbers are stored as 32-bit floats (about 7 significant digits, relative error around 10⁻⁷) — enough for prices, ratios and money values.
Price and volume
| Field | Meaning | Unit |
|---|---|---|
d.open, d.high, d.low, d.close | Open, high, low, close prices adjusted for dividends and splits | VND thousand (indices: points) |
d.volume | Matched volume, raw (not adjusted for splits) | shares |
d.volumeAdj | Matched volume adjusted for splits = volume × adjRatio — comparable across splits | shares |
d.tradable | 1 if the session had matched trades, 0 if suspended / no matches | — |
d.value | Estimated matched value = close × volume × 1000 | VND |
d.ret | Session return = close ÷ previous session's close − 1 | ratio |
d.value uses adjusted prices, so in distant periods it is lower than the actual traded value for tickers that later paid stock dividends; for the actual value use d.valueExact (below).
Raw prices and trading details
| Field | Meaning | Unit |
|---|---|---|
d.closeRaw | Raw close price, unadjusted (provisional candle: the current matched price) | VND thousand |
d.basic | Raw reference price | VND thousand |
d.avgPrice | Session average price, raw | VND thousand |
d.valueExact | Total trading value including put-through deals | VND |
d.dealVolume | Matched volume, raw | shares |
d.putthroughVolume, d.putthroughValue | Put-through volume / value | shares / VND |
d.adjRatio | Cumulative adjustment factor: adjusted price = raw price ÷ adjRatio | — |
For the detail, foreign-investor and order-count fields: a session with trading for which the source has no figure records 0 (except propNet, which stays NaN).
Foreign investors, proprietary trading, order counts
| Field | Meaning | Unit |
|---|---|---|
d.foreignBuyVolume, d.foreignSellVolume | Volume bought / sold by foreign investors | shares |
d.foreignBuyValue, d.foreignSellValue | Value bought / sold by foreign investors | VND |
d.foreignNet | Foreign net buying value = buy − sell | VND |
d.foreignNetVolume | Foreign net buying volume | shares |
d.foreignRoom | Remaining foreign ownership room | shares |
d.propNet | Net buying value of securities companies' proprietary trading (from Dec 2019) | VND |
d.buyCount, d.sellCount | Number of buy / sell orders placed | orders |
d.buyVolume, d.sellVolume | Volume of buy / sell orders placed | shares |
Today's session figures are available after 19:00; before that, the cells of the unsettled session are NaN. Screeners that use foreign-investor or proprietary-trading data should set includeToday: false and apply fillna(0) before accumulating:
// Khối ngoại mua ròng 20 phiên so với GT giao dịch của chính mã
const flow = d.foreignNet.fillna(0).rolling(20).sum().div(d.value.rolling(20).sum());
Financial statements by publication date
The value from the latest financial statement already usable before that session (quarterly or annual, see the usable-date rule), held until the next report.
| Field | Meaning | Unit |
|---|---|---|
d.eps | Basic EPS, trailing 4 quarters | VND / share |
d.bvps | Book value per share | VND |
d.roe, d.roa | ROE, ROA, trailing 4 quarters | ratio (0.15 = 15%) |
d.grossMargin | Gross margin, 4 quarters | ratio |
d.revenueGrowth | Quarterly net revenue, year over year | ratio |
d.profitGrowth | Quarterly net profit attributable to parent shareholders, year over year | ratio |
d.debtToEquity | Liabilities (total liabilities, including non-interest-bearing) / equity | times |
d.fScore | Piotroski F-Score 0–9, from annual statements only | points |
d.reportNew | 1 on the first session a new statement (quarterly, annual) is used, 0 on other sessions | — |
d.pe | P/E = raw price × 1,000 ÷ 4-quarter EPS; NaN when EPS ≤ 0 | times |
d.pb | P/B = raw price × 1,000 ÷ book value; NaN when ≤ 0 | times |
d.earningsYield | Earnings yield = EPS ÷ (raw price × 1,000) — the inverse of P/E, usable even when loss-making | ratio |
P/E and P/B are computed from the price of each session (intraday: the current matched price) and the published EPS and book value — unlike d.fin("PE"), which is P/E at the end of the reporting period. Banks, securities companies and insurers usually leave debtToEquity, fScore and margins empty.
d.fin: 72 financial statement items
d.fin("Khóa", { ttm, period, ago }) returns a Panel of one item by publication date (FireAnt key names, case-insensitive). Each session takes the latest period of that item already usable before the session.
| Option | Meaning |
|---|---|
period | "quarter" (default): quarterly statements; "year": annual statements. Items only available in annual statements (FCF, PiotroskiFScore) use "year" automatically |
ttm: true | Sum of the 4 most recent consecutive quarters — only for "Quarter" items; if a quarter is missing, NaN |
ago: n | Go back n periods from the latest (0–20): quarterly ago: 4 = same period last year; annual ago: 1 = previous year |
The Figure column tells you what the number in a quarterly statement is: Quarter — incurred during the quarter (for an annual period, the full year), summed over 4 quarters with ttm; 4 quarters — already computed over the last 4 quarters within the quarterly report; Period end — a balance or ratio at the end of the period; YoY; Year — only in annual statements. Money is in VND.
// LNST cổ đông mẹ của quý so cùng kỳ (bỏ kỳ trước ≤ 0 để tăng trưởng không đổi dấu)
const lnst = (ago) => d.fin("ParentCompanyShareholderProfitAfterTax", { ago });
const growth = lnst(0).div(lnst(4).where(lnst(4).gt(0))).sub(1);
// Dòng tiền kinh doanh 4 quý so với LNST 4 quý (chất lượng lợi nhuận)
const cashRatio = d.fin("CashflowFromOperatingActivity", { ttm: true }).div(d.fin("ProfitAfterTax", { ttm: true }));
// ROE thấp nhất của 3 BCTC năm gần nhất
const roeY = (k) => d.fin("ROE", { period: "year", ago: k });
const roeMin3 = roeY(0).min(roeY(1)).min(roeY(2));
In an analysis, declare the items up front in the fields of data.bars, as fin:Key with the suffixes :ttm, :year, :agoN: data.bars(universe("HOSE"), { fields: ["fin:NetSale:ttm", "fin:NetSale:ttm:ago4", "fin:FCF"] }).
Income statement (quarterly figures; annual period is the full year)
| Key | Meaning | Figure |
|---|---|---|
NetSale | Net revenue | Quarter |
TotalRevenue | Revenue from sales and services (before deductions) | Quarter |
CostOfGoodSold | Cost of goods sold (positive number) | Quarter |
GrossProfit | Gross profit | Quarter |
SellingExpense | Selling expenses | Quarter |
ManagingExpense | General and administrative expenses | Quarter |
FinancialExpense | Financial expenses | Quarter |
InterestExpense | Interest expense | Quarter |
ProfitFromFinancialActivity | Profit from financial activities | Quarter |
NetProfitFromOperatingActivity | Net operating profit | Quarter |
EBIT | Earnings before interest and taxes | Quarter |
EBITDA | EBITDA | Quarter |
DepreciationAndAmortization | Depreciation and amortization | Quarter |
ProfitBeforeTax | Profit before tax | Quarter |
ProfitAfterTax | Profit after tax | Quarter |
ParentCompanyShareholderProfitAfterTax | Net profit attributable to parent company shareholders | Quarter |
Balance sheet (period-end balances)
| Key | Meaning | Figure |
|---|---|---|
TotalAsset | Total assets | Period end |
TotalCurrentAsset | Current assets | Period end |
Cash | Cash (excluding cash equivalents) | Period end |
CashEquivalent | Cash equivalents | Period end |
ShortTermFinancialInvestment | Short-term financial investments (including term deposits) | Period end |
TotalShortTermReceivable | Short-term receivables | Period end |
TotalInventory | Inventories | Period end |
FixedAsset | Fixed assets | Period end |
TotalDebt | Liabilities (total liabilities, including non-interest-bearing) | Period end |
TotalShortTermDebt | Current liabilities | Period end |
TotalLongTermDebt | Long-term liabilities | Period end |
ShortTermInterestBearingDebt | Short-term borrowings (interest-bearing) | Period end |
LongTermInterestBearingDebt | Long-term borrowings (interest-bearing) | Period end |
StockHolderEquity | Owners' equity | Period end |
RetainedProfit | Retained earnings | Period end |
WorkingCapital | Working capital = current assets − current liabilities | Period end |
Cash flow
| Key | Meaning | Figure |
|---|---|---|
CashflowFromOperatingActivity | Net cash flow from operating activities | Quarter |
CashflowFromInvestingActivity | Net cash flow from investing activities | Quarter |
CashflowFromFinancingActivity | Net cash flow from financing activities | Quarter |
CAPEX | Purchases of fixed assets over 4 quarters (positive number) | 4 quarters |
FCF | Free cash flow | Year |
Per share, valuation at period end
| Key | Meaning | Figure |
|---|---|---|
ShareAtPeriodEnd | Shares outstanding at period end (shares) | Period end |
MarketCapAtPeriodEnd | Market cap at period end | Period end |
BasicEPS | Basic EPS, 4 quarters (VND / share) | 4 quarters |
DilutedEPS | Diluted EPS, 4 quarters | 4 quarters |
BookValuePerShare | Book value per share | Period end |
SalePerShare | 4-quarter revenue per share | 4 quarters |
CashDividend | Cash dividend per share for the latest year | 4 quarters |
DividendYield | Cash dividend yield at the period-end price (ratio) | 4 quarters |
PayoutRatio | Dividend payout ratio (ratio) | 4 quarters |
PE | P/E at the period-end price (per-session price: d.pe) | 4 quarters |
PB | P/B at the period-end price (per-session price: d.pb) | Period end |
PS | P/S at the period-end price | 4 quarters |
EVOverEBITDA | EV/EBITDA at the period-end price | 4 quarters |
Returns, margins (4 quarters)
| Key | Meaning | Figure |
|---|---|---|
ROE | ROE (ratio) | 4 quarters |
ROA | ROA | 4 quarters |
ROIC | ROIC | 4 quarters |
ROCE | ROCE | 4 quarters |
GrossMargin | Gross margin | 4 quarters |
EBITMargin | EBIT margin | 4 quarters |
OperatingMargin | Operating margin | 4 quarters |
PreTaxMargin | Pre-tax margin | 4 quarters |
TotalAssetTurnover | Total asset turnover (times) | 4 quarters |
InventoryTurnover | Inventory turnover | 4 quarters |
ReceivableTurnover | Receivables turnover | 4 quarters |
InterestCoverageRatio | Interest coverage = EBIT ÷ interest expense | 4 quarters |
Liquidity, leverage (period end)
| Key | Meaning | Figure |
|---|---|---|
CurrentRatio | Current ratio (times) | Period end |
QuickRatio | Quick ratio | Period end |
TotalDebtOverEquity | Liabilities ÷ equity | Period end |
TotalDebtOverAsset | Liabilities ÷ total assets (ratio) | Period end |
Year-over-year growth, scores
| Key | Meaning | Figure |
|---|---|---|
SaleGrowth | Quarterly net revenue, year over year | YoY |
ProfitGrowth | Quarterly net profit attributable to parent shareholders, year over year | YoY |
BasicEPSGrowth | 4-quarter EPS, year over year | YoY |
PiotroskiFScore | Piotroski F-Score 0–9 | Year |
ManufacturingZScore | Altman Z-Score for manufacturing companies | Period end |
NonManufacturingZScore | Altman Z-Score for non-manufacturing companies | Period end |
TotalDebtis total liabilities, including non-interest-bearing liabilities; borrowings =ShortTermInterestBearingDebt+LongTermInterestBearingDebt.Cashdoes not includeCashEquivalent.- Banks, securities companies and insurers use their own statement templates: many items are empty (cost of goods sold, inventories, EBIT, borrowings…) or mean something different. When adding items that may be empty, apply
fillna(0)to each part, and only compare within the same sector group. - If one quarter is missing from 4 consecutive quarters (the company only publishes semi-annual or annual reports),
ttmyieldsNaN— useperiod: "year". period: "year"gives audited figures, usable from the date they are available (usually late March, sometimes as late as July); before that date it is still the previous year.- If the server does not have an item yet, the result carries the note Máy chủ dữ liệu chưa có chỉ tiêu BCTC … — để trống. (The data server does not have the financial statement item … yet — left empty.)
Dividends, corporate actions, ceiling / floor
| Field | Meaning | Unit |
|---|---|---|
d.cashDividend | Cash dividend on the ex-date session (the next session if that day is a holiday); 0 on other sessions | VND / share |
d.dividendYield | 12-month cash dividend yield = sum of cashDividend over 250 sessions ÷ (raw price × 1,000); needs 250 prior sessions of data | ratio |
d.exRights | 1 on an ex-date session with a price adjustment (dividend, split, rights issue) | — |
d.ceiling, d.floor | Session ceiling and floor prices (adjusted like prices) | VND thousand |
d.atCeiling, d.atFloor | 1 if the close is at the ceiling / floor price | — |
Community and news
| Field | Meaning |
|---|---|
d.newsCount | Number of news items tagged with the ticker that day |
d.postCount | Number of FireAnt community posts mentioning the ticker that day |
d.postAuthors | Number of distinct authors mentioning the ticker that day |
d.postLikes, d.postReplies | Total likes and replies on those posts |
d.bullishPosts, d.bearishPosts | Number of posts where the author chose a positive / negative sentiment |
Available from 28 Jan 2021; days with no posts are 0, before 2021 it is NaN. Today's session figures are available after the update at about 19:10 (update schedule); before that, today's cell is NaN, so use fillna(0) before computing rolling windows. The level of chatter is meaningful when compared with the same ticker: for example d.postCount.fillna(0).rolling(5).mean().div(d.postCount.fillna(0).rolling(60).mean()) is how many times the 5-session post count exceeds normal.
Insider trading and major shareholders
| Field | Meaning | Unit |
|---|---|---|
d.insiderBuy, d.insiderSell | Volume bought / sold by individual insiders, related persons and major shareholders, recorded on the 3rd session after the execution date; 0 on other sessions | shares |
d.insiderBuyPlan, d.insiderSellPlan | Volume individuals registered to buy / sell, recorded on the first session they may trade | shares |
d.holderBuy, d.holderSell | Volume bought / sold by institutions (major shareholders, parent companies, funds), like insiderBuy | shares |
d.insiderNet | insiderBuy − insiderSell | shares |
d.insiderNetValue | insiderNet × the session's raw price | VND |
d.stateOwnership | State ownership ratio (0–1) — current snapshot | ratio |
d.foreignMajorOwnership | Total stake of foreign major shareholders — current snapshot | ratio |
d.founderOwnership | Total stake of founding shareholders — current snapshot | ratio |
d.majorOwnership | Total stake of disclosed shareholders; 1 − majorOwnership ≈ free float — current snapshot | ratio |
d.majorHolders | Number of disclosed shareholders — current snapshot | shareholders |
In years with insider trading data, sessions without trades are 0. The five snapshot fields are only available from the date the shareholder list was updated, NaN before that — use them for today's screeners, not for backtests (see Insider trading and major shareholders).
// GT cá nhân nội bộ mua ròng 60 phiên, tỷ đồng
const insider60 = d.insiderNetValue.fillna(0).rolling(60).sum().div(1e9);
d.macro: 108 macro series
d.macro("code") returns a single-row Panel (like d.bench, it broadcasts when combined with a multi-ticker Panel): the figure known at each session — the latest period published before the session, with revised figures used from the date the revision appeared (rule).
// Chỉ nắm cổ phiếu khi lãi suất liên ngân hàng qua đêm dưới 4% và lạm phát dưới 4,5%
signals: (d) => {
const ok = d.macro("ib_on").lt(4).and(d.macro("cpi_yoy").lt(4.5));
const up = d.close.gt(ta.sma(d.close, 50));
return { entry: up.and(ok), exit: up.not().or(ok.not()) };
},
- A macro condition placed only in
entryonly blocks buying; to sell when the macro picture worsens, put the opposite condition inexitas above. For rotation strategies, put the condition infilter: if no ticker qualifies at a rebalance, the portfolio moves to cash. - Series in % are percentage numbers (
gdp_yoy7.1 means 7.1%): the"percent"format multiplies by 100, so divide by 100 before plotting or comparing with returns —d.macro("gdp_yoy").div(100). - In an analysis, declare them in
fieldsasmacro:code:data.bars("VNINDEX", { fields: ["macro:cpi_yoy", "macro:ib_on"] }). - If the analysis period has gaps, or a series starts late or stops updating, the result carries the note Chuỗi vĩ mô "…"… (Macro series "…"…); during the gap, the value holds the old figure. For a code not in the catalog: the note Không có chuỗi vĩ mô "…" (No macro series "…") and the series is left empty.
The Usable from column is when the first figure was published, i.e. available in backtests (monthly, quarterly, annual series: the publication month; daily series: the publication date); complete from — when figures resumed after the last long gap (measured on 19 Oct 2026). This date can be later than the figure's period: credit and M2 for Jan 2025 were published on 24 Mar 2025, so it reads Mar 2025.
Growth
| Code | Series | Unit | Period | Usable from |
|---|---|---|---|---|
gdp_yoy | Quarterly GDP growth (YoY) | % | quarter | Mar 2018 |
gdp_ytd_yoy | Year-to-date GDP growth (YoY) | % | quarter | Dec 2000 · complete from Dec 2010 |
gdp_agri_yoy | GDP of agriculture, forestry and fishery (YoY) | % | quarter | Mar 2018 |
gdp_industry_yoy | GDP of industry and construction (YoY) | % | quarter | Mar 2018 |
gdp_mfg_yoy | GDP of manufacturing and processing (YoY) | % | quarter | Mar 2018 |
gdp_services_yoy | GDP of services (YoY) | % | quarter | Mar 2018 |
gdp_nominal_q | Quarterly GDP at current prices | VND tn | quarter | Mar 2018 |
gdp_real_q | Quarterly GDP at constant prices | VND tn | quarter | Mar 2018 |
gdp_real_ytd | Year-to-date GDP at constant prices | VND tn | quarter | Mar 2018 |
gdp_agri_q | GDP of agriculture, forestry and fishery (constant prices) | VND tn | quarter | Mar 2018 |
gdp_agri_ytd | GDP of agriculture, forestry and fishery, year to date | VND tn | quarter | Mar 2018 |
gdp_construction_q | GDP of construction (constant prices) | VND tn | quarter | Mar 2018 |
gdp_construction_ytd | GDP of construction, year to date | VND tn | quarter | Mar 2018 |
gdp_mfg_q | GDP of manufacturing and processing (constant prices) | VND tn | quarter | Mar 2018 |
gdp_mfg_ytd | GDP of manufacturing and processing, year to date | VND tn | quarter | Mar 2018 |
gdp_mining_q | GDP of mining (constant prices) | VND tn | quarter | Mar 2018 |
gdp_mining_ytd | GDP of mining, year to date | VND tn | quarter | Mar 2018 |
gdp_public_admin_q | GDP of public administration, security and defense (constant prices) | VND tn | quarter | Mar 2018 |
gdp_public_admin_ytd | GDP of public administration, security and defense, year to date | VND tn | quarter | Mar 2018 |
gdp_services_q | GDP of services (constant prices) | VND tn | quarter | Mar 2018 |
gdp_services_ytd | GDP of services, year to date | VND tn | quarter | Mar 2018 |
gdp_transport_q | GDP of transport and warehousing (constant prices) | VND tn | quarter | Mar 2018 |
gdp_transport_ytd | GDP of transport and warehousing, year to date | VND tn | quarter | Mar 2018 |
gdp_utility_q | GDP of electricity and gas production and distribution (constant prices) | VND tn | quarter | Mar 2018 |
gdp_utility_ytd | GDP of electricity and gas production and distribution, year to date | VND tn | quarter | Mar 2018 |
invest_q | Quarterly realized total social investment | VND tn | quarter | Mar 2014 · complete from Mar 2018 |
invest_yoy | Quarterly total social investment (YoY) | % | quarter | Mar 2014 · complete from Mar 2018 |
public_invest | Monthly realized state budget investment | VND tn | month | Jan 2000 |
public_invest_ytd_yoy | State budget investment, year to date (YoY) | % | month | Mar 2000 · complete from Feb 2011 |
weo_gdp_growth | Real GDP growth (IMF WEO) | % | year | Apr 1990 |
weo_gdp_usd | Nominal GDP (IMF WEO) | USD bn | year | Sep 2003 |
weo_gdp_pc | GDP per capita (IMF WEO) | USD | year | Sep 2003 |
weo_gdp_pc_ppp | GDP per capita at purchasing power parity (IMF WEO) | USD PPP | year | Sep 2003 |
weo_gov_debt | Government debt / GDP (IMF WEO) | % | year | Oct 2010 |
wb_gfcf | Gross fixed capital formation | VND tn | year | Jul 1996 |
Production and businesses
| Code | Series | Unit | Period | Usable from |
|---|---|---|---|---|
wb_inventory | Change in inventories | VND tn | year | Jul 1996 |
iip_yoy | Industrial production index (YoY) | % | month | Jun 2011 |
iip_mfg_yoy | IIP manufacturing and processing (YoY) | % | month | Jul 2012 |
iip_mining_yoy | IIP mining (YoY) | % | month | Jul 2012 |
iip_power_yoy | IIP electricity production and distribution (YoY) | % | month | Jul 2012 |
electricity | Electricity produced | bn kWh | month | Apr 2007 · complete from Jul 2007 |
crude_oil | Crude oil extracted | thousand tonnes | month | Apr 2007 · complete from Jul 2007 |
steel | Rolled steel | thousand tonnes | month | Jan 2000 · complete from Jan 2013 |
cement | Cement | mn tonnes | month | Jan 2000 |
firms_new_ytd | Newly established businesses (year to date) | businesses | month | Nov 2017 |
firms_return_ytd | Businesses resuming operations (year to date) | businesses | month | Sep 2016 |
firms_suspended_ytd | Businesses temporarily suspending operations (year to date) | businesses | month | Sep 2016 |
firms_dissolved_ytd | Dissolved businesses (year to date) | businesses | month | Sep 2018 |
Inflation and prices
| Code | Series | Unit | Period | Usable from |
|---|---|---|---|---|
weo_inflation | Average annual inflation (IMF WEO) | % | year | Apr 1990 |
cpi_yoy | CPI (YoY) | % | month | Jan 2000 |
cpi_mom | CPI (MoM) | % | month | Jan 2000 |
cpi_ytd_avg | Year-to-date average CPI (YoY) | % | month | Sep 2007 |
cpi_vs_dec | CPI vs. December of the previous year | % | month | Jan 2000 |
cpi_core_yoy | Core inflation (YoY) | % | month | Jan 2015 |
cpi_food_yoy | CPI food and catering services (YoY) | % | month | May 2006 |
cpi_transport_yoy | CPI transport (YoY) | % | month | Nov 2009 |
gold_index_yoy | Gold price index (YoY) | % | month | Jan 2000 |
usd_index_yoy | US dollar price index (YoY) | % | month | Jan 2000 |
cpi_index | CPI (index, chained across base periods) | points | month | Jan 2000 |
ppi_yoy | Industrial producer prices (YoY) | % | quarter | Mar 2011 · complete from Dec 2012 |
export_price_yoy | Goods export prices (YoY) | % | quarter | Mar 2018 |
import_price_yoy | Goods import prices (YoY) | % | quarter | Mar 2018 |
petrol_ron95 | RON 95 gasoline price (zone 1) | VND/liter | day | 09 Oct 2008 |
diesel | Diesel 0.05S price (zone 1) | VND/liter | day | 03 Dec 2008 |
Money and interest rates
| Code | Series | Unit | Period | Usable from |
|---|---|---|---|---|
ib_on | Overnight interbank rate | % | day | 06 Jan 2014 |
ib_1w | 1-week interbank rate | % | day | 06 Jan 2014 |
ib_2w | 2-week interbank rate | % | day | 06 Jan 2014 |
ib_1m | 1-month interbank rate | % | day | 06 Jan 2014 |
ib_3m | 3-month interbank rate | % | day | 06 Jan 2014 |
ib_6m | 6-month interbank rate | % | day | 06 Jan 2014 · complete from 30 Jun 2014 |
ib_9m | 9-month interbank rate | % | day | 06 Jan 2014 |
ib_vol_on | Overnight interbank volume | VND tn | day | 06 Jan 2014 |
ib_vol_1w | 1-week interbank volume | VND tn | day | 06 Jan 2014 |
ib_vol_2w | 2-week interbank volume | VND tn | day | 06 Jan 2014 |
ib_vol_1m | 1-month interbank volume | VND tn | day | 06 Jan 2014 |
ib_vol_3m | 3-month interbank volume | VND tn | day | 06 Jan 2014 |
ib_vol_6m | 6-month interbank volume | VND tn | day | 06 Jan 2014 · complete from 30 Jun 2014 |
ib_vol_9m | 9-month interbank volume | VND tn | day | 06 Jan 2014 |
omo_injection | Open market injection (accepted bids that day) | VND tn | day | 22 Apr 2025 · complete from 05 Nov 2025 |
omo_outstanding | Open market outstanding balance at end of day | VND tn | day | 18 Feb 2026 |
credit_ytd | Year-to-date credit growth | % | month | Feb 2015 · complete from Mar 2025 |
credit | Outstanding credit to the economy | VND tn | month | Feb 2015 · complete from Mar 2025 |
m2_ytd | Total means of payment, year-to-date growth | % | month | Mar 2025 · complete from May 2026 |
m2 | Total means of payment | VND tn | month | Mar 2025 |
usd_vcb_sell | USD/VND selling rate (Vietcombank) | VND | day | 01 Feb 2020 |
usd_vcb_buy | USD/VND transfer buying rate (Vietcombank) | VND | day | 01 Feb 2020 |
usd_imf | USD/VND at month end (IMF) | VND | month | Feb 1995 |
fx_reserves | International reserves excluding gold | USD bn | month | Apr 1995 · complete from Mar 2001 |
wb_deposit_rate | Average annual deposit rate | % | year | Jul 1994 · complete from Jul 1998 |
wb_lending_rate | Average annual lending rate | % | year | Jul 1994 · complete from Jul 1997 |
Trade and foreign capital
| Code | Series | Unit | Period | Usable from |
|---|---|---|---|---|
terms_of_trade_yoy | Terms of trade for goods (YoY) | % | quarter | Jun 2015 |
export | Monthly goods exports | USD bn | month | Mar 2009 · complete from May 2014 |
import | Monthly goods imports | USD bn | month | Mar 2009 |
trade_balance | Monthly goods trade balance | USD bn | month | Mar 2009 · complete from May 2014 |
fdi_new_ytd | Newly registered FDI (year to date) | USD bn | month | Mar 2001 · complete from May 2019 |
fdi_adjusted_ytd | Adjusted registered FDI (year to date) | USD bn | month | May 2019 |
tourists | International visitors to Vietnam | thousand arrivals | month | Mar 2001 |
current_account | Quarterly current account balance | USD bn | quarter | Jun 2025 |
weo_ca_gdp | Current account balance / GDP (IMF WEO) | % | year | Apr 1990 |
wb_external_debt | External debt | USD bn | year | Jul 1982 |
Consumption
| Code | Series | Unit | Period | Usable from |
|---|---|---|---|---|
wb_consumption | Household final consumption | VND tn | year | Jul 1996 |
retail_yoy | Total retail sales of goods and services (YoY) | % | month | Jan 2004 · complete from Sep 2018 |
retail | Monthly total retail sales of goods and services | VND tn | month | Jan 2004 · complete from Jan 2013 |
Labor and population
| Code | Series | Unit | Period | Usable from |
|---|---|---|---|---|
weo_population | Population (IMF WEO) | mn people | year | Sep 2006 |
unemployment | Unemployment rate of the working-age population | % | quarter | Apr 2013 |
youth_unemployment | Youth unemployment rate, ages 15–24 | % | quarter | Apr 2013 |
underemployment | Underemployment rate of the working-age population | % | quarter | Apr 2013 |
labour_force | Labor force aged 15 and over | thousand people | quarter | Apr 2013 |
Some series miss the same month every year (the source does not publish that period separately); in a missing month, d.macro keeps the previous period's figure: cpi_mom has no January (the January report only has the figure vs. December, i.e. cpi_vs_dec); cpi_vs_dec has no December; cpi_ytd_avg has no January, March or December; public_invest_ytd_yoy has no December or January; fdi_new_ytd, fdi_adjusted_ytd and firms_*_ytd have no December. Constant-price GDP changes its base year from Q1 2026: do not compare GDP levels across this point.
Two groups of daily series are sparse by nature: petrol_ron95 and diesel only have figures on price-adjustment days (about 25 times a year); between two adjustments d.macro keeps the old price — the correct retail price at the time. ib_9m and ib_vol_9m only have figures on sessions with 9-month tenor trades (about one fifth of sessions; in 2026 there were gaps of more than a month) — prefer shorter tenors.
d.bench, d.meta and other information
| Component | Meaning |
|---|---|
d.bench.open … d.bench.volume | Benchmark index (VNINDEX by default; a strategy changes it with benchmark), a single-row Panel on the same session calendar. Available in strategies and analyses, not in screeners |
d.symbols | List of tickers in row order |
d.days | Date of each session: number of days since 01 Jan 1970 (use with dates.*) |
d.meta[i] | Information on ticker i — table below |
d.partialLast | true when the last session is the provisional candle of the session in progress |
d.asOf | The last session with settled data |
d.field("name") | Get a field by its name as text, for example d.field("foreignNet") |
Property of d.meta[i] | Meaning |
|---|---|
symbol, name | Ticker, company name |
exchange | Exchange: "HSX" (HOSE), "HNX", "UPCOM"; "" for delisted tickers whose former exchange is unknown |
type | Ticker type: "stock" (stock, ETF), "index", "futures", "warrant" |
icb, industry, industryShort, sector | ICB industry code, industry name, short industry name ("Chứng khoán" (Securities), "Bất động sản" (Real estate)…), parent sector group |
shares | Shares outstanding |
adv20 | Current 20-session average trading value (VND) |
price, marketCap | Current price (VND thousand), market cap (VND) |
listFrom, listTo, delistedAt | Only in point-in-time universes: the date range the ticker belongs to the universe, the last trading session of a delisted ticker |
Panel operations
Operations return a new Panel; arguments are numbers or another Panel. For full signatures and NaN handling: Function reference.
| Group | Functions |
|---|---|
| Arithmetic | add sub mul div (divide by 0 → NaN) pow min max neg abs log exp sqrt sign round clip(lo, hi) |
Comparison (1 / 0 / NaN) | gt gte lt lte eq neq between(a, b) |
| Logic | and or not · where(điềuKiện, giáTrịKhác) · fillna(v) · ffill(giớiHạn?) · isNaN notNaN |
| Over time (per ticker) | shift(n ≥ 0) · diff(n) · pct(n) · cumsum cumprod cummax cummin · ewm(span) · highest(n) lowest(n) |
| Rolling window | rolling(n).mean() .sum() .std() .var() .min() .max() .count() .rank() .zscore() |
| Events | crossAbove(x) crossBelow(x) · barsSince() · hold(n) |
| Cross-sectional (across tickers, per session) | rank() zscore() demean() bucket(q) topN(n) bottomN(n) · sumAcross() meanAcross() countAcross() |
| Getting values | last() · at(ngày) · values("FPT") · row(i) · get(i, t) · pick([mã]) · range(từ, đến) |
| Resampling | resample("week" | "month" | "quarter" | "year") then .last() .first() .sum() .mean() .max() .min() |
Common formulas:
| To compute | Write |
|---|---|
| Volume vs. 20-session average | d.volume.div(d.volume.rolling(20).mean()) |
| Distance to the 52-week high | d.close.div(d.high.highest(250)).sub(1) |
| 6-month momentum, skipping the latest month | d.close.shift(21).pct(105) |
| Momentum rank within the universe (0 → 1) | d.close.pct(126).rank() |
| 60-session volatility, lowest 60% of the universe | d.ret.rolling(60).std().rank().lte(0.6) |
| Price breaks above the previous 20-session high | d.close.gt(d.high.highest(20).shift(1)) |
| MA50 crossed above MA200 within the last 10 sessions | ta.sma(d.close, 50).crossAbove(ta.sma(d.close, 200)).hold(9) |
| Sessions since a new financial statement | d.reportNew.eq(1).barsSince() |
| P/E vs. the ticker's own 5 years (0 = cheapest) | d.pe.rolling(1250).rank() |
| Net cash (cash + short-term investments − borrowings) | d.fin("Cash").fillna(0).add(d.fin("CashEquivalent").fillna(0)).add(d.fin("ShortTermFinancialInvestment").fillna(0)).sub(d.fin("ShortTermInterestBearingDebt").fillna(0)).sub(d.fin("LongTermInterestBearingDebt").fillna(0)) |
| VNINDEX above MA200 (applied to every ticker) | d.close.gt(0).and(d.bench.close.gt(ta.sma(d.bench.close, 200))) |
| Share of tickers in the universe above MA50 | d.close.gt(ta.sma(d.close, 50)).meanAcross() |
| Monthly returns | d.close.resample("month").last().pct(1) |
rolling(n) is a strict window: it needs n consecutive non-NaN values to produce a result (a newly listed ticker has no MA200 for its first 200 sessions). The rolling-window std() is the population standard deviation (divides by n, as in Bollinger); ewm(span) starts from the average of the first span values.
Avoiding look-ahead
A signal at session t may only use data up to the end of session t. The SDK blocks look-ahead at the source and Studio checks again on every backtest (how it is checked).
| Wrong | Right |
|---|---|
d.close.shift(-1) — next session's price (errors immediately) | Signal at the close of session t; Studio fills at session t + 1 automatically |
d.close.gt(d.close.mean()) — mean of the whole table, the whole history | d.close.gt(d.close.rolling(250).mean()) or cummax() |
| Normalizing by the maximum of the whole series | rolling(n).zscore(), rolling(n).rank() |
Picking tickers by today's information (.where((m) => m.marketCap > 1e13)) for a long backtest | .liquid(…), .top(n) — evaluated at each point in time |
stats.forward(giá, 20) as a signal | Only use forward in analyses to measure outcomes after an event |
Building your own Panel
When you need to compute in a loop (grouping by industry, complex logic), compute on arrays and then rebuild a Panel on the same session calendar:
// Điểm = đà tăng của mã, chỉ cho mã thuộc 3 ngành có đà tăng trung bình cao nhất ở từng phiên
const mom = d.close.pct(126);
const groups = new Map();
d.meta.forEach((m, i) => groups.set(m.industry, [...(groups.get(m.industry) ?? []), i]));
const rows = d.symbols.map(() => new Float32Array(d.days.length).fill(NaN));
for (let t = 0; t < d.days.length; t++) {
const ranked = [...groups.values()]
.map((idx) => ({ idx, avg: stats.mean(idx.map((i) => mom.get(i, t))) }))
.filter((g) => Number.isFinite(g.avg))
.sort((a, b) => b.avg - a.avg);
for (const g of ranked.slice(0, 3)) for (const i of g.idx) rows[i][t] = mom.get(i, t);
}
const score = Panel.fromRows(d.symbols, d.days, rows);
Panel.fromRows(tênHàng, ngày, mảngCácHàng) builds a Panel from arrays (each row as long as d.days); Panel.full(tênHàng, ngày, giáTrị) builds a Panel filled with one value. In an analysis, Panel.fromRows(["Tên"], d.days, [mảng]) lets you plot a self-computed series on the date axis.
전략의 함수(signals, rank, weights, filter)와 스크리너의 함수(columns, filter)는 데이터 **d**를 받고, 분석은 await data.bars(…)에서 d를 얻습니다. 이 페이지는 d의 모든 필드 — 정확한 이름, 의미, 단위 — 와 Panel 위에서 계산하는 방법을 정리합니다. 데이터가 언제부터 있는지, 언제 갱신되는지, 공시일 기준으로 어떻게 쓰이는지는 데이터와 체결 모의 실행을 참고하세요.
Panel: 종목 × 세션 표
d의 각 필드는 Panel입니다. 행 하나가 종목 하나, 열 하나가 거래 세션 하나인 숫자 표입니다(VNINDEX의 거래 세션 일정 기준).
d.close 04/01/2016 05/01/2016 … 14/10/2026
FPT 7.77 7.77 … 57.10
HPG 2.56 2.54 … 20.80
VNM 45.04 44.69 … 57.90
가격은 수정 주가입니다. 2016년 FPT가 7.77로 표시되는 것은 그 이후의 현금 배당, 보너스 주식을 반영했기 때문이며, 가장 최근 세션의 수정 주가는 실제 체결가와 같습니다.
- **데이터가 없으면
NaN**입니다(상장 전, 거래 정지 후, 아직 수치가 없는 기간). 거래가 일시 정지된 세션은 직전 종가를 유지하고 KL은 0입니다. - 조건은 1 / 0 /
NaNPanel입니다(참 / 거짓 / 알 수 없음).d.close.gt(ta.sma(d.close, 200))는 가격이 MA200 위에 있을 때 1입니다. 논리 연산and,or,not은 3값 논리를 따릅니다.0 and NaN = 0,1 or NaN = 1이고, 그 밖에NaN이 섞이면NaN입니다. 모의 실행에서NaN은 거짓으로 취급됩니다. - 연산은 표 전체에 한꺼번에 적용되며, 결과는 같은 모양의 새 Panel입니다.
d.close.div(d.high.highest(250)).sub(1)은 모든 종목, 모든 세션의 52주 고점까지의 거리입니다. - 한 행짜리 Panel(
d.bench의 VNINDEX, 거시경제 시계열d.macro(…),sumAcross()의 결과)은 여러 종목 Panel과 계산할 때 자동으로 확장됩니다.d.close.gt(0).and(d.bench.close.gt(ta.sma(d.bench.close, 200)))는 여러 종목 Panel입니다. Studio가 돌려받는 값(exit,score, 스크리너의 열과 조건)은 여러 종목 Panel이어야 합니다. 한 행짜리 Panel을 그대로 반환하면 바스켓의 첫 종목만 올바른 값을 받아 결과가 틀립니다. - 숫자는 32비트 실수로 저장됩니다(유효 숫자 약 7자리, 상대 오차 약 10⁻⁷). 가격, 비율, 금액에는 충분합니다.
가격과 거래량
| 필드 | 의미 | 단위 |
|---|---|---|
d.open, d.high, d.low, d.close | 배당, 분할을 반영해 수정한 시가, 고가, 저가, 종가 | 천 동(지수: 포인트) |
d.volume | 체결량, 원래 수치(분할 미반영) | 주 |
d.volumeAdj | 분할을 반영한 체결량 = volume × adjRatio — 분할 전후 비교 가능 | 주 |
d.tradable | 세션에 체결이 있으면 1, 정지 / 미체결이면 0 | — |
d.value | 추정 체결 GT = close × volume × 1000 | 동 |
d.ret | 세션 수익률 = close ÷ 직전 세션 close − 1 | 비율 |
d.value는 수정 주가를 쓰므로, 이후 주식 배당을 한 종목은 먼 과거 기간의 값이 실제 거래대금보다 낮습니다. 실제 거래대금이 필요하면 d.valueExact(아래)를 쓰세요.
원래 가격과 상세 거래
| 필드 | 의미 | 단위 |
|---|---|---|
d.closeRaw | 수정 전 원래 종가(임시 봉: 현재 체결가) | 천 동 |
d.basic | 원래 기준가 | 천 동 |
d.avgPrice | 세션 평균가, 원래 수치 | 천 동 |
d.valueExact | 시간외 대량매매를 포함한 총 거래대금 | 동 |
d.dealVolume | 체결량, 원래 수치 | 주 |
d.putthroughVolume, d.putthroughValue | 시간외 대량매매 거래량 / 거래대금 | 주 / 동 |
d.adjRatio | 누적 수정 계수: 수정 주가 = 원래 가격 ÷ adjRatio | — |
상세 필드, 외국인, 주문 건수: 거래가 있는 세션인데 출처에 수치가 없으면 0으로 기록합니다(propNet만 NaN).
외국인, 증권사 자기매매, 주문 건수
| 필드 | 의미 | 단위 |
|---|---|---|
d.foreignBuyVolume, d.foreignSellVolume | 외국인 투자자 매수 / 매도 거래량 | 주 |
d.foreignBuyValue, d.foreignSellValue | 외국인 투자자 매수 / 매도 거래대금 | 동 |
d.foreignNet | 외국인 순매수 거래대금 = 매수 − 매도 | 동 |
d.foreignNetVolume | 외국인 순매수 거래량 | 주 |
d.foreignRoom | 외국인 잔여 보유 한도(Room) | 주 |
d.propNet | 증권사 자기매매 순매수 거래대금(2019년 12월부터) | 동 |
d.buyCount, d.sellCount | 매수 / 매도 주문 건수 | 건 |
d.buyVolume, d.sellVolume | 매수 / 매도 주문량 | 주 |
오늘 세션의 수치는 19:00 이후에 나옵니다. 그 전에는 마감되지 않은 세션의 칸이 NaN입니다. 외국인, 자기매매를 쓰는 스크리너는 includeToday: false로 설정하고, 누적하기 전에 fillna(0)을 쓰세요.
// Khối ngoại mua ròng 20 phiên so với GT giao dịch của chính mã
const flow = d.foreignNet.fillna(0).rolling(20).sum().div(d.value.rolling(20).sum());
공시일 기준 재무제표
해당 세션 전에 사용할 수 있게 된 가장 최근 BCTC(분기 또는 연간, 사용 가능일 규칙 참고)의 값이며, 다음 보고서가 나올 때까지 그대로 유지됩니다.
| 필드 | 의미 | 단위 |
|---|---|---|
d.eps | 최근 4 개 분기 기본 EPS | 동 / 주 |
d.bvps | 주당 장부가치 | 동 |
d.roe, d.roa | 최근 4개 분기 ROE, ROA | 비율(0.15 = 15%) |
d.grossMargin | 4개 분기 매출총이익률 | 비율 |
d.revenueGrowth | 분기 순매출의 전년 동기 대비 증가율 | 비율 |
d.profitGrowth | 분기 지배주주 LNST의 전년 동기 대비 증가율 | 비율 |
d.debtToEquity | 부채(무이자 부채를 포함한 총부채) / 자기자본 | 배 |
d.fScore | Piotroski F-Score 0–9, 연간 재무제표로만 계산 | 점 |
d.reportNew | 새 재무제표(분기, 연간)가 처음 사용되는 세션에 1, 다른 세션은 0 | — |
d.pe | P/E = 원래 가격 × 1,000 ÷ 4개 분기 EPS; EPS ≤ 0이면 NaN | 배 |
d.pb | P/B = 원래 가격 × 1,000 ÷ 장부가치; ≤ 0이면 NaN | 배 |
d.earningsYield | 이익수익률 = EPS ÷ (원래 가격 × 1,000) — P/E의 역수로, 적자일 때도 사용 가능 | 비율 |
P/E, P/B는 세션별 가격(장중: 현재 체결가)과 공시된 EPS, 장부가치로 계산합니다. 보고 기간 종료일의 P/E인 d.fin("PE")와 다릅니다. 은행, 증권사, 보험사는 보통 debtToEquity, fScore, 이익률이 비어 있습니다.
d.fin: 72개 재무제표 항목
d.fin("Khóa", { ttm, period, ago })는 공시일 기준 한 항목의 Panel을 반환합니다(FireAnt의 키 이름, 대소문자 구분 없음). 각 세션은 해당 항목의 세션 전에 사용할 수 있게 된 가장 최근 기간 값을 씁니다.
| 옵션 | 의미 |
|---|---|
period | "quarter"(기본): 분기 재무제표; "year": 연간 재무제표. 연간 재무제표에만 있는 항목(FCF, PiotroskiFScore)은 자동으로 "year" 사용 |
ttm: true | 최근 연속 4개 분기 합산 — "분기" 항목에만 적용; 한 분기라도 빠지면 NaN |
ago: n | 최신 기간에서 n기간 이전(0–20): 분기 ago: 4 = 전년 동기; 연간 ago: 1 = 전년 |
수치 열은 분기 재무제표의 수치가 무엇인지 나타냅니다. 분기 — 분기 중 발생액(연간 기간은 1년 전체), 4개 분기 합은 ttm; 4개 분기 — 분기 보고서 안에서 이미 최근 4개 분기로 계산된 값; 기말 — 기간 종료일의 잔액, 지표; 전년 동기 대비; 연간 — 연간 재무제표에만 있음. 금액은 동 단위입니다.
// LNST cổ đông mẹ của quý so cùng kỳ (bỏ kỳ trước ≤ 0 để tăng trưởng không đổi dấu)
const lnst = (ago) => d.fin("ParentCompanyShareholderProfitAfterTax", { ago });
const growth = lnst(0).div(lnst(4).where(lnst(4).gt(0))).sub(1);
// Dòng tiền kinh doanh 4 quý so với LNST 4 quý (chất lượng lợi nhuận)
const cashRatio = d.fin("CashflowFromOperatingActivity", { ttm: true }).div(d.fin("ProfitAfterTax", { ttm: true }));
// ROE thấp nhất của 3 BCTC năm gần nhất
const roeY = (k) => d.fin("ROE", { period: "year", ago: k });
const roeMin3 = roeY(0).min(roeY(1)).min(roeY(2));
분석에서는 data.bars의 fields에 항목을 미리 선언합니다. 형식은 fin:Khóa이고 접미사 :ttm, :year, :agoN을 붙일 수 있습니다: data.bars(universe("HOSE"), { fields: ["fin:NetSale:ttm", "fin:NetSale:ttm:ago4", "fin:FCF"] }).
손익(분기 수치; 연간 기간은 1년 전체)
| 키 | 의미 | 수치 |
|---|---|---|
NetSale | 순매출 | 분기 |
TotalRevenue | 상품·서비스 매출(차감 전) | 분기 |
CostOfGoodSold | 매출원가(양수) | 분기 |
GrossProfit | 매출총이익 | 분기 |
SellingExpense | 판매비 | 분기 |
ManagingExpense | 일반관리비 | 분기 |
FinancialExpense | 금융비용 | 분기 |
InterestExpense | 이자비용 | 분기 |
ProfitFromFinancialActivity | 금융활동 이익 | 분기 |
NetProfitFromOperatingActivity | 영업활동 순이익 | 분기 |
EBIT | 이자 및 법인세 차감 전 이익 | 분기 |
EBITDA | EBITDA | 분기 |
DepreciationAndAmortization | 감가상각비 | 분기 |
ProfitBeforeTax | 세전 이익 | 분기 |
ProfitAfterTax | 세후 순이익 | 분기 |
ParentCompanyShareholderProfitAfterTax | 지배주주 세후 순이익 | 분기 |
재무상태표(기말 잔액)
| 키 | 의미 | 수치 |
|---|---|---|
TotalAsset | 총자산 | 기말 |
TotalCurrentAsset | 유동자산 | 기말 |
Cash | 현금(현금성자산 제외) | 기말 |
CashEquivalent | 현금성자산 | 기말 |
ShortTermFinancialInvestment | 단기 금융투자(정기예금 포함) | 기말 |
TotalShortTermReceivable | 단기 매출채권 | 기말 |
TotalInventory | 재고자산 | 기말 |
FixedAsset | 유형자산 | 기말 |
TotalDebt | 부채(무이자 부채를 포함한 총부채) | 기말 |
TotalShortTermDebt | 유동부채 | 기말 |
TotalLongTermDebt | 비유동부채 | 기말 |
ShortTermInterestBearingDebt | 단기 차입금(이자 발생) | 기말 |
LongTermInterestBearingDebt | 장기 차입금(이자 발생) | 기말 |
StockHolderEquity | 자기자본 | 기말 |
RetainedProfit | 미처분 이익잉여금 | 기말 |
WorkingCapital | 운전자본 = 유동자산 − 유동부채 | 기말 |
현금흐름
| 키 | 의미 | 수치 |
|---|---|---|
CashflowFromOperatingActivity | 영업활동 순현금흐름 | 분기 |
CashflowFromInvestingActivity | 투자활동 순현금흐름 | 분기 |
CashflowFromFinancingActivity | 재무활동 순현금흐름 | 분기 |
CAPEX | 4개 분기 유형자산 취득 지출(양수) | 4개 분기 |
FCF | 잉여현금흐름 | 연간 |
주당 지표, 기간 종료일 기준 밸류에이션
| 키 | 의미 | 수치 |
|---|---|---|
ShareAtPeriodEnd | 기말 유통 주식 수(주) | 기말 |
MarketCapAtPeriodEnd | 기간 종료일 시가총액 | 기말 |
BasicEPS | 4개 분기 기본 EPS(동 / 주) | 4개 분기 |
DilutedEPS | 4개 분기 희석 EPS | 4개 분기 |
BookValuePerShare | 주당 장부가치 | 기말 |
SalePerShare | 4개 분기 주당 매출 | 4개 분기 |
CashDividend | 최근 1년 주당 현금 배당 | 4개 분기 |
DividendYield | 기말 가격 기준 현금 배당수익률(비율) | 4개 분기 |
PayoutRatio | 배당성향(비율) | 4개 분기 |
PE | 기말 가격 기준 P/E(세션별 가격: d.pe) | 4개 분기 |
PB | 기말 가격 기준 P/B(세션별 가격: d.pb) | 기말 |
PS | 기말 가격 기준 P/S | 4개 분기 |
EVOverEBITDA | 기말 가격 기준 EV/EBITDA | 4개 분기 |
수익성, 이익률(4개 분기)
| 키 | 의미 | 수치 |
|---|---|---|
ROE | ROE(비율) | 4개 분기 |
ROA | ROA | 4개 분기 |
ROIC | ROIC | 4개 분기 |
ROCE | ROCE | 4개 분기 |
GrossMargin | 매출총이익률 | 4개 분기 |
EBITMargin | EBIT 이익률 | 4개 분기 |
OperatingMargin | 영업이익률 | 4개 분기 |
PreTaxMargin | 세전이익률 | 4개 분기 |
TotalAssetTurnover | 총자산회전율(회) | 4개 분기 |
InventoryTurnover | 재고자산회전율 | 4개 분기 |
ReceivableTurnover | 매출채권회전율 | 4개 분기 |
InterestCoverageRatio | 이자보상배율 = EBIT ÷ 이자비용 | 4개 분기 |
유동성, 레버리지(기말)
| 키 | 의미 | 수치 |
|---|---|---|
CurrentRatio | 유동비율(배) | 기말 |
QuickRatio | 당좌비율 | 기말 |
TotalDebtOverEquity | 부채 ÷ 자기자본 | 기말 |
TotalDebtOverAsset | 부채 ÷ 총자산(비율) | 기말 |
전년 동기 대비 성장률, 점 수
| 키 | 의미 | 수치 |
|---|---|---|
SaleGrowth | 분기 순매출의 전년 동기 대비 증가율 | 전년 동기 대비 |
ProfitGrowth | 분기 지배주주 세후 순이익의 전년 동기 대비 증가율 | 전년 동기 대비 |
BasicEPSGrowth | 4개 분기 EPS의 전년 동기 대비 증가율 | 전년 동기 대비 |
PiotroskiFScore | Piotroski F-Score 0–9 | 연간 |
ManufacturingZScore | 제조업 기업의 Altman Z-Score | 기말 |
NonManufacturingZScore | 비제조업 기업의 Altman Z-Score | 기말 |
TotalDebt는 무이자 부채까지 포함한 총부채입니다. 차입금 =ShortTermInterestBearingDebt+LongTermInterestBearingDebt입니다.Cash에는CashEquivalent가 포함되지 않습니다.- 은행, 증권사, 보험사는 별도의 재무제표 양식을 씁니다. 많은 항목이 비어 있거나(매출원가, 재고, EBIT, 차입금…) 의미가 다릅니다. 비어 있을 수 있는 항목을 더할 때는 각각
fillna(0)을 쓰고, 같은 업종 그룹 안에서만 비교하세요. - 연속 4개 분기 중 한 분기라도 빠지면(반기, 연간만 공시하는 기업)
ttm은NaN이 됩니다.period: "year"를 쓰세요. period: "year"는 감사받은 수치로, 그 수치가 나온 날부터 사용할 수 있습니다(보통 3월 말, 늦으면 7월). 그 전까지는 전년도 값이 쓰입니다.- 서버에 아직 없는 항목이면 결과에 Máy chủ dữ liệu chưa có chỉ tiêu BCTC … — để trống.(데이터 서버에 재무제표 항목 …가 아직 없음 — 비워 둠) 메모가 붙습니다.
배당, 권리 이벤트, 상한가 / 하한가
| 필드 | 의미 | 단위 |
|---|---|---|
d.cashDividend | GDKHQ 세션의 현금 배당(그날이 휴장이면 다음 세션); 다른 세션은 0 | 동 / 주 |
d.dividendYield | 12개월 현금 배당수익률 = 250세션 cashDividend 합계 ÷ (원래 가격 × 1,000); 이전 250세션의 데이터가 필요 | 비율 |
d.exRights | 가격 조정이 있는 권리락 세션에 1(배당, 분할, 유상증자 권리) | — |
d.ceiling, d.floor | 세션의 상한가, 하한가(가격과 같은 방식으로 수정) | 천 동 |
d.atCeiling, d.atFloor | 상한가 / 하한가로 마감하면 1 | — |
커뮤니티와 뉴스
| 필드 | 의미 |
|---|---|
d.newsCount | 당일 종목에 연결된 뉴스 수 |
d.postCount | 당일 종목을 언급한 FireAnt 커뮤니티 게시물 수 |
d.postAuthors | 당일 종목을 언급한 서로 다른 작성자 수 |
d.postLikes, d.postReplies | 해당 게시물의 좋아요, 답글 합계 |
d.bullishPosts, d.bearishPosts | 작성자가 긍정 / 부정 감정을 선택한 게시물 수 |
2021년 1월 28일부터 있습니다. 게시물이 없는 날은 0, 2021년 이전은 NaN입니다. 오늘 세션의 수치는 약 19:10의 갱신 이후에 나옵니다(갱신 일정). 그 전에는 오늘 세션의 칸이 NaN이므로, 이동 창을 계산하기 전에 fillna(0)을 쓰세요. 화제성은 그 종목 자신과 비교할 때 의미가 있습니다. 예를 들어 d.postCount.fillna(0).rolling(5).mean().div(d.postCount.fillna(0).rolling(60).mean())은 5세션 게시물 수가 평소의 몇 배인지를 나타냅니다.
내부자 거래와 대주주
| 필드 | 의미 | 단위 |
|---|---|---|
d.insiderBuy, d.insiderSell | 내부자, 특수관계인, 대주주 중 개인이 매수 / 매도한 수량. 실행일 후 세 번째 세션에 기록; 다른 세션은 0 | 주 |
d.insiderBuyPlan, d.insiderSellPlan | 개인이 매수 / 매도를 신고한 수량. 거래 가능한 첫 세션에 기록 | 주 |
d.holderBuy, d.holderSell | 기관(대주주, 모회사, 펀드)이 매수 / 매도한 수량, insiderBuy와 같은 방식 | 주 |
d.insiderNet | insiderBuy − insiderSell | 주 |
d.insiderNetValue | insiderNet × 세션의 원래 가격 | 동 |
d.stateOwnership | 국가 지분율(0–1) — 현재 스냅샷 | 비율 |
d.foreignMajorOwnership | 외국인 대주주 지분율 합계 — 현재 스냅샷 | 비율 |
d.founderOwnership | 창업 주주 지분율 합계 — 현재 스냅샷 | 비율 |
d.majorOwnership | 공시된 주주들의 지분율 합계; 1 − majorOwnership ≈ 유동주식 비율 — 현재 스냅샷 | 비율 |
d.majorHolders | 공시된 주주 수 — 현재 스냅샷 | 주주 |
내부자 거래 데이터 다섯 필드는 거래가 없는 세션에 0입니다. 스냅샷 다섯 필드는 주주 명부가 갱신된 날부터만 있고 그 전에는 NaN입니다. 오늘의 스크리너에 쓰고 백테스트에는 쓰지 마세요(내부자 거래와 대주주 참고).
// GT cá nhân nội bộ mua ròng 60 phiên, tỷ đồng
const insider60 = d.insiderNetValue.fillna(0).rolling(60).sum().div(1e9);
d.macro: 108개 거시경제 시계열
d.macro("mã")는 한 행짜리 Panel을 반환합니다(d.bench처럼 여러 종목 Panel과 계산할 때 자동 확장). 값은 각 세션 시점에 알려진 수치입니다. 즉 세션 전에 발표된 가장 최근 기간의 값이며, 수정치는 수정본이 나온 날부터 쓰입니다(규칙).
// Chỉ nắm cổ phiếu khi lãi suất liên ngân hàng qua đêm dưới 4% và lạm phát dưới 4,5%
signals: (d) => {
const ok = d.macro("ib_on").lt(4).and(d.macro("cpi_yoy").lt(4.5));
const up = d.close.gt(ta.sma(d.close, 50));
return { entry: up.and(ok), exit: up.not().or(ok.not()) };
},
- 거시경제 조건을
entry에만 두면 매수 시점만 막습니다. 거시경제가 나빠질 때 매도하려면 위처럼 반대 조건을exit에 넣으세요. 순환 전략에서는 조건을filter에 둡니다. 리밸런싱 시점에 조건을 만족하는 종목이 없으면 포트폴리오는 현금이 됩니다. - %로 계산된 시계열은 퍼센트 숫자입니다(
gdp_yoy7.1은 7.1%라는 뜻)."percent"형식은 100을 곱하므로, 차트에 그리거나 수익률과 비교하기 전에 100으로 나누세요 —d.macro("gdp_yoy").div(100). - 분석에서는
fields에macro:mã형식으로 선언합니다:data.bars("VNINDEX", { fields: ["macro:cpi_yoy", "macro:ib_on"] }). - 분석 기간에 공백이 있거나 시계열이 늦게 시작하거나 수치가 끊기면 결과에 Chuỗi vĩ mô "…"…(거시경제 시계열 "…"…) 메모가 붙습니다. 빠진 구간에서는 이전 값이 유지됩니다. 목록에 없는 코드는 Không có chuỗi vĩ mô "…"(거시경제 시계열 "…"가 없음) 메모와 함께 시계열이 비어 있습니다.
사용 가능 시점 열은 첫 수치가 발표된 시점, 즉 백테스트에 반영되는 시점입니다(월·분기·연 시계열: 발표 월, 일 시계열: 발표일). 완전 — 마지막 긴 공백 이후 수치가 다시 나오기 시작한 시점입니다(2026년 10월 19일 측정). 이 시점은 수치의 기간보다 늦을 수 있습니다. 예를 들어 신용, M2의 2025년 1월 수치는 2025년 3월 24일에 발표되었으므로 2025.03으로 표시됩니다. 표의 날짜는 연.월 또는 연.월.일 형식입니다.
성장
| 코드 | 시계열 | 단위 | 주기 | 사용 가능 시점 |
|---|---|---|---|---|
gdp_yoy | 분기 GDP 성장률(전년 동기 대비) | % | 분기 | 2018.03 |
gdp_ytd_yoy | 연초 대비 누적 GDP 성장률(전년 동기 대비) | % | 분기 | 2000.12 · 완전 2010.12 |
gdp_agri_yoy | 농림수산업 GDP(전년 동기 대비) | % | 분기 | 2018.03 |
gdp_industry_yoy | 공업·건설업 GDP(전년 동기 대비) | % | 분기 | 2018.03 |
gdp_mfg_yoy | 제조업 GDP(전년 동기 대비) | % | 분기 | 2018.03 |
gdp_services_yoy | 서비스업 GDP(전년 동기 대비) | % | 분기 | 2018.03 |
gdp_nominal_q | 경상가격 기준 분기 GDP | 조 동 | 분기 | 2018.03 |
gdp_real_q | 불변가격 기준 분기 GDP | 조 동 | 분기 | 2018.03 |
gdp_real_ytd | 불변가격 기준 누적 GDP | 조 동 | 분기 | 2018.03 |
gdp_agri_q | 농림수산업 GDP(불변가격) | 조 동 | 분기 | 2018.03 |
gdp_agri_ytd | 농림수산업 GDP 누적 | 조 동 | 분기 | 2018.03 |
gdp_construction_q | 건설업 GDP(불변가격) | 조 동 | 분기 | 2018.03 |
gdp_construction_ytd | 건설업 GDP 누적 | 조 동 | 분기 | 2018.03 |
gdp_mfg_q | 제조업 GDP(불변가격) | 조 동 | 분기 | 2018.03 |
gdp_mfg_ytd | 제조업 GDP 누적 | 조 동 | 분기 | 2018.03 |
gdp_mining_q | 광업 GDP(불변가격) | 조 동 | 분기 | 2018.03 |
gdp_mining_ytd | 광업 GDP 누적 | 조 동 | 분기 | 2018.03 |
gdp_public_admin_q | 공공행정·국방 GDP(불변가격) | 조 동 | 분기 | 2018.03 |
gdp_public_admin_ytd | 공공행정·국방 GDP 누적 | 조 동 | 분기 | 2018.03 |
gdp_services_q | 서비스업 GDP(불변가격) | 조 동 | 분기 | 2018.03 |
gdp_services_ytd | 서비스업 GDP 누적 | 조 동 | 분기 | 2018.03 |
gdp_transport_q | 운수·창고업 GDP(불변가격) | 조 동 | 분기 | 2018.03 |
gdp_transport_ytd | 운수·창고업 GDP 누적 | 조 동 | 분기 | 2018.03 |
gdp_utility_q | 전기·가스 생산·공급업 GDP(불변가격) | 조 동 | 분기 | 2018.03 |
gdp_utility_ytd | 전기·가스 생산·공급업 GDP 누적 | 조 동 | 분기 | 2018.03 |
invest_q | 분기 사회 전체 투자 집행액 | 조 동 | 분기 | 2014.03 · 완전 2018.03 |
invest_yoy | 분기 사회 전체 투자(전년 동기 대비) | % | 분기 | 2014.03 · 완전 2018.03 |
public_invest | 월간 국가 예산 투자 집행액 | 조 동 | 월 | 2000.01 |
public_invest_ytd_yoy | 국가 예산 투자 누적(전년 동기 대비) | % | 월 | 2000.03 · 완전 2011.02 |
weo_gdp_growth | 실질 GDP 성장률(IMF WEO) | % | 연 | 1990.04 |
weo_gdp_usd | 명목 GDP(IMF WEO) | 십억 달러 | 연 | 2003.09 |
weo_gdp_pc | 1인당 GDP(IMF WEO) | 달러 | 연 | 2003.09 |
weo_gdp_pc_ppp | 구매력 기준 1인당 GDP(IMF WEO) | USD PPP | 연 | 2003.09 |
weo_gov_debt | 정부 부채 / GDP(IMF WEO) | % | 연 | 2010.10 |
wb_gfcf | 총고정자본형성 | 조 동 | 연 | 1996.07 |
생산과 기업
| 코드 | 시계열 | 단위 | 주기 | 사용 가능 시점 |
|---|---|---|---|---|
wb_inventory | 재고 증감 | 조 동 | 연 | 1996.07 |
iip_yoy | 산업생산지수(전년 동기 대비) | % | 월 | 2011.06 |
iip_mfg_yoy | 제조업 IIP(전년 동기 대비) | % | 월 | 2012.07 |
iip_mining_yoy | 광업 IIP(전년 동기 대비) | % | 월 | 2012.07 |
iip_power_yoy | 전력 생산·공급 IIP(전년 동기 대비) | % | 월 | 2012.07 |
electricity | 발전량 | 십억 kWh | 월 | 2007.04 · 완전 2007.07 |
crude_oil | 원유 생산량 | 천 톤 | 월 | 2007.04 · 완전 2007.07 |
steel | 압연 강재 | 천 톤 | 월 | 2000.01 · 완전 2013.01 |
cement | 시멘트 | 백만 톤 | 월 | 2000.01 |
firms_new_ytd | 신설 기업(누적) | 개사 | 월 | 2017.11 |
firms_return_ytd | 영업 재개 기업(누적) | 개사 | 월 | 2016.09 |
firms_suspended_ytd | 휴업 기업(누적) | 개사 | 월 | 2016.09 |
firms_dissolved_ytd | 해산 기업(누적) | 개사 | 월 | 2018.09 |
물가와 가격
| 코드 | 시계열 | 단위 | 주기 | 사용 가능 시점 |
|---|---|---|---|---|
weo_inflation | 연평균 인플레이션(IMF WEO) | % | 연 | 1990.04 |
cpi_yoy | CPI(전년 동월 대비) | % | 월 | 2000.01 |
cpi_mom | CPI(전월 대비) | % | 월 | 2000.01 |
cpi_ytd_avg | 연초 이후 평균 CPI(전년 동기 대비) | % | 월 | 2007.09 |
cpi_vs_dec | 전년 12월 대비 CPI | % | 월 | 2000.01 |
cpi_core_yoy | 근원 인플레이션(전년 동월 대비) | % | 월 | 2015.01 |
cpi_food_yoy | 식료품·외식 서비스 CPI(전년 동월 대비) | % | 월 | 2006.05 |
cpi_transport_yoy | 교통 CPI(전년 동월 대비) | % | 월 | 2009.11 |
gold_index_yoy | 금 가격지수(전년 동월 대비) | % | 월 | 2000.01 |
usd_index_yoy | 미국 달러 가격지수(전년 동월 대비) | % | 월 | 2000.01 |
cpi_index | CPI(지수, 기준 연도 간 연결) | 포인트 | 월 | 2000.01 |
ppi_yoy | 공업 생산자물가(전년 동기 대비) | % | 분기 | 2011.03 · 완전 2012.12 |
export_price_yoy | 상품 수출 가격(전년 동기 대비) | % | 분기 | 2018.03 |
import_price_yoy | 상품 수입 가격(전년 동기 대비) | % | 분기 | 2018.03 |
petrol_ron95 | RON 95 휘발유 가격(1지역) | 동/리터 | 일 | 2008.10.09 |
diesel | 0.05S 경유 가격(1지역) | 동/리터 | 일 | 2008.12.03 |
통화와 금리
| 코드 | 시계열 | 단위 | 주기 | 사용 가능 시점 |
|---|---|---|---|---|
ib_on | 은행 간 익일물 금리 | % | 일 | 2014.01.06 |
ib_1w | 은행 간 1주 금리 | % | 일 | 2014.01.06 |
ib_2w | 은행 간 2주 금리 | % | 일 | 2014.01.06 |
ib_1m | 은행 간 1개월 금리 | % | 일 | 2014.01.06 |
ib_3m | 은행 간 3개월 금리 | % | 일 | 2014.01.06 |
ib_6m | 은행 간 6개월 금리 | % | 일 | 2014.01.06 · 완전 2014.06.30 |
ib_9m | 은행 간 9개월 금리 | % | 일 | 2014.01.06 |
ib_vol_on | 은행 간 익일물 거래액 | 조 동 | 일 | 2014.01.06 |
ib_vol_1w | 은행 간 1주 거래액 | 조 동 | 일 | 2014.01.06 |
ib_vol_2w | 은행 간 2주 거래액 | 조 동 | 일 | 2014.01.06 |
ib_vol_1m | 은행 간 1개월 거래액 | 조 동 | 일 | 2014.01.06 |
ib_vol_3m | 은행 간 3개월 거래액 | 조 동 | 일 | 2014.01.06 |
ib_vol_6m | 은행 간 6개월 거래액 | 조 동 | 일 | 2014.01.06 · 완전 2014.06.30 |
ib_vol_9m | 은행 간 9개월 거래액 | 조 동 | 일 | 2014.01.06 |
omo_injection | 공개시장 자금 공급(당일 낙찰) | 조 동 | 일 | 2025.04.22 · 완전 2025.11.05 |
omo_outstanding | 공개시장 일말 잔액 | 조 동 | 일 | 2026.02.18 |
credit_ytd | 연초 대비 신용 증가율 | % | 월 | 2015.02 · 완전 2025.03 |
credit | 경제 부문 신용 잔액 | 조 동 | 월 | 2015.02 · 완전 2025.03 |
m2_ytd | 연초 대비 총통화 증가율 | % | 월 | 2025.03 · 완전 2026.05 |
m2 | 총통화(M2) | 조 동 | 월 | 2025.03 |
usd_vcb_sell | USD/VND 매도 환율(Vietcombank) | 동 | 일 | 2020.02.01 |
usd_vcb_buy | USD/VND 송금 매입 환율(Vietcombank) | 동 | 일 | 2020.02.01 |
usd_imf | 월말 USD/VND(IMF) | 동 | 월 | 1995.02 |
fx_reserves | 금 제외 외환보유액 | 십억 달러 | 월 | 1995.04 · 완전 2001.03 |
wb_deposit_rate | 연평균 예금 금리 | % | 연 | 1994.07 · 완전 1998.07 |
wb_lending_rate | 연평균 대출 금리 | % | 연 | 1994.07 · 완전 1997.07 |
무역과 외국 자본
| 코드 | 시계열 | 단위 | 주기 | 사용 가능 시점 |
|---|---|---|---|---|
terms_of_trade_yoy | 상품 교역조건(전년 동기 대비) | % | 분기 | 2015.06 |
export | 월간 상품 수출 | 십억 달러 | 월 | 2009.03 · 완전 2014.05 |
import | 월간 상품 수입 | 십억 달러 | 월 | 2009.03 |
trade_balance | 월간 상품 무역수지 | 십억 달러 | 월 | 2009.03 · 완전 2014.05 |
fdi_new_ytd | 신규 등록 FDI(누적) | 십억 달러 | 월 | 2001.03 · 완전 2019.05 |
fdi_adjusted_ytd | 증액 등록 FDI(누적) | 십억 달러 | 월 | 2019.05 |
tourists | 베트남 방문 외국인 관광 객 | 천 명 | 월 | 2001.03 |
current_account | 분기 경상수지 | 십억 달러 | 분기 | 2025.06 |
weo_ca_gdp | 경상수지 / GDP(IMF WEO) | % | 연 | 1990.04 |
wb_external_debt | 대외 부채 | 십억 달러 | 연 | 1982.07 |
소비
| 코드 | 시계열 | 단위 | 주기 | 사용 가능 시점 |
|---|---|---|---|---|
wb_consumption | 가계 최종 소비 | 조 동 | 연 | 1996.07 |
retail_yoy | 상품·서비스 소매 판매 총액(전년 동월 대비) | % | 월 | 2004.01 · 완전 2018.09 |
retail | 월간 상품·서비스 소매 판매 총액 | 조 동 | 월 | 2004.01 · 완전 2013.01 |
노동과 인구
| 코드 | 시계열 | 단위 | 주기 | 사용 가능 시점 |
|---|---|---|---|---|
weo_population | 인구(IMF WEO) | 백만 명 | 연 | 2006.09 |
unemployment | 생산가능인구 실업률 | % | 분기 | 2013.04 |
youth_unemployment | 15–24세 청년 실업률 | % | 분기 | 2013.04 |
underemployment | 생산가능인구 불완전 고용률 | % | 분기 | 2013.04 |
labour_force | 15세 이상 경제활동인구 | 천 명 | 분기 | 2013.04 |
일부 시계열은 매년 같은 달이 빠집니다(출처가 해당 기간을 따로 발표하지 않음). 빠진 달에는 d.macro가 이전 기간 값을 유지합니다. cpi_mom은 1월이 없고(1월 보고서에는 12월 대비 수치, 즉 cpi_vs_dec만 있음), cpi_vs_dec는 12월이 없으며, cpi_ytd_avg는 1월, 3월, 12월이 없고, public_invest_ytd_yoy는 12월과 1월이 없으며, fdi_new_ytd, fdi_adjusted_ytd, firms_*_ytd는 12월이 없습니다. 불변가격 기준 GDP는 2026년 1분기부터 기준 연도가 바뀌었으므로 이 시점을 넘어 GDP 수준을 비교하지 마세요.
일 단위 시계열 중 두 그룹은 본래 수치가 드문드문합니다. petrol_ron95, diesel은 가격 조정일에만 수치가 있고(연 약 25회), 두 조정 사이에는 d.macro가 이전 가격을 유지합니다 — 당시의 실제 소매가와 같습니다. ib_9m, ib_vol_9m은 9개월물 거래가 있는 세션에만 수치가 있어(전체 세션의 약 5분의 1, 2026년에는 한 달 넘게 비는 구간도 있음) 더 짧은 만기를 쓰는 것이 좋습니다.
d.bench, d.meta와 기타 정보
| 구성 요소 | 의미 |
|---|---|
d.bench.open … d.bench.volume | 비교 지수(기본 VNINDEX; 전략에서는 benchmark로 변경), 같은 세션 일정의 한 행짜리 Panel. 전략과 분석에 있으며 스크리너에는 없음 |
d.symbols | 행 순서대로의 종목 목록 |
d.days | 각 세션의 날짜: 1970년 1월 1일부터의 일수(dates.*와 함께 사용) |
d.meta[i] | i번째 종목 정보 — 아래 표 |
d.partialLast | 마지막 세션이 거래 중인 세션의 임시 봉이면 true |
d.asOf | 데이터가 확정된 마지막 세션 |
d.field("tên") | 문자열 이름으로 필드 가져오기, 예: d.field("foreignNet") |
d.meta[i]의 속성 | 의미 |
|---|---|
symbol, name | 종목 코드, 기업명 |
exchange | 거래소: "HSX"(HOSE), "HNX", "UPCOM"; 이전 거래소를 알 수 없는 상장폐지 종목은 "" |
type | 종목 유형: "stock"(주식, ETF), "index", "futures", "warrant" |
icb, industry, industryShort, sector | ICB 업종 코드, 업종명, 짧은 업종명("Chứng khoán"(증권), "Bất động sản"(부동산)…), 상위 업종 그룹 |
shares | 유통 주식 수 |
adv20 | 현재 20세션 평균 GTGD(동) |
price, marketCap | 현재 가격(천 동), 시가총액(동) |
listFrom, listTo, delistedAt | 시점별 바스켓에만 있음: 종목이 바스켓에 속한 기간, 상장폐지 종목의 마지막 거래 세션 |
Panel 연산
연산은 새 Panel을 반환하며, 인수는 숫자나 다른 Panel입니다. 전체 시그니처와 NaN 처리 방식: 함수 참조.
| 그룹 | 함수 |
|---|---|
| 산술 | add sub mul div(0으로 나누면 NaN) pow min max neg abs log exp sqrt sign round clip(lo, hi) |
비교(1 / 0 / NaN) | gt gte lt lte eq neq between(a, b) |
| 논리 | and or not · where(điềuKiện, giáTrịKhác) · fillna(v) · ffill(giớiHạn?) · isNaN notNaN |
| 시간 축(종목별) | shift(n ≥ 0) · diff(n) · pct(n) · cumsum cumprod cummax cummin · ewm(span) · highest(n) lowest(n) |
| 이동 창 | rolling(n).mean() .sum() .std() .var() .min() .max() .count() .rank() .zscore() |
| 이벤트 | crossAbove(x) crossBelow(x) · barsSince() · hold(n) |
| 횡단면(세션별 종목 간) | rank() zscore() demean() bucket(q) topN(n) bottomN(n) · sumAcross() meanAcross() countAcross() |
| 값 가져오기 | last() · at(ngày) · values("FPT") · row(i) · get(i, t) · pick([mã]) · range(từ, đến) |
| 주기 변환 | resample("week" | "month" | "quarter" | "year") 후 .last() .first() .sum() .mean() .max() .min() |
자주 쓰는 공식:
| 계산하려는 것 | 작성법 |
|---|---|
| 20세션 평균 대비 거래량 | d.volume.div(d.volume.rolling(20).mean()) |
| 52주 고점까지의 거리 | d.close.div(d.high.highest(250)).sub(1) |
| 최근 1개월을 뺀 6개월 모멘텀 | d.close.shift(21).pct(105) |
| 바스켓 내 모멘텀 순위(0 → 1) | d.close.pct(126).rank() |
| 60세션 변동성, 바스켓 하위 60% 그룹 | d.ret.rolling(60).std().rank().lte(0.6) |
| 가격이 직전 20세션 고점 돌파 | d.close.gt(d.high.highest(20).shift(1)) |
| 최근 10세션 안에 MA50이 MA200 상향 돌파 | ta.sma(d.close, 50).crossAbove(ta.sma(d.close, 200)).hold(9) |
| 새 재무제표 이후 경과 세션 수 | d.reportNew.eq(1).barsSince() |
| 종목 자신의 5년 대비 P/E(0 = 가장 쌈) | d.pe.rolling(1250).rank() |
| 순현금(현금 + 단기 투자 − 차입금) | d.fin("Cash").fillna(0).add(d.fin("CashEquivalent").fillna(0)).add(d.fin("ShortTermFinancialInvestment").fillna(0)).sub(d.fin("ShortTermInterestBearingDebt").fillna(0)).sub(d.fin("LongTermInterestBearingDebt").fillna(0)) |
| VNINDEX가 MA200 위(모든 종목에 적용) | d.close.gt(0).and(d.bench.close.gt(ta.sma(d.bench.close, 200))) |
| 바스켓 중 MA50 위 종목 비율 | d.close.gt(ta.sma(d.close, 50)).meanAcross() |
| 월별 수익률 | d.close.resample("month").last().pct(1) |
rolling(n)은 엄격한 창입니다. NaN이 아닌 연속된 값이 n개 있어야 결과가 나옵니다(신규 상장 종목은 처음 200세션 동안 MA200이 없음). 이동 창의 std()는 모집단 표준편차(n으로 나눔, Bollinger와 같음)이며, ewm(span)은 처음 span개 값의 평균으로 시작합니다.