Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)45k · #6382

ccxt-java

Skill này làm gì

Skill này là hướng dẫn xây dựng tính năng sàn tiền mã hóa trong ứng dụng Java bằng thư viện CCXT. Nó dành cho lập trình viên xây hệ thống giao dịch hoặc phần mềm tài chính bằng Java.

Khi nào nên dùng

  • ✓Khi bạn đang xây một ứng dụng Java đọc giá tiền mã hóa từ một sàn.
  • ✓Khi bạn cần đặt lệnh từ một hệ thống giao dịch Java.
  • ✓Khi bạn muốn cập nhật ticker trực tiếp trong một dự án Java.

Liên kết skill

https://github.com/ccxt/ccxt/blob/master/.claude/skills/ccxt-java/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/ccxt/ccxt/blob/master/.claude/skills/ccxt-java/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Viết một lớp Java in giá ETH/USDT hiện tại từ Kraken.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

AI dùng gói CCXT Java, tạo một lớp exchange có kiểu rõ ràng, và gọi các phương thức REST hoặc WebSocket tùy theo tác vụ.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

CCXT for Java

A comprehensive guide to using CCXT in Java projects for cryptocurrency exchange integration.

Installation

Via Gradle

// build.gradle
repositories {
    mavenCentral()
}
dependencies {
    implementation 'io.github.ccxt:ccxt:latest.release'
}

Via Maven

<dependency>
    <groupId>io.github.ccxt</groupId>
    <artifactId>ccxt</artifactId>
    <version>LATEST</version>
</dependency>

Requirements

  • Java 21 or higher (uses virtual threads)

Quick Start

REST API

import io.github.ccxt.exchanges.Binance;
import io.github.ccxt.types.Ticker;

Binance exchange = new Binance();
exchange.loadMarkets(false);
Ticker ticker = exchange.fetchTicker("BTC/USDT");
System.out.println(ticker.last);

WebSocket API - Real-time Updates

import io.github.ccxt.exchanges.pro.Binance;

var exchange = new Binance();
exchange.loadMarkets(false);
while (true) {
    Ticker ticker = exchange.watchTicker("BTC/USDT"); // typed sync, blocks for one update
    System.out.println(ticker.last);
}

Architecture: Typed Subclasses

Each exchange has two classes following the Go pattern:

  • BinanceCore - transpiled untyped class (internal, extends BinanceApi extends Exchange)
  • Binance - typed wrapper extending Core with typed overloads (user-facing)
// User-facing typed class (recommended)
Binance exchange = new Binance();
Ticker ticker = exchange.fetchTicker("BTC/USDT");       // returns Ticker
List<Trade> trades = exchange.fetchTrades("BTC/USDT");   // returns List<Trade>

// Exchange-specific implicit API methods are also accessible
Object raw = exchange.publicGetTicker24hr(params).join(); // Binance-specific endpoint

// Properties accessible directly
exchange.apiKey = "...";
exchange.secret = "...";

The typed methods use Java method overloading. They coexist safely with untyped methods because Java resolves overloads at compile time: BinanceCore.java is compiled without knowledge of Binance.java's typed overloads, so internal calls always bind to untyped varargs.

REST vs WebSocket

Feature REST API WebSocket API
Use for One-time queries, placing orders Real-time monitoring, live price feeds
Import io.github.ccxt.exchanges.Binance io.github.ccxt.exchanges.pro.Binance
Methods fetch* (fetchTicker, fetchOrderBook) watch* (watchTicker, watchOrderBook)
Returns Typed objects (Ticker, List<Trade>) CompletableFuture<Object> (call .join())
Speed Slower (HTTP request/response) Faster (persistent connection)
Rate limits Strict (1-2 req/sec) More lenient (continuous stream)
Best for Trading, account management Price monitoring, arbitrage detection

Creating Exchange Instance

REST API

import io.github.ccxt.exchanges.Binance;
import java.util.Map;
import java.util.HashMap;

// Public API (no authentication)
Binance exchange = new Binance();

// Private API (with authentication)
Map<String, Object> config = new HashMap<>();
config.put("apiKey", "YOUR_API_KEY");
config.put("secret", "YOUR_SECRET");
Binance exchange = new Binance(config);

WebSocket API

import io.github.ccxt.exchanges.pro.Binance;

// Public WebSocket
var exchange = new Binance();

// Private WebSocket (with authentication)
Map<String, Object> config = new HashMap<>();
config.put("apiKey", "YOUR_API_KEY");
config.put("secret", "YOUR_SECRET");
var exchange = new Binance(config);

Dynamic Instantiation (generic, untyped)

import io.github.ccxt.Exchange;

// Returns Exchange type - no typed methods, but works for any exchange
Exchange exchange = Exchange.dynamicallyCreateInstance("binance", config);
Object ticker = exchange.fetchTicker("BTC/USDT").join(); // untyped, returns CompletableFuture

Common REST Operations

Loading Markets

// Load all available trading pairs (typed)
Map<String, MarketInterface> markets = exchange.loadMarkets(false);

// Access market information
MarketInterface btcMarket = markets.get("BTC/USDT");
System.out.println(btcMarket.base);    // "BTC"
System.out.println(btcMarket.quote);   // "USDT"
System.out.println(btcMarket.active);  // true

Fetching Ticker

// Single ticker (typed)
Ticker ticker = exchange.fetchTicker("BTC/USDT");
System.out.println(ticker.last);      // Last price
System.out.println(ticker.bid);       // Best bid
System
Câu hỏi thường gặp

Cần phiên bản Java nào?

Skill nói cần Java 21 trở lên vì nó dùng virtual thread.

Thư viện được thêm vào dự án thế nào?

Skill có ví dụ cài đặt cho Gradle và Maven.

Lớp exchange có kiểu là gì?

Skill giải thích mỗi sàn có một lớp có kiểu riêng, giúp mã của bạn có kiểu trả về được đặt tên thay vì dữ liệu chung chung.

Chi tiết

Mô tả gốc của tác giả

CCXT cryptocurrency exchange library for Java developers. Covers both REST API (standard) and WebSocket API (real-time). Helps install CCXT, connect to exchanges, fetch market data, place orders, stream live tickers/orderbooks, handle authentication, and manage errors in Java projects. Use when working with crypto exchanges in Java applications, trading systems, or financial software. Requires Java 21+.

repo: ccxt/ccxt

Độ phổ biến

Sao GitHub
45k
Vị trí xếp hạng
#6382
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự