Các hàm cơ bản của vnstock-js
import { stock, commodity } from 'vnstock-js';
const indexPrices = await stock.index({ index: 'VNINDEX', start: '2024-01-01' });
// → [{ date: "2024-01-02", open: 1.18, high: 1.19, low: 1.17, close: 1.185, volume: 500000000 }, ...]
const tickerPrices = await stock.quote({ ticker: 'VCI', start: '2024-01-01' });
// → [{ date: "2024-01-02", open: 25.5, high: 26.0, low: 25.0, close: 25.8, volume: 1000000 }, ...]
const priceBoard = await stock.priceBoard({ ticker: 'VCI' });
// → [{ symbol: "VCI", price: 25.8, totalVolume: 500000, ceilingPrice: 27.5, ... }]
const gainers = await stock.topGainers();
const losers = await stock.topLosers();
// → [{ symbol: "FPT", exchange: "HOSE", marketCap: 95000, ... }]
const company = stock.company({ ticker: 'VCI' });
const profile = await company.profile();
// → { industry: "Chứng khoán", issuedShares: 500000000, ... }
const shareholders = await company.shareholders();
// → [{ name: "...", percentage: 0.15, ... }]
const financials = await stock.financials({ ticker: 'VCI', period: 'quarter' });
// → { data: { symbol: "VCI", year: 2024, quarter: 4, roe: 0.22, ... }, mapping: { ... } }
const screened = await stock.screening({
exchange: 'HOSE',
filters: [{ field: 'pe', operator: '<', value: 15 }],
sortBy: 'roe',
order: 'desc',
limit: 10,
});
// → [{ symbol: "FPT", pe: 12, roe: 0.22, marketCap: 95000, ... }]
const goldSJC = await commodity.gold.priceSJC();
// → [{ type: "SJC 1L", buyPrice: 92000000, sellPrice: 94000000, ... }]
const goldBTMC = await commodity.gold.priceBTMC();
const goldGVN = await commodity.gold.priceGiaVangNet();
const rates = await commodity.exchange();
// → [{ currencyCode: "USD", currencyName: "US Dollar", buyCash: "25100", sell: "25450" }]