import { AxiosInstance } from 'axios'; /** * Sàn giao dịch chứng khoán Việt Nam */ declare enum Exchange { HOSE = "HOSE",// Sở Giao dịch Chứng khoán TP.HCM HNX = "HNX",// Sở Giao dịch Chứng khoán Hà Nội UPCOM = "UPCOM" } /** * Nguồn dữ liệu được hỗ trợ */ declare enum DataSource { TCBS = "TCBS",// Techcom Securities (api.tcbs.com.vn) DNSE = "DNSE",// DNSE Securities (services.entrade.com.vn) SSI = "SSI",// SSI Securities VCI = "VCI",// VCI/VCSC Securities VNDIRECT = "VNDIRECT" } /** * Khung thời gian (timeframe) cho dữ liệu OHLCV */ declare enum Interval { M1 = "1",// 1 phút (chỉ DNSE, tối đa 90 ngày gần nhất) M5 = "5",// 5 phút M15 = "15",// 15 phút M30 = "30",// 30 phút M45 = "45",// 45 phút H1 = "60",// 1 giờ H4 = "240",// 4 giờ D1 = "D",// 1 ngày (TCBS: không giới hạn; DNSE: tối đa 10 năm) W1 = "W",// 1 tuần MN = "M" } /** * Kỳ báo cáo tài chính */ declare enum ReportPeriod { YEAR = "year",// Báo cáo năm QUARTER = "quarter" } /** * Loại nhà đầu tư nước ngoài */ declare enum TraderType { FOREIGN_BUY = "FOREIGN_BUY",// Mua ròng nước ngoài FOREIGN_SELL = "FOREIGN_SELL",// Bán ròng nước ngoài PROPRIETARY = "PROPRIETARY" } /** * Cấu hình khởi tạo VnStockClient */ interface VnStockConfig { /** Timeout (ms) cho mỗi request. Mặc định: 30000 */ timeout?: number; /** Số lần thử lại khi request thất bại. Mặc định: 3 */ retries?: number; /** Delay (ms) giữa các lần thử lại. Mặc định: 1000 */ retryDelay?: number; /** User-Agent tuỳ chỉnh */ userAgent?: string; /** Bật/tắt log debug. Mặc định: false */ debug?: boolean; /** Headers tuỳ chỉnh thêm vào mỗi request */ extraHeaders?: Record; } /** * Một nến OHLCV */ interface OHLCVCandle { /** Thời gian mở cửa nến (Unix timestamp milliseconds) */ time: number; /** Ngày giao dịch (YYYY-MM-DD) */ date: string; /** Giá mở cửa (VND) */ open: number; /** Giá cao nhất (VND) */ high: number; /** Giá thấp nhất (VND) */ low: number; /** Giá đóng cửa (VND) */ close: number; /** Khối lượng giao dịch (đơn vị: cổ phiếu) */ volume: number; } /** * Tham số lấy dữ liệu OHLCV lịch sử */ interface HistoryParams { /** Mã chứng khoán (VD: "VCB", "HPG", "VNM") */ symbol: string; /** Ngày bắt đầu (YYYY-MM-DD) */ start: string; /** Ngày kết thúc (YYYY-MM-DD) */ end: string; /** Khung thời gian. Mặc định: Interval.D1 */ interval?: Interval; /** Nguồn dữ liệu. Mặc định: DataSource.TCBS */ source?: DataSource; } /** * Dữ liệu khớp lệnh trong phiên (intraday) - từng lệnh */ interface IntradayTick { /** Thời gian khớp lệnh (HH:mm:ss) */ time: string; /** Giá khớp (VND) */ price: number; /** Khối lượng khớp (cổ phiếu) */ volume: number; /** Giá trị khớp (VND) */ value: number; /** * Loại lệnh chủ động: * "BU" = Active Buy (Chủ động mua - bên mua chủ động đẩy giá) * "SD" = Active Sell (Chủ động bán - bên bán chủ động kéo giá) * "" = Không xác định */ orderType: "BU" | "SD" | ""; /** Biến động giá so với lệnh trước (VND) */ priceChange: number; /** Biến động giá % */ priceChangePercent: number; } /** * Thống kê khối lượng chủ động mua/bán trong phiên */ interface ActiveBuySellSummary { /** Mã chứng khoán */ symbol: string; /** Ngày giao dịch (YYYY-MM-DD) */ date: string; /** Tổng khối lượng chủ động mua (BU) */ totalBuyVolume: number; /** Tổng giá trị chủ động mua (VND) */ totalBuyValue: number; /** Số lệnh chủ động mua */ buyOrderCount: number; /** Tổng khối lượng chủ động bán (SD) */ totalSellVolume: number; /** Tổng giá trị chủ động bán (VND) */ totalSellValue: number; /** Số lệnh chủ động bán */ sellOrderCount: number; /** * Khối lượng ròng (mua - bán). * Dương = áp lực mua, Âm = áp lực bán */ netVolume: number; /** Giá trị ròng (VND) */ netValue: number; } /** * Thống kê phân loại nhà đầu tư theo khối lượng lệnh * TCBS phân loại: Cá mập (Shark/CM), Sói xám (Grey Wolf/SG), Cừu (Sheep/CN) */ interface InvestorTypeStats { /** Ngày giao dịch */ date: string; /** Cá mập (CM): lệnh > 1 tỷ VND */ shark: { buyVolume: number; sellVolume: number; buyValue: number; sellValue: number; }; /** Sói xám (SG): lệnh 200 triệu - 1 tỷ VND */ greyWolf: { buyVolume: number; sellVolume: number; buyValue: number; sellValue: number; }; /** Cừu (CN): lệnh < 200 triệu VND */ sheep: { buyVolume: number; sellVolume: number; buyValue: number; sellValue: number; }; } /** * Dữ liệu bảng giá (price board) cho một mã cổ phiếu */ interface PriceBoardItem { /** Mã chứng khoán */ symbol: string; /** Giá tham chiếu (VND) */ referencePrice: number; /** Giá trần (VND) */ ceilingPrice: number; /** Giá sàn (VND) */ floorPrice: number; /** Giá khớp lệnh gần nhất (VND) */ matchPrice: number; /** Biến động giá so với tham chiếu (VND) */ priceChange: number; /** Biến động giá % */ priceChangePercent: number; /** Tổng khối lượng khớp */ totalVolume: number; /** Tổng giá trị khớp (VND) */ totalValue: number; /** Khối lượng mua tốt nhất (bid) */ bidVolume1: number; /** Giá mua tốt nhất (bid 1) */ bidPrice1: number; bidVolume2: number; bidPrice2: number; bidVolume3: number; bidPrice3: number; /** Khối lượng bán tốt nhất (ask 1) */ askVolume1: number; /** Giá bán tốt nhất (ask 1) */ askPrice1: number; askVolume2: number; askPrice2: number; askVolume3: number; askPrice3: number; /** Giá cao nhất trong phiên */ highPrice: number; /** Giá thấp nhất trong phiên */ lowPrice: number; /** Giá trung bình trong phiên (avg = totalValue / totalVolume) */ avgPrice: number; /** Khối lượng khớp nước ngoài mua */ foreignBuyVolume: number; /** Khối lượng khớp nước ngoài bán */ foreignSellVolume: number; /** Room nước ngoài còn lại */ foreignRoom: number; /** Chỉ số P/E */ pe: number; /** Chỉ số P/B */ pb: number; /** Hiệu suất 1 tuần (%) */ performance1W: number; /** Hiệu suất 1 tháng (%) */ performance1M: number; /** Hiệu suất 3 tháng (%) */ performance3M: number; /** Hiệu suất 1 năm (%) */ performance1Y: number; } /** * Thông tin tổng quan công ty */ interface CompanyOverview { /** Mã chứng khoán */ symbol: string; /** Tên đầy đủ công ty (tiếng Việt) */ name: string; /** Tên viết tắt */ shortName: string; /** Sàn giao dịch */ exchange: Exchange | string; /** Ngành (level 1) */ industry: string; /** Ngành con (level 2) */ subIndustry: string; /** Lĩnh vực (sector - ICB standard) */ sector: string; /** Mã ngành ICB */ icbCode: string; /** Mô tả công ty */ description: string; /** Địa chỉ trụ sở */ address: string; /** Website công ty */ website: string; /** Số điện thoại */ phone: string; /** Năm thành lập */ foundedYear: number; /** Ngày niêm yết */ listedDate: string; /** Vốn điều lệ (VND) */ charteredCapital: number; /** Số cổ phiếu đang lưu hành */ sharesOutstanding: number; /** Vốn hoá thị trường (VND) */ marketCap: number; /** Mệnh giá cổ phiếu (VND). Thông thường 10.000 VND */ parValue: number; /** Số cổ đông */ shareholderCount?: number; } /** * Thông tin cổ đông lớn (major shareholders) */ interface Shareholder { /** Tên cổ đông */ name: string; /** Số lượng cổ phần nắm giữ */ shares: number; /** Tỷ lệ sở hữu (%) */ ownershipPercent: number; /** Loại cổ đông: "Individual" | "Institution" | "Foreign" */ type: string; } /** * Thông tin ban lãnh đạo / HĐQT */ interface Officer { /** Họ tên */ name: string; /** Chức vụ */ title: string; /** Số cổ phiếu nắm giữ */ shares?: number; /** Tỷ lệ sở hữu (%) */ ownershipPercent?: number; } /** * Thông tin sự kiện quan trọng (dividends, rights issues, AGM, ...) */ interface CorporateEvent { /** Mã chứng khoán */ symbol: string; /** Loại sự kiện */ eventType: string; /** Ngày giao dịch không hưởng quyền (ex-date) */ exDate: string; /** Ngày chốt danh sách cổ đông */ recordDate: string; /** Ngày thực hiện */ executionDate: string; /** Tỷ lệ/Giá trị (VD: cổ tức 500 VND/CP, phát hành 1:2) */ ratio: string; /** Mô tả chi tiết */ description: string; } /** * Thông tin giao dịch nội bộ (insider trading) */ interface InsiderTrading { /** Tên người giao dịch */ name: string; /** Chức vụ */ position: string; /** Loại giao dịch: "BUY" | "SELL" */ tradeType: "BUY" | "SELL"; /** Khối lượng đăng ký giao dịch */ registeredVolume: number; /** Khối lượng thực hiện */ executedVolume: number; /** Ngày bắt đầu giao dịch */ startDate: string; /** Ngày kết thúc giao dịch */ endDate: string; /** Giá giao dịch trung bình (VND) */ avgPrice?: number; } /** * Tham số chung cho báo cáo tài chính */ interface FinancialParams { /** Mã chứng khoán */ symbol: string; /** Kỳ báo cáo */ period?: ReportPeriod; /** Số kỳ trả về. Mặc định: 8 */ limit?: number; } /** * Bảng cân đối kế toán (Balance Sheet) * Đơn vị: Triệu VND (trừ khi có ghi chú khác) */ interface BalanceSheet { /** Mã chứng khoán */ symbol: string; /** Năm */ year: number; /** Quý (1-4, null nếu là báo cáo năm) */ quarter: number | null; /** Kỳ dạng chuỗi (VD: "Q1/2024", "2023") */ period: string; /** Tổng tài sản (Total Assets) */ totalAssets: number; /** Tài sản ngắn hạn (Current Assets) */ currentAssets: number; /** Tiền và tương đương tiền (Cash & Equivalents) */ cash: number; /** Đầu tư tài chính ngắn hạn */ shortTermInvestments: number; /** Phải thu ngắn hạn */ shortTermReceivables: number; /** Hàng tồn kho (Inventory) */ inventory: number; /** Tài sản ngắn hạn khác */ otherCurrentAssets: number; /** Tài sản dài hạn (Non-current Assets) */ nonCurrentAssets: number; /** Tài sản cố định (Fixed Assets) */ fixedAssets: number; /** Đầu tư tài chính dài hạn */ longTermInvestments: number; /** Tài sản dài hạn khác */ otherNonCurrentAssets: number; /** Tổng nợ phải trả (Total Liabilities) */ totalLiabilities: number; /** Nợ ngắn hạn (Current Liabilities) */ currentLiabilities: number; /** Vay ngắn hạn */ shortTermDebt: number; /** Phải trả người bán ngắn hạn */ shortTermPayables: number; /** Nợ dài hạn (Non-current Liabilities) */ nonCurrentLiabilities: number; /** Vay dài hạn */ longTermDebt: number; /** Tổng nợ vay (ngắn + dài hạn) */ totalDebt: number; /** Vốn chủ sở hữu (Shareholders' Equity) */ equity: number; /** Vốn điều lệ (Charter Capital) */ charterCapital: number; /** Thặng dư vốn cổ phần */ capitalSurplus: number; /** Lợi nhuận chưa phân phối */ retainedEarnings: number; /** Lợi ích cổ đông thiểu số */ minorityInterest: number; } /** * Kết quả hoạt động kinh doanh (Income Statement) * Đơn vị: Triệu VND */ interface IncomeStatement { symbol: string; year: number; quarter: number | null; period: string; /** Doanh thu thuần (Net Revenue) */ revenue: number; /** Giá vốn hàng bán (COGS) */ costOfGoodsSold: number; /** Lợi nhuận gộp (Gross Profit) */ grossProfit: number; /** Biên lợi nhuận gộp (%) */ grossMargin: number; /** Chi phí bán hàng */ sellingExpenses: number; /** Chi phí quản lý doanh nghiệp */ adminExpenses: number; /** Lợi nhuận từ hoạt động kinh doanh (EBIT) */ operatingProfit: number; /** Biên EBIT (%) */ operatingMargin: number; /** Thu nhập tài chính */ financialIncome: number; /** Chi phí tài chính (bao gồm lãi vay) */ financialExpenses: number; /** Lãi vay (Interest Expense) */ interestExpense: number; /** EBITDA */ ebitda: number; /** Thu nhập từ công ty liên kết */ associateIncome: number; /** Lợi nhuận trước thuế (EBT) */ preTaxProfit: number; /** Thuế thu nhập doanh nghiệp */ taxExpense: number; /** Thuế suất hiệu lực (%) */ effectiveTaxRate: number; /** Lợi nhuận sau thuế (Net Profit) */ netProfit: number; /** Biên lợi nhuận sau thuế (%) */ netMargin: number; /** Lợi nhuận sau thuế của cổ đông công ty mẹ */ netProfitParent: number; /** Lợi nhuận sau thuế cổ đông thiểu số */ minorityInterestProfit: number; /** Lãi cơ bản trên cổ phiếu - EPS cơ bản (VND) */ eps: number; /** EPS pha loãng (VND) */ epsDiluted: number; } /** * Lưu chuyển tiền tệ (Cash Flow Statement) * Đơn vị: Triệu VND */ interface CashFlow { symbol: string; year: number; quarter: number | null; period: string; /** Dòng tiền từ hoạt động kinh doanh (Operating Cash Flow) */ operatingCashFlow: number; /** Lợi nhuận trước thay đổi vốn lưu động */ profitBeforeWorkingCapital: number; /** Thay đổi hàng tồn kho */ changeInInventory: number; /** Thay đổi phải thu */ changeInReceivables: number; /** Thay đổi phải trả */ changeInPayables: number; /** Dòng tiền từ hoạt động đầu tư (Investing Cash Flow) */ investingCashFlow: number; /** Mua tài sản cố định (CAPEX) */ capex: number; /** Thu từ thanh lý tài sản */ proceedsFromAssetSales: number; /** Đầu tư tài chính */ financialInvestments: number; /** Dòng tiền từ hoạt động tài chính (Financing Cash Flow) */ financingCashFlow: number; /** Vay nợ thuần */ netBorrowing: number; /** Cổ tức đã trả */ dividendsPaid: number; /** Phát hành cổ phiếu */ stockIssuance: number; /** Mua lại cổ phiếu */ stockRepurchase: number; /** Thay đổi tiền thuần trong kỳ */ netChangeInCash: number; /** Tiền đầu kỳ */ openingCash: number; /** Tiền cuối kỳ */ closingCash: number; /** Free Cash Flow (Operating CF - CAPEX) */ freeCashFlow: number; } /** * Chỉ số tài chính (Financial Ratios) */ interface FinancialRatio { symbol: string; year: number; quarter: number | null; period: string; /** Price to Earnings */ pe: number; /** Price to Book */ pb: number; /** Price to Sales */ ps: number; /** Price to Cash Flow */ pcf: number; /** EV/EBITDA */ evEbitda: number; /** EV/EBIT */ evEbit: number; /** EV/Revenue */ evRevenue: number; /** Tăng trưởng doanh thu (%) */ revenueGrowth: number; /** Tăng trưởng lợi nhuận gộp (%) */ grossProfitGrowth: number; /** Tăng trưởng EBIT (%) */ ebitGrowth: number; /** Tăng trưởng lợi nhuận sau thuế (%) */ netProfitGrowth: number; /** Tăng trưởng EPS (%) */ epsGrowth: number; /** Hệ số thanh toán hiện hành (Current Ratio) */ currentRatio: number; /** Hệ số thanh toán nhanh (Quick Ratio) */ quickRatio: number; /** Hệ số thanh toán tiền mặt (Cash Ratio) */ cashRatio: number; /** Hệ số nợ/vốn chủ (D/E Ratio) */ deRatio: number; /** Hệ số nợ/tổng tài sản (Debt/Assets) */ debtToAssets: number; /** Hệ số vay/EBITDA (Net Debt/EBITDA) */ netDebtToEbitda: number; /** Interest Coverage Ratio */ interestCoverage: number; /** ROA - Return on Assets (%) */ roa: number; /** ROE - Return on Equity (%) */ roe: number; /** ROIC - Return on Invested Capital (%) */ roic: number; /** Biên lợi nhuận gộp Gross Margin (%) */ grossMargin: number; /** Biên EBIT Operating Margin (%) */ operatingMargin: number; /** Biên lợi nhuận ròng Net Margin (%) */ netMargin: number; /** Vòng quay tài sản (Asset Turnover) */ assetTurnover: number; /** Vòng quay hàng tồn kho (Inventory Turnover) */ inventoryTurnover: number; /** Số ngày tồn kho (DSI) */ daysInventory: number; /** Số ngày phải thu (DSO) */ daysSalesOutstanding: number; /** Số ngày phải trả (DPO) */ daysPayableOutstanding: number; /** Cổ tức trên mỗi cổ phiếu (VND) */ dividendPerShare: number; /** Tỷ suất cổ tức (%) */ dividendYield: number; /** Tỷ lệ chi trả cổ tức (Payout Ratio, %) */ payoutRatio: number; /** Giá trị sổ sách mỗi cổ phiếu (BVPS, VND) */ bookValuePerShare: number; } /** * Thông tin niêm yết của một mã chứng khoán */ interface StockListing { /** Mã chứng khoán */ symbol: string; /** Tên công ty */ name: string; /** Sàn niêm yết */ exchange: Exchange | string; /** Ngành */ industry: string; /** Ngành con */ subIndustry: string; /** Mã ngành ICB */ icbCode: string; /** Ngày niêm yết */ listedDate: string; /** Số cổ phiếu niêm yết */ listedShares: number; /** Loại chứng khoán: "stock" | "etf" | "bond" | "derivative" */ type: string; /** Trạng thái: "listed" | "delisted" | "suspended" */ status: string; } /** * Nhóm cổ phiếu (index group) */ interface StockGroup { /** Tên nhóm (VD: "VN30", "VN100", "VNMidCap", "VNSmallCap") */ groupName: string; /** Danh sách mã cổ phiếu trong nhóm */ symbols: string[]; } /** * Danh mục ngành (industry/sector classification) */ interface IndustrySector { /** Mã ICB level 1 */ icbCode: string; /** Tên ngành cấp 1 (Sector) */ sectorName: string; /** Tên ngành cấp 2 (Industry Group) */ industryGroupName: string; /** Danh sách công ty trong ngành */ symbols?: string[]; } /** * Dữ liệu giao dịch nước ngoài theo ngày */ interface ForeignTrading { /** Mã chứng khoán */ symbol: string; /** Ngày giao dịch (YYYY-MM-DD) */ date: string; /** Khối lượng nước ngoài mua */ foreignBuyVolume: number; /** Giá trị nước ngoài mua (VND) */ foreignBuyValue: number; /** Khối lượng nước ngoài bán */ foreignSellVolume: number; /** Giá trị nước ngoài bán (VND) */ foreignSellValue: number; /** Khối lượng ròng (mua - bán) */ foreignNetVolume: number; /** Giá trị ròng (VND) */ foreignNetValue: number; /** Room nước ngoài còn lại */ currentForeignRoom: number; /** Tổng room nước ngoài (max) */ totalForeignRoom: number; /** Tỷ lệ room đã sử dụng (%) */ foreignRoomUsedPercent: number; } /** * Dữ liệu giao dịch tự doanh (proprietary trading) theo ngày */ interface ProprietaryTrading { symbol: string; date: string; /** Khối lượng tự doanh mua */ propBuyVolume: number; /** Giá trị tự doanh mua (VND) */ propBuyValue: number; /** Khối lượng tự doanh bán */ propSellVolume: number; /** Giá trị tự doanh bán (VND) */ propSellValue: number; /** Khối lượng ròng */ propNetVolume: number; /** Giá trị ròng */ propNetValue: number; } /** * Dữ liệu chỉ số thị trường (VNIndex, HNX30, UPCOM, ...) */ interface MarketIndex { /** Tên chỉ số (VD: "VNINDEX", "HNX30", "VN30", "UPCOM") */ indexName: string; /** Ngày (YYYY-MM-DD) */ date: string; /** Giá trị mở cửa */ open: number; /** Giá trị cao nhất */ high: number; /** Giá trị thấp nhất */ low: number; /** Giá trị đóng cửa */ close: number; /** Thay đổi điểm so với phiên trước */ change: number; /** Thay đổi % */ changePercent: number; /** Tổng khối lượng giao dịch */ totalVolume: number; /** Tổng giá trị giao dịch (VND) */ totalValue: number; /** Số mã tăng */ advances: number; /** Số mã giảm */ declines: number; /** Số mã đứng giá */ noChange: number; /** Vốn hoá toàn thị trường (VND) */ marketCap?: number; } /** * Thống kê thị trường tổng quan trong ngày */ interface MarketOverview { /** Ngày giao dịch (YYYY-MM-DD) */ date: string; /** Dữ liệu sàn HOSE */ hose: MarketIndex; /** Dữ liệu sàn HNX */ hnx: MarketIndex; /** Dữ liệu UPCOM */ upcom: MarketIndex; /** Dữ liệu VN30 */ vn30: MarketIndex; /** Tổng giá trị giao dịch 3 sàn (VND) */ totalMarketValue: number; } /** * Tiêu chí sàng lọc cổ phiếu */ interface ScreenerFilter { /** Sàn giao dịch */ exchange?: Exchange | Exchange[]; /** Ngành */ industry?: string | string[]; /** Vốn hoá tối thiểu (VND) */ minMarketCap?: number; /** Vốn hoá tối đa (VND) */ maxMarketCap?: number; /** P/E tối thiểu */ minPE?: number; /** P/E tối đa */ maxPE?: number; /** P/B tối thiểu */ minPB?: number; /** P/B tối đa */ maxPB?: number; /** ROE tối thiểu (%) */ minROE?: number; /** ROE tối đa (%) */ maxROE?: number; /** ROA tối thiểu (%) */ minROA?: number; /** Tỷ suất cổ tức tối thiểu (%) */ minDividendYield?: number; /** Tăng trưởng doanh thu tối thiểu (%) */ minRevenueGrowth?: number; /** Tăng trưởng EPS tối thiểu (%) */ minEPSGrowth?: number; /** Khối lượng trung bình 5 ngày tối thiểu */ minVolume5D?: number; /** Tỷ lệ D/E tối đa */ maxDERatio?: number; } /** * Kết quả sàng lọc một cổ phiếu */ interface ScreenerResult { symbol: string; name: string; exchange: string; industry: string; price: number; priceChangePercent: number; marketCap: number; pe: number; pb: number; roe: number; roa: number; dividendYield: number; revenueGrowth: number; epsGrowth: number; volume5DAvg: number; deRatio: number; eps: number; bookValuePerShare: number; } /** * Thông tin trái phiếu */ interface Bond { /** Mã trái phiếu */ bondCode: string; /** Tên công ty phát hành */ issuer: string; /** Mã cổ phiếu công ty phát hành */ issuerSymbol: string; /** Ngày phát hành */ issueDate: string; /** Ngày đáo hạn */ maturityDate: string; /** Kỳ hạn (năm) */ term: number; /** Mệnh giá (VND) */ faceValue: number; /** Lãi suất coupon (%/năm) */ couponRate: number; /** Loại lãi suất: "FIXED" | "FLOATING" */ couponType: string; /** Kỳ trả lãi (tháng) */ couponFrequency: number; /** Tổng giá trị phát hành (VND) */ totalIssueValue: number; /** Khối lượng còn lại đang lưu hành */ outstandingVolume: number; /** Trạng thái: "active" | "matured" | "redeemed" */ status: string; } /** * Thông tin hợp đồng tương lai (futures - VN30F) */ interface FuturesContract { /** Mã hợp đồng (VD: "VN30F2503") */ symbol: string; /** Giá khớp hiện tại */ matchPrice: number; /** Thay đổi giá */ priceChange: number; /** Thay đổi % */ priceChangePercent: number; /** Giá cơ sở (VN30 index) */ underlying: number; /** Cơ sở (basis) */ basis: number; /** Khối lượng mở (Open Interest) */ openInterest: number; /** Khối lượng khớp trong phiên */ volume: number; /** Ngày đáo hạn */ expirationDate: string; } /** * Dữ liệu chứng quyền (covered warrants) */ interface CoveredWarrant { /** Mã chứng quyền (VD: "CVNM2402") */ symbol: string; /** Tên tổ chức phát hành */ issuer: string; /** Mã cổ phiếu cơ sở */ underlyingSymbol: string; /** Giá thực hiện (exercise price, VND) */ exercisePrice: number; /** Tỷ lệ chuyển đổi (vd: 1CQ = 0.1 CP cơ sở) */ conversionRatio: number; /** Ngày đáo hạn */ expirationDate: string; /** Số ngày còn đến đáo hạn */ daysToExpiry: number; /** Giá thị trường hiện tại (VND) */ marketPrice: number; /** Giá trị nội tại (Intrinsic Value, VND) */ intrinsicValue: number; /** Giá trị thời gian (Time Value, VND) */ timeValue: number; /** Trạng thái: "ITM" (in the money) | "ATM" | "OTM" */ moneyness: "ITM" | "ATM" | "OTM"; /** Loại: "CALL" | "PUT" */ type: "CALL" | "PUT"; /** Hệ số Delta */ delta?: number; } /** * Tin tức thị trường / công ty */ interface NewsItem { /** ID tin */ id: string; /** Tiêu đề */ title: string; /** Tóm tắt */ summary: string; /** URL bài viết */ url: string; /** Nguồn (VD: "CAFEF", "VIETSTOCK", "TCBS") */ source: string; /** Ngày đăng (ISO string) */ publishedAt: string; /** Mã chứng khoán liên quan */ relatedSymbols: string[]; /** Tags/từ khoá */ tags: string[]; } /** * Lịch sự kiện thị trường (dividends, AGM, earnings release, ...) */ interface MarketEvent { /** Mã chứng khoán */ symbol: string; /** Loại sự kiện */ eventType: string; /** Ngày sự kiện */ eventDate: string; /** Mô tả */ description: string; /** Giá trị (VD: cổ tức 500 VND/CP) */ value?: string; } /** * Tỷ giá hối đoái */ interface ExchangeRate { /** Mã cặp tiền tệ (VD: "USDVND", "EURVND") */ pair: string; /** Ngày */ date: string; /** Tỷ giá mua vào */ buyRate: number; /** Tỷ giá bán ra */ sellRate: number; /** Tỷ giá trung bình */ midRate: number; } /** * Giá vàng */ interface GoldPrice { /** Ngày (YYYY-MM-DD) */ date: string; /** Loại vàng (VD: "SJC", "DOJI", "BTMC") */ type: string; /** Giá mua vào (VND/lượng) */ buyPrice: number; /** Giá bán ra (VND/lượng) */ sellPrice: number; } /** * Kết quả phân trang (paginated response) */ interface PaginatedResponse { data: T[]; total: number; page: number; pageSize: number; hasMore: boolean; } /** * Response chuẩn của SDK */ interface ApiResponse { success: boolean; data: T; source: DataSource | string; timestamp: string; error?: string; } /** * Module quản lý dữ liệu giá cho một mã cổ phiếu * Khởi tạo qua: client.quote("VCB") */ declare class QuoteModule { private readonly symbol; private readonly client; private readonly config; constructor(symbol: string, client: AxiosInstance, config: VnStockConfig); /** * Lấy dữ liệu OHLCV lịch sử * * @param params.start - Ngày bắt đầu (YYYY-MM-DD). Mặc định: 1 năm trước * @param params.end - Ngày kết thúc (YYYY-MM-DD). Mặc định: hôm nay * @param params.interval - Khung thời gian. Mặc định: D1 (1 ngày) * @param params.source - Nguồn dữ liệu: TCBS (ngày, dài hạn) hoặc DNSE (đa khung giờ) * * @example * const candles = await quote.history({ * start: "2023-01-01", * end: "2024-01-01", * interval: Interval.D1, * source: DataSource.TCBS * }) */ history({ start, end, interval, source, }: { start: string; end?: string; interval?: Interval; source?: DataSource; }): Promise; /** * Lấy dữ liệu khớp lệnh intraday (trong phiên) * * Phân loại lệnh: * - "BU": Chủ động mua (Active Buy) - áp lực mua mạnh * - "SD": Chủ động bán (Active Sell) - áp lực bán mạnh * - "": Lệnh ATC/ATO hoặc không xác định * * @param page - Trang (bắt đầu từ 0) * @param pageSize - Số lệnh mỗi trang (tối đa 100) * * @example * const ticks = await quote.intraday(0, 100) * const buyTicks = ticks.filter(t => t.orderType === "BU") */ intraday(page?: number, pageSize?: number): Promise; /** * Lấy thống kê tổng hợp chủ động mua/bán trong phiên * Tự động gộp tối đa 1000 lệnh từ nhiều trang * * Hữu ích để phân tích áp lực mua/bán: * - netVolume > 0: áp lực mua đang chiếm ưu thế * - netVolume < 0: áp lực bán đang chiếm ưu thế * * @example * const summary = await quote.activeBuySellSummary() * console.log(`Net Volume: ${summary.netVolume}`) // dương = áp lực mua */ activeBuySellSummary(maxPages?: number): Promise; /** * Phân tích lệnh theo loại nhà đầu tư (Shark/Grey Wolf/Sheep) * Phân loại dựa trên giá trị lệnh: * - Cá mập (Shark): giá trị lệnh > 1 tỷ VND * - Sói xám (Grey Wolf): 200 triệu ≤ giá trị ≤ 1 tỷ VND * - Cừu (Sheep): giá trị < 200 triệu VND * * @example * const stats = await quote.investorTypeStats() * console.log(`Cá mập mua: ${stats.shark.buyVolume} CP`) */ investorTypeStats(): Promise; /** * Lấy tin tức liên quan đến mã cổ phiếu * @param limit - Số lượng tin tức (mặc định: 20) */ news(limit?: number): Promise; } /** * Module thông tin công ty * Khởi tạo qua: client.company("VCB") */ declare class CompanyModule { private readonly symbol; private readonly client; private readonly config; constructor(symbol: string, client: AxiosInstance, config: VnStockConfig); /** * Thông tin tổng quan công ty * Bao gồm: tên, sàn, ngành, mô tả, vốn điều lệ, số cổ phiếu lưu hành, ... * * @example * const overview = await company.overview() * console.log(overview.name, overview.industry) */ overview(): Promise; /** * Danh sách cổ đông lớn (nắm > 5% vốn) * * @example * const shareholders = await company.shareholders() */ shareholders(): Promise; /** * Danh sách lãnh đạo và HĐQT * * @example * const officers = await company.officers() */ officers(): Promise; /** * Lịch sử sự kiện doanh nghiệp * (cổ tức, phát hành thêm cổ phiếu, ĐHCĐ, chia tách, ...) * * @example * const events = await company.events() */ events(): Promise; /** * Giao dịch nội bộ (Ban lãnh đạo/cổ đông lớn mua bán) * * @example * const insiders = await company.insiderTrading() */ insiderTrading(): Promise; /** * Giao dịch nước ngoài theo lịch sử * * @param start - Ngày bắt đầu (YYYY-MM-DD) * @param end - Ngày kết thúc (YYYY-MM-DD) * * @example * const foreign = await company.foreignTrading("2024-01-01", "2024-12-31") */ foreignTrading(start: string, end?: string): Promise; } /** * Module báo cáo tài chính * Khởi tạo qua: client.finance("VCB") */ declare class FinanceModule { private readonly symbol; private readonly client; private readonly config; constructor(symbol: string, client: AxiosInstance, config: VnStockConfig); /** * Bảng cân đối kế toán (Balance Sheet) * * @param period - "year" | "quarter" * @param limit - Số kỳ trả về (mặc định: 8) * * @example * const bs = await finance.balanceSheet("year", 5) * console.log(bs[0].totalAssets) // tổng tài sản kỳ mới nhất */ balanceSheet(period?: ReportPeriod, limit?: number): Promise; /** * Kết quả hoạt động kinh doanh (Income Statement) * * @param period - "year" | "quarter" * @param limit - Số kỳ trả về * * @example * const income = await finance.incomeStatement("quarter", 8) * console.log(income[0].revenue) // doanh thu */ incomeStatement(period?: ReportPeriod, limit?: number): Promise; /** * Lưu chuyển tiền tệ (Cash Flow Statement) * * @param period - "year" | "quarter" * @param limit - Số kỳ trả về * * @example * const cf = await finance.cashFlow("year") * console.log(cf[0].freeCashFlow) // free cash flow */ cashFlow(period?: ReportPeriod, limit?: number): Promise; /** * Chỉ số tài chính (Financial Ratios) * Bao gồm: P/E, P/B, ROE, ROA, D/E, Current Ratio, ... * * @param period - "year" | "quarter" * @param limit - Số kỳ trả về * * @example * const ratios = await finance.ratio("year") * console.log(ratios[0].roe) // ROE kỳ mới nhất (%) */ ratio(period?: ReportPeriod, limit?: number): Promise; /** * Lấy toàn bộ báo cáo tài chính trong một lần gọi * (Balance Sheet + Income Statement + Cash Flow + Ratios) * * @param period - "year" | "quarter" * @param limit - Số kỳ trả về * * @example * const all = await finance.all("year", 5) */ all(period?: ReportPeriod, limit?: number): Promise<{ balanceSheet: BalanceSheet[]; incomeStatement: IncomeStatement[]; cashFlow: CashFlow[]; ratio: FinancialRatio[]; }>; } /** * Module quản lý danh sách mã và nhóm chứng khoán * Khởi tạo qua: client.listing() */ declare class ListingModule { private readonly client; private readonly config; constructor(client: AxiosInstance, config: VnStockConfig); /** * Lấy toàn bộ danh sách mã chứng khoán niêm yết (HOSE + HNX + UPCOM) * * @param source - Nguồn dữ liệu (SSI mặc định, DNSE fallback) * * @example * const allStocks = await listing.all() * const hoseOnly = allStocks.filter(s => s.exchange === "HOSE") */ all(source?: DataSource): Promise; /** * Lấy danh sách mã theo sàn giao dịch * * @param exchange - Sàn: HOSE | HNX | UPCOM * * @example * const hoseStocks = await listing.byExchange(Exchange.HOSE) */ byExchange(exchange: Exchange): Promise; /** * Lấy danh sách mã trong một nhóm chỉ số * * Các nhóm: VN30, VN100, VNMidCap, VNSmallCap, VNAllShare, * HNX30, HNXLargeCap, HNXMidCap, HNXSmallCap, * UPCOM50, UPCOMLARGE, UPCOMMID, UPCOMSMALL * * @param indexName - Tên nhóm chỉ số * * @example * const vn30 = await listing.indexGroup("VN30") * console.log(vn30.symbols) // ["VCB", "HPG", "VNM", ...] */ indexGroup(indexName: string): Promise; /** * Lấy tất cả các nhóm chỉ số và thành phần * * @example * const groups = await listing.allIndexGroups() */ allIndexGroups(): Promise; /** * Lấy danh mục phân loại ngành (ICB) * * @example * const sectors = await listing.sectors() */ sectors(): Promise; } /** * Module dữ liệu giao dịch thị trường * Khởi tạo qua: client.trading() */ declare class TradingModule { private readonly client; private readonly config; constructor(client: AxiosInstance, config: VnStockConfig); /** * Lấy bảng giá realtime cho nhiều mã cùng lúc * Bao gồm: bid/ask 3 bước, khối lượng nước ngoài, room, P/E, P/B, ... * * @param symbols - Danh sách mã (tối đa 200 mã) * * @example * const board = await trading.priceBoard(["VCB", "HPG", "VNM"]) * const vcb = board.find(b => b.symbol === "VCB") */ priceBoard(symbols: string[]): Promise; /** * Dữ liệu room nước ngoài toàn thị trường theo sàn * * @param exchange - Sàn giao dịch * @param date - Ngày cụ thể (YYYY-MM-DD), null = hôm nay * * @example * const rooms = await trading.foreignRoom(Exchange.HOSE) */ foreignRoom(exchange?: Exchange, date?: string): Promise; } /** * Module dữ liệu thị trường tổng quan * Khởi tạo qua: client.market() */ declare class MarketModule { private readonly client; private readonly config; constructor(client: AxiosInstance, config: VnStockConfig); /** * Lấy lịch sử chỉ số thị trường * * Các chỉ số TCBS: VNINDEX, HNXIndex, UpcomIndex, VN30, VNMidCap, VNSmallCap, HNX30 * Các chỉ số DNSE: VNINDEX, HNXINDEX, UPCOMINDEX, VN30, HNX30, VNMidCap, VNSmallCap * * @param indexName - Tên chỉ số (VD: "VNINDEX") * @param start - Ngày bắt đầu (YYYY-MM-DD) * @param end - Ngày kết thúc (YYYY-MM-DD) * @param interval - Khung thời gian (chỉ DNSE hỗ trợ phút) * @param source - Nguồn dữ liệu * * @example * const vnindex = await market.index("VNINDEX", "2024-01-01", "2024-12-31") */ index(indexName: string, start: string, end?: string, interval?: Interval, source?: DataSource): Promise; /** * Sàng lọc cổ phiếu theo bộ tiêu chí * * @param filter - Tiêu chí lọc (P/E, P/B, ROE, vốn hoá, ngành, ...) * @param limit - Số kết quả tối đa (mặc định: 50) * * @example * const results = await market.screener({ * exchange: Exchange.HOSE, * minROE: 15, * maxPE: 20, * minMarketCap: 1_000_000_000_000 // 1 nghìn tỷ VND * }) */ screener(filter?: ScreenerFilter, limit?: number): Promise; /** * Lấy dữ liệu OHLCV cho hợp đồng phái sinh (VN30F) * * @param symbol - Mã hợp đồng (VD: "VN30F2503") * @param start - Ngày bắt đầu * @param end - Ngày kết thúc * @param interval - Khung thời gian * * @example * const futures = await market.derivativeHistory("VN30F2503", "2024-01-01", "2024-03-31") */ derivativeHistory(symbol: string, start: string, end?: string, interval?: Interval): Promise; /** * Danh sách hợp đồng tương lai VN30F đang giao dịch * * @example * const contracts = await market.futuresContracts() */ futuresContracts(): Promise; } /** * Module dữ liệu bổ sung: ngoại hối, vàng, trái phiếu, chứng quyền * Khởi tạo qua: client.misc() */ declare class MiscModule { private readonly client; private readonly config; constructor(client: AxiosInstance, config: VnStockConfig); /** * Tỷ giá hối đoái từ Vietcombank * Bao gồm tỷ giá mua/bán/chuyển khoản cho 15+ loại ngoại tệ * * @param date - Ngày cụ thể (YYYY-MM-DD), null = hôm nay * * @example * const rates = await misc.exchangeRates() * const usd = rates.find(r => r.pair === "USDVND") */ exchangeRates(date?: string): Promise; /** * Giá vàng SJC (mua vào và bán ra) * * @example * const gold = await misc.goldPrice() * console.log(`SJC bán ra: ${gold[0].sellPrice.toLocaleString()} VND/lượng`) */ goldPrice(): Promise; /** * Danh sách trái phiếu doanh nghiệp từ TCBS * * @param page - Trang (bắt đầu từ 0) * @param pageSize - Số trái phiếu mỗi trang * * @example * const bonds = await misc.bonds() */ bonds(page?: number, pageSize?: number): Promise; /** * Chi tiết một trái phiếu cụ thể * * @param bondCode - Mã trái phiếu (VD: "TCB.H2025.01") * * @example * const bond = await misc.bondDetail("TCB.H2025.01") */ bondDetail(bondCode: string): Promise; }>; /** * Danh sách chứng quyền đang giao dịch * * @param underlyingSymbol - Lọc theo mã cơ sở (VD: "VCB"). null = lấy tất cả * * @example * const warrants = await misc.coveredWarrants("VCB") * const itm = warrants.filter(w => w.moneyness === "ITM") // In the money */ coveredWarrants(underlyingSymbol?: string): Promise; /** * Danh sách quỹ mở (open-end funds) * * @example * const funds = await misc.funds() */ funds(): Promise[]>; /** * Lịch sử NAV của một quỹ đầu tư * * @param fundCode - Mã quỹ (VD: "TCBF", "VCBF-BCF") * @param start - Ngày bắt đầu (YYYY-MM-DD) * @param end - Ngày kết thúc (YYYY-MM-DD) * * @example * const nav = await misc.fundNav("TCBF", "2024-01-01", "2024-12-31") */ fundNav(fundCode: string, start: string, end?: string): Promise<{ date: string; nav: number; fundCode: string; }[]>; /** * Thông tin giới hạn dữ liệu theo interval của DNSE * Hữu ích để thông báo người dùng về giới hạn * * @param interval - Khung thời gian * * @example * const info = misc.dnseIntervalInfo(Interval.M1) * console.log(info.description) // "Dữ liệu 1 phút: tối đa 90 ngày gần nhất" */ dnseIntervalInfo(interval: Interval): { maxDays: number; description: string; }; } /** * # VnStockClient * * Client chính để truy cập dữ liệu chứng khoán Việt Nam. * Hoàn toàn miễn phí, không cần API key, không cần đăng ký. * * ## Nguồn dữ liệu được hỗ trợ: * - **TCBS** (api.tcbs.com.vn): OHLCV ngày, intraday, báo cáo tài chính, công ty, screener * - **DNSE** (services.entrade.com.vn): OHLCV đa khung thời gian (1m đến 1 tháng), phái sinh * - **SSI** (fc-data.ssi.com.vn): Danh sách mã, bảng giá, nhóm chỉ số * - **VCB** (portal.vietcombank.com.vn): Tỷ giá ngoại tệ * - **SJC** (sjc.com.vn): Giá vàng * * ## Cách sử dụng: * * ```typescript * import { VnStockClient, Interval, DataSource, Exchange, ReportPeriod } from 'vn-stock-sdk' * * const client = new VnStockClient({ debug: true }) * * // Dữ liệu giá lịch sử (OHLCV) * const candles = await client.quote("VCB").history({ * start: "2024-01-01", * end: "2024-12-31", * interval: Interval.D1 * }) * * // Dữ liệu 1 phút từ DNSE * const minuteData = await client.quote("VNM").history({ * start: "2024-12-01", * interval: Interval.M1, * source: DataSource.DNSE * }) * * // Khớp lệnh intraday + phân tích chủ động mua/bán * const activeSummary = await client.quote("HPG").activeBuySellSummary() * console.log(`Áp lực mua: ${activeSummary.totalBuyVolume.toLocaleString()} CP`) * * // Thông tin công ty * const company = await client.company("VCB").overview() * const shareholders = await client.company("VCB").shareholders() * * // Báo cáo tài chính * const finance = client.finance("VCB") * const bs = await finance.balanceSheet(ReportPeriod.YEAR, 5) * const income = await finance.incomeStatement(ReportPeriod.QUARTER, 8) * const ratios = await finance.ratio() * * // Danh sách mã và nhóm * const allStocks = await client.listing().all() * const vn30 = await client.listing().indexGroup("VN30") * * // Sàng lọc cổ phiếu * const topROE = await client.market().screener({ * exchange: Exchange.HOSE, * minROE: 20, * maxPE: 15 * }) * * // Chỉ số thị trường * const vnindex = await client.market().index("VNINDEX", "2024-01-01") * * // Tỷ giá và vàng * const usdRate = await client.misc().exchangeRates() * const goldPrice = await client.misc().goldPrice() * ``` */ declare class VnStockClient { private readonly httpClient; private readonly config; /** * Khởi tạo VnStockClient * * @param config - Cấu hình tuỳ chọn * @param config.timeout - Timeout mỗi request (ms). Mặc định: 30000 * @param config.retries - Số lần thử lại khi lỗi. Mặc định: 3 * @param config.retryDelay - Delay giữa các lần thử (ms). Mặc định: 1000 * @param config.debug - Bật log debug. Mặc định: false * @param config.userAgent - User-Agent tuỳ chỉnh * @param config.extraHeaders - Headers tuỳ chỉnh thêm vào mỗi request * * @example * // Khởi tạo với cấu hình mặc định * const client = new VnStockClient() * * // Khởi tạo với debug và timeout dài hơn * const client = new VnStockClient({ debug: true, timeout: 60_000 }) */ constructor(config?: VnStockConfig); /** * Module dữ liệu giá cho một mã cổ phiếu * * @param symbol - Mã chứng khoán (VD: "VCB", "HPG") * * @example * const quote = client.quote("VCB") * const candles = await quote.history({ start: "2024-01-01" }) */ quote(symbol: string): QuoteModule; /** * Module thông tin công ty * * @param symbol - Mã chứng khoán * * @example * const company = client.company("VCB") * const overview = await company.overview() */ company(symbol: string): CompanyModule; /** * Module báo cáo tài chính * * @param symbol - Mã chứng khoán * * @example * const finance = client.finance("VCB") * const bs = await finance.balanceSheet() */ finance(symbol: string): FinanceModule; /** * Module danh sách mã và nhóm chứng khoán * * @example * const listing = client.listing() * const allStocks = await listing.all() */ listing(): ListingModule; /** * Module giao dịch thị trường (bảng giá, room ngoại) * * @example * const trading = client.trading() * const board = await trading.priceBoard(["VCB", "HPG"]) */ trading(): TradingModule; /** * Module dữ liệu thị trường tổng quan (index, screener, phái sinh) * * @example * const market = client.market() * const index = await market.index("VNINDEX", "2024-01-01") */ market(): MarketModule; /** * Module dữ liệu bổ sung (ngoại hối, vàng, trái phiếu, chứng quyền, quỹ) * * @example * const misc = client.misc() * const gold = await misc.goldPrice() */ misc(): MiscModule; } /** * Custom Error class cho SDK */ declare class VnStockError extends Error { /** HTTP status code (0 nếu không phải HTTP error) */ readonly statusCode: number; /** URL gây ra lỗi */ readonly url: string; constructor(message: string, statusCode: number, url: string); } /** * Chuyển đổi ngày YYYY-MM-DD sang Unix timestamp (seconds) */ declare function dateToTimestamp(dateStr: string): number; /** * Chuyển đổi Unix timestamp (seconds) sang YYYY-MM-DD */ declare function timestampToDate(timestamp: number): string; /** * Lấy ngày hôm nay dạng YYYY-MM-DD */ declare function today(): string; /** * Validate mã cổ phiếu (1-10 ký tự, chữ hoa) */ declare function validateSymbol(symbol: string): string; declare function fetchTcbsOHLCV(client: AxiosInstance, symbol: string, start: string, end: string, debug?: boolean): Promise; declare function fetchTcbsIntraday(client: AxiosInstance, symbol: string, page?: number, pageSize?: number, debug?: boolean): Promise; declare function fetchTcbsActiveBuySellSummary(client: AxiosInstance, symbol: string, maxPages?: number, debug?: boolean): Promise; declare function fetchTcbsInvestorTypeStats(client: AxiosInstance, symbol: string, debug?: boolean): Promise; declare function fetchTcbsCompanyOverview(client: AxiosInstance, symbol: string, debug?: boolean): Promise; declare function fetchTcbsShareholders(client: AxiosInstance, symbol: string, debug?: boolean): Promise; declare function fetchTcbsOfficers(client: AxiosInstance, symbol: string, debug?: boolean): Promise; declare function fetchTcbsCorporateEvents(client: AxiosInstance, symbol: string, debug?: boolean): Promise; declare function fetchTcbsInsiderTrading(client: AxiosInstance, symbol: string, debug?: boolean): Promise; declare function fetchTcbsBalanceSheet(client: AxiosInstance, symbol: string, period?: ReportPeriod, limit?: number, debug?: boolean): Promise; declare function fetchTcbsIncomeStatement(client: AxiosInstance, symbol: string, period?: ReportPeriod, limit?: number, debug?: boolean): Promise; declare function fetchTcbsCashFlow(client: AxiosInstance, symbol: string, period?: ReportPeriod, limit?: number, debug?: boolean): Promise; declare function fetchTcbsFinancialRatio(client: AxiosInstance, symbol: string, period?: ReportPeriod, limit?: number, debug?: boolean): Promise; declare function fetchTcbsForeignTrading(client: AxiosInstance, symbol: string, start: string, end: string, debug?: boolean): Promise; declare function fetchTcbsNews(client: AxiosInstance, symbol: string, limit?: number, debug?: boolean): Promise; declare function fetchTcbsMarketIndex(client: AxiosInstance, indexName: string, start: string, end: string, debug?: boolean): Promise; declare function fetchTcbsScreener(client: AxiosInstance, filter?: ScreenerFilter, limit?: number, debug?: boolean): Promise; declare function fetchDnseOHLCV(client: AxiosInstance, symbol: string, start: string, end: string, interval?: Interval, debug?: boolean): Promise; /** * Lấy danh sách toàn bộ chứng khoán niêm yết * API này rất ổn định và đầy đủ */ declare function fetchDnseListing(client: AxiosInstance, debug?: boolean): Promise; declare function fetchDnseDerivativeOHLCV(client: AxiosInstance, symbol: string, start: string, end: string, interval?: Interval, debug?: boolean): Promise; declare function fetchDnseFuturesContracts(client: AxiosInstance, debug?: boolean): Promise; declare function fetchDnseIndexOHLCV(client: AxiosInstance, indexName: string, start: string, end: string, interval: Interval, debug?: boolean): Promise; declare function getDnseIntervalLimits(interval: Interval): { maxDays: number; description: string; }; /** * Lấy danh sách mã chứng khoán (Dùng DNSE vì tốt nhất hiện tại) */ declare function fetchAllListing(client: AxiosInstance, debug?: boolean): Promise; /** * Lấy thành phần chỉ số (Dùng TCBS) */ declare function fetchIndexComponents(client: AxiosInstance, indexName: string, debug?: boolean): Promise; declare function fetchAllIndexGroups(client: AxiosInstance, debug?: boolean): Promise; declare function fetchIndustrySectors(client: AxiosInstance, debug?: boolean): Promise; /** * Lấy bảng giá (Dùng TCBS Snapshot) */ declare function fetchPriceBoard(client: AxiosInstance, symbols: string[], debug?: boolean): Promise; declare function fetchForeignRoomByExchange(client: AxiosInstance, exchange: Exchange, date?: string, debug?: boolean): Promise; /** Danh sách mã tiền tệ phổ biến tại Việt Nam */ declare const SUPPORTED_CURRENCIES: readonly ["USD", "EUR", "GBP", "JPY", "CNY", "KRW", "THB", "SGD", "AUD", "CAD", "CHF", "HKD", "MYR", "TWD", "NZD"]; /** * Lấy tỷ giá hối đoái từ Vietcombank * * Vietcombank cung cấp API tỷ giá công khai (không cần key). * Endpoint: GET /Usercontrols/TVPortal.TyGia/pXML.aspx * Format trả về: XML (cần parse) * * @param client - Axios HTTP client * @param date - Ngày lấy tỷ giá (YYYY-MM-DD), null = hôm nay * @param debug - Bật log debug * @returns Danh sách ExchangeRate */ declare function fetchVcbExchangeRates(client: AxiosInstance, date?: string, debug?: boolean): Promise; /** * Lấy giá vàng SJC (Công ty Vàng bạc Đá quý SJC - uy tín nhất VN) * * Dữ liệu bao gồm: giá mua vào và bán ra cho từng vùng * Đơn vị: nghìn VND/lượng (1 lượng = 37.5 gram) * * @param client - Axios HTTP client * @param debug - Bật log debug * @returns Danh sách GoldPrice */ declare function fetchSjcGoldPrice(client: AxiosInstance, debug?: boolean): Promise; /** * Lấy danh sách trái phiếu doanh nghiệp từ TCBS * * TCBS là một trong những nền tảng phân phối trái phiếu lớn nhất VN. * Endpoint: GET /tcanalysis/v1/bond/listing * * @param client - Axios HTTP client * @param page - Trang (bắt đầu từ 0) * @param pageSize - Số trái phiếu mỗi trang * @param debug - Bật log debug * @returns Danh sách Bond */ declare function fetchBondListing(client: AxiosInstance, page?: number, pageSize?: number, debug?: boolean): Promise; /** * Lấy thông tin chi tiết và lịch trả lãi/gốc của một trái phiếu * * Endpoint: GET /tcanalysis/v1/bond/{bondCode} * * @param client - Axios HTTP client * @param bondCode - Mã trái phiếu (VD: "TCB.H2025.01") * @param debug - Bật log debug * @returns Chi tiết trái phiếu */ declare function fetchBondDetail(client: AxiosInstance, bondCode: string, debug?: boolean): Promise; }>; /** * Lấy danh sách chứng quyền đang giao dịch trên HOSE * * Chứng quyền được phát hành bởi các CTCK như: * SSI, VNDS, KIS, MBS, VNCS, ACBS, ... * * Endpoint: GET /fc-data.ssi.com.vn/api/v2/Market/CoveredWarrants * * @param client - Axios HTTP client * @param underlyingSymbol - Lọc theo mã cơ sở (VD: "VCB"). null = lấy tất cả * @param debug - Bật log debug * @returns Danh sách CoveredWarrant */ declare function fetchCoveredWarrants(client: AxiosInstance, underlyingSymbol?: string, debug?: boolean): Promise; /** * Lấy danh sách quỹ mở (open-end funds) từ FMarket * * Endpoint: GET /fmarket.vn/api/fund/filter * * @param client - Axios HTTP client * @param debug - Bật log debug * @returns Danh sách quỹ đầu tư */ declare function fetchFundListing(client: AxiosInstance, debug?: boolean): Promise>>; /** * Lấy NAV lịch sử của một quỹ đầu tư * * @param client - Axios HTTP client * @param fundCode - Mã quỹ (VD: "TCBF", "VCBF-BCF") * @param start - Ngày bắt đầu (YYYY-MM-DD) * @param end - Ngày kết thúc (YYYY-MM-DD) * @param debug - Bật log debug * @returns Lịch sử NAV */ declare function fetchFundNavHistory(client: AxiosInstance, fundCode: string, start: string, end: string, debug?: boolean): Promise>; /** * Danh sách tên các chỉ số thị trường được hỗ trợ */ declare const SUPPORTED_INDICES: { readonly TCBS: readonly ["VNINDEX", "HNXIndex", "UpcomIndex", "VN30", "VNMidCap", "VNSmallCap", "HNX30", "VNAllShare", "VNX50", "VNXALL"]; readonly DNSE: readonly ["VNINDEX", "HNXINDEX", "UPCOMINDEX", "VN30", "HNX30", "VNMidCap", "VNSmallCap"]; }; /** * Danh sách nhóm chỉ số được hỗ trợ */ declare const INDEX_GROUPS: readonly ["VN30", "VN100", "VNMidCap", "VNSmallCap", "VNAllShare", "HNX30", "HNXLargeCap", "HNXMidCap", "HNXSmallCap", "UPCOM50", "UPCOMLARGE", "UPCOMMID", "UPCOMSMALL", "VNXALL", "VNX50"]; /** * Phiên bản của thư viện */ declare const VERSION = "1.0.0"; export { type ActiveBuySellSummary, type ApiResponse, type BalanceSheet, type Bond, type CashFlow, CompanyModule, type CompanyOverview, type CorporateEvent, type CoveredWarrant, DataSource, Exchange, type ExchangeRate, FinanceModule, type FinancialParams, type FinancialRatio, type ForeignTrading, type FuturesContract, type GoldPrice, type HistoryParams, INDEX_GROUPS, type IncomeStatement, type IndustrySector, type InsiderTrading, Interval, type IntradayTick, type InvestorTypeStats, ListingModule, type MarketEvent, type MarketIndex, MarketModule, type MarketOverview, MiscModule, type NewsItem, type OHLCVCandle, type Officer, type PaginatedResponse, type PriceBoardItem, type ProprietaryTrading, QuoteModule, ReportPeriod, SUPPORTED_CURRENCIES, SUPPORTED_INDICES, type ScreenerFilter, type ScreenerResult, type Shareholder, type StockGroup, type StockListing, TraderType, TradingModule, VERSION, VnStockClient, type VnStockConfig, VnStockError, dateToTimestamp, fetchAllIndexGroups, fetchAllListing, fetchBondDetail, fetchBondListing, fetchCoveredWarrants, fetchDnseDerivativeOHLCV, fetchDnseFuturesContracts, fetchDnseIndexOHLCV, fetchDnseListing, fetchDnseOHLCV, fetchForeignRoomByExchange, fetchFundListing, fetchFundNavHistory, fetchIndexComponents, fetchIndustrySectors, fetchPriceBoard, fetchSjcGoldPrice, fetchTcbsActiveBuySellSummary, fetchTcbsBalanceSheet, fetchTcbsCashFlow, fetchTcbsCompanyOverview, fetchTcbsCorporateEvents, fetchTcbsFinancialRatio, fetchTcbsForeignTrading, fetchTcbsIncomeStatement, fetchTcbsInsiderTrading, fetchTcbsIntraday, fetchTcbsInvestorTypeStats, fetchTcbsMarketIndex, fetchTcbsNews, fetchTcbsOHLCV, fetchTcbsOfficers, fetchTcbsScreener, fetchTcbsShareholders, fetchVcbExchangeRates, getDnseIntervalLimits, timestampToDate, today, validateSymbol };