npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

miniccxt-lite

v1.0.3

Published

Mini Unified Market Data library for Crypto and Forex

Readme

Mini-CCXT Project

Mini-CCXT là một thư viện Unified Market Data siêu nhẹ (Lite), được thiết kế để hợp nhất các API REST và WebSocket từ nhiều sàn giao dịch khác nhau (Crypto & Forex) thành một chuẩn duy nhất. Thư viện hỗ trợ cả môi trường Node.jsBrowser.

🎯 Mục tiêu: Tập trung vào Market Data (OHLCV, Ticker, ExchangeInfo) với khả năng "Smart Fetch" (tự động phân trang khi yêu cầu dữ liệu lịch sử lớn) và đồng bộ hóa đa sàn.


🚀 Tính năng chính

  • Unified API: Sử dụng chung một bộ hàm cho mọi sàn (fetchOHLCV, fetchTicker, fetchExchangeInfo, subscribeTicker).
  • Standardized Symbols: Ký hiệu thống nhất dưới dạng EXCHANGE:BASE/QUOTE (ví dụ: BINANCE:BTC/USDT, OANDA:XAU/USD).
  • Smart Fetch: Tự động chia nhỏ và gọi API nhiều lần khi limit vượt quá giới hạn của sàn (ví dụ: lấy 5000 nến Binance trong 1 lần gọi).
  • Forex Gap Filling: Algorith tự động chèn "nến phẳng" (flat bars) vào các khoảng nghỉ của thị trường Forex (cuối tuần, lễ) giúp biểu đồ không bị đứt đoạn.
  • Hybrid Streaming:
    • Crypto: Sử dụng native WebSocket.
    • Forex (OANDA): Sử dụng HTTP Streaming (ReadableStream) để nhận giá trực tiếp không cần WebSocket.
  • TradingView Compatible: Cung cấp sẵn các thuộc tính minMove, priceScale, precision để tích hợp trực tiếp vào TradingView Chart.

🏗️ Cấu trúc dự án

src/
├── core/               # Nhân lõi (Base classes, Drivers)
│   ├── BaseExchange.ts # Lớp cơ sở cho mọi sàn
│   ├── RestClient.ts   # Axios wrapper
│   └── WebSocketClient.ts # WebSocket wrapper (Node/Browser)
├── exchanges/          # Triển khai cụ thể từng sàn
│   ├── crypto/         # Binance, Bybit, OKX
│   └── forex/          # Oanda
├── types/              # Định nghĩa TypeScript (Market, Exchange, WS)
├── utils/              # Tiện ích (Symbol handling, Timezone UTC+7)
└── index.ts            # Entry point (MiniCCXT class & Configs)

🛠️ Hướng dẫn sử dụng

1. Cài đặt và Build

npm install
npm run bundle  # Tạo file bundle tại dist/mini-ccxt.js

2. Sử dụng trong Browser

Nhúng file dist/mini-ccxt.js và khởi tạo:

const ccxt = new MiniCCXT.MiniCCXT();

// Thêm sàn (sử dụng ID trong DEFAULT_CONFIGS)
const binance = await ccxt.addExchange('BINANCE_FUTURE');
const oanda = await ccxt.addExchange('OANDA', { accountId: '...', apiKey: '...' });

// Lấy 2000 nến (Smart Fetch tự động chạy)
const bars = await ccxt.fetchOHLCV('BINANCE_FUTURE', 'BTC/USDT', '1h', { limit: 2000 });

// Lấy thông tin cấu hình chart (cho TradingView)
const info = binance.getInfoSymbol('BTC/USDT'); 
// Trả về { minMove, priceScale, precision ... }

3. Đăng ký nhận giá Realtime

ccxt.subscribeTicker('OANDA', 'XAU/USD', (msg) => {
    console.log(`[OANDA] Gold Price: ${msg.data.last}`);
});

🧪 Dashboard Demo

Dự án đi kèm một trang Dashboard mẫu tại examples/dashboard/index.html. Để chạy demo:

  1. Chạy lệnh: npx http-server .
  2. Mở trình duyệt tại: http://localhost:8080/examples/dashboard/

📂 Danh sách sàn đang hỗ trợ

  • BINANCE_FUTURE: Crypto Futures (USD-M).
  • BYBIT_FUTURE: Crypto Futures (Linear).
  • OKX_FUTURE: Crypto Futures (Swap).
  • OANDA: Forex (Major pairs & Gold).

📝 Giấy phép

Dự án được phát triển cho mục đích nghiên cứu và giao dịch tự động. Vui lòng kiểm tra kỹ logic tính toán (đặc biệt là Gap Filling và Timezone) trước khi áp dụng vào thực tế.