CCXT for Go

CCXT cryptocurrency exchange library for Go developers.

You say
Install this skill Read the source first Free Written by ccxt · unverified publisher
Context cost
7.3k tokensestimated from the bundle, loaded when it triggers
Bundle
1 file · 29.2 kBtext throughout, nothing executable
Licence
MITfree to use
Last change
no release on file
Servers it uses
Noneruns standalone

What it does

CCXT cryptocurrency exchange library for Go 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 Go projects. Use when working with crypto exchanges in Go applications, microservices, or trading systems.

Installed, it changes the agent in these ways.

What this skill changes about the agent is not written down here yet. The listing was collected from its source, and the description is in its own SKILL.md.

Workflow

Runs a procedure end to end.

api

The skill itself

This is the whole product. A skill is instructions the model reads, so there is nothing behind the listing you cannot see first — the front matter loads with every session, and the body below it loads when the skill triggers.

SKILL.md29.2 kB · 975 lines
--- name: ccxt-go description: CCXT cryptocurrency exchange library for Go 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 Go projects. Use when working with crypto exchanges in Go applications, microservices, or trading systems. ---
6# CCXT for Go
7
8A comprehensive guide to using CCXT in Go projects for cryptocurrency exchange integration.
9
10## Installation
11
12### REST API
13```bash
14go get github.com/ccxt/ccxt/go/v4
15```
16
17### WebSocket API (ccxt.pro)
18```bash
19go get github.com/ccxt/ccxt/go/v4/pro
20```
21
22## Quick Start
23
24### REST API
25```go
26package main
27
28import (
29 "fmt"
30 "github.com/ccxt/ccxt/go/v4/binance"
31)
32
33func main() {
34 exchange := binance.New()
35 markets, err := exchange.LoadMarkets()
36 if err != nil {
37 panic(err)
38 }
39
40 ticker, err := exchange.FetchTicker("BTC/USDT")
41 if err != nil {
42 panic(err)
43 }
44
45 fmt.Println(ticker)
46}
47```
48
49### WebSocket API - Real-time Updates
50```go
51package main
52
53import (
54 "fmt"
55 "github.com/ccxt/ccxt/go/v4/pro/binance"
56)
57
58func main() {
59 exchange := binance.New()
60 defer exchange.Close()
61
62 for {
63 ticker, err := exchange.WatchTicker("BTC/USDT")
64 if err != nil {
65 panic(err)
66 }
67 fmt.Println(ticker.Last) // Live updates!
68 }
69}
70```
71
72## REST vs WebSocket
73
74| Feature | REST API | WebSocket API |
75|---------|----------|---------------|
76| **Use for** | One-time queries, placing orders | Real-time monitoring, live price feeds |
77| **Import** | github.com/ccxt/ccxt/go/v4/{exchange} | github.com/ccxt/ccxt/go/v4/pro/{exchange} |
78| **Methods** | Fetch* (FetchTicker, FetchOrderBook) | Watch* (WatchTicker, WatchOrderBook) |
79| **Speed** | Slower (HTTP request/response) | Faster (persistent connection) |
80| **Rate limits** | Strict (1-2 req/sec) | More lenient (continuous stream) |
81| **Best for** | Trading, account management | Price monitoring, arbitrage detection |
82
83**Important:** All methods return (result, error) - always check errors!
84
85## Creating Exchange Instance
86
87### REST API
88```go
89import "github.com/ccxt/ccxt/go/v4/binance"
90
91// Public API (no authentication)
92exchange := binance.New()
93exchange.EnableRateLimit = true // Recommended!
94
95// Private API (with authentication)
96exchange := binance.New()
97exchange.ApiKey = "YOUR_API_KEY"
98exchange.Secret = "YOUR_SECRET"
99exchange.EnableRateLimit = true
100```
101
102### WebSocket API
103```go
104import "github.com/ccxt/ccxt/go/v4/pro/binance"
105
106// Public WebSocket
107exchange := binance.New()
108defer exchange.Close()
109
110// Private WebSocket (with authentication)
111exchange := binance.New()
112exchange.ApiKey = "YOUR_API_KEY"
113exchange.Secret = "YOUR_SECRET"
114defer exchange.Close()
115```
116
117## Common REST Operations
118
119### Loading Markets
120```go
121// Load all available trading pairs
122markets, err := exchange.LoadMarkets()
123if err != nil {
124 panic(err)
125}
126
127// Access market information
128btcMarket := exchange.Market("BTC/USDT")
129fmt.Println(btcMarket.Limits.Amount.Min) // Minimum order amount
130```
131
132### Fetching Ticker
133```go
134// Single ticker
135ticker, err := exchange.FetchTicker("BTC/USDT")
136if err != nil {
137 panic(err)
138}
139fmt.Println(ticker.Last) // Last price
140fmt.Println(ticker.Bid) // Best bid
141fmt.Println(ticker.Ask) // Best ask
142fmt.Println(ticker.Volume) // 24h volume
143
144// Multiple tickers (if supported)
145tickers, err := exchange.FetchTickers([]string{"BTC/USDT", "ETH/USDT"})
146```
147
148### Fetching Order Book
149```go
150// Full orderbook
151orderbook, err := exchange.FetchOrderBook("BTC/USDT", nil)
152if err != nil {
153 panic(err)
154}
155fmt.Println(orderbook.Bids[0]) // [price, amount]
156fmt.Println(orderbook.Asks[0]) // [price, amount]
157
158// Limited depth
159limit := 5
160orderbook, err := exchange.FetchOrderBook("BTC/USDT", &limit)
161```
162
163### Creating Orders
164
165#### Limit Order
166```go
167// Buy limit order
168order, err := exchange.CreateLimitBuyOrder("BTC/USDT", 0.01, 50000, nil)
169if err != nil {
170 panic(err)
171}
172fmt.Println(order.Id)
173
174// Sell limit order
175order, err := exchange.CreateLimitSellOrder("BTC/USDT", 0.01, 60000, nil)
176
177// Generic limit order
178order, err := exchange.CreateOrder("BTC/USDT", "limit", "buy", 0.01, 50000, nil)
179```
180
181#### Market Order
182```go
183// Buy market order
184order, err := exchange.CreateMarketBuyOrder("BTC/USDT", 0.01, nil)
185
186// Sell market order
187order, err := exchange.CreateMarketSellOrder("BTC/USDT", 0.01, nil)
188
189// Generic market order
190order, err := exchange.CreateOrder("BTC/USDT", "market", "sell", 0.01, nil, nil)
191```
192
193### Fetching Balance
194```go
195balance, err := exchange.FetchBalance()
196if err != nil {
197 panic(err)
198}
199fmt.Println(balance["BTC"].Free) // Available balance
200fmt.Println(balance["BTC"].Used) // Balance in orders
201fmt.Println(balance["BTC"].Total) // Total balance
202```
203
204### Fetching Orders
205```go
206// Open orders
207openOrders, err := exchange.FetchOpenOrders("BTC/USDT", nil, nil, nil)
208
209// Closed orders
210closedOrders, err := exchange.FetchClosedOrders("BTC/USDT", nil, nil, nil)
211
212// All orders (open + closed)
213allOrders, err := exchange.FetchOrders("BTC/USDT", nil, nil, nil)
214
215// Single order by ID
216order, err := exchange.FetchOrder(orderId, "BTC/USDT", nil)
217```
218
219### Fetching Trades
220```go
221// Recent public trades
222limit := 10
223trades, err := exchange.FetchTrades("BTC/USDT", nil, &limit, nil)
224
225// Your trades (requires authentication)
226myTrades, err := exchange.FetchMyTrades("BTC/USDT", nil, nil, nil)
227```
228
229### Canceling Orders
230```go
231// Cancel single order
232err := exchange.CancelOrder(orderId, "BTC/USDT", nil)
233
234// Cancel all orders for a symbol
235err := exchange.CancelAllOrders("BTC/USDT", nil)
236```
237
238## WebSocket Operations (Real-time)
239
240### Watching Ticker (Live Price Updates)
241```go
242import "github.com/ccxt/ccxt/go/v4/pro/binance"
243
244exchange := binance.New()
245defer exchange.Close()
246
247for {
248 ticker, err := exchange.WatchTicker("BTC/USDT")
249 if err != nil {
250 panic(err)
251 }
252 fmt.Println(ticker.Last, ticker.Timestamp)
253}
254```
255
256### Watching Order Book (Live Depth Updates)
257```go
258exchange := binance.New()
259defer exchange.Close()
260
261for {
262 orderbook, err := exchange.WatchOrderBook("BTC/USDT", nil)
263 if err != nil {
264 panic(err)
265 }
266 fmt.Println("Best bid:", orderbook.Bids[0])
267 fmt.Println("Best ask:", orderbook.Asks[0])
268}
269```
270
271### Watching Trades (Live Trade Stream)
272```go
273exchange := binance.New()
274defer exchange.Close()
275
276for {
277 trades, err := exchange.WatchTrades("BTC/USDT", nil, nil, nil)
278 if err != nil {
279 panic(err)
280 }
281 for _, trade := range trades {
282 fmt.Println(trade.Price, trade.Amount, trade.Side)
283 }
284}
285```
286
287### Watching Your Orders (Live Order Updates)
288```go
289exchange := binance.New()
290exchange.ApiKey = "YOUR_API_KEY"
291exchange.Secret = "YOUR_SECRET"
292defer exchange.Close()
293
294for {
295 orders, err := exchange.WatchOrders("BTC/USDT", nil, nil, nil)
296 if err != nil {
297 panic(err)
298 }
299 for _, order := range orders {
300 fmt.Println(order.Id, order.Status, order.Filled)
301 }
302}
303```
304
305### Watching Balance (Live Balance Updates)
306```go
307exchange := binance.New()
308exchange.ApiKey = "YOUR_API_KEY"
309exchange.Secret = "YOUR_SECRET"
310defer exchange.Close()
311
312for {
313 balance, err := exchange.WatchBalance()
314 if err != nil {
315 panic(err)
316 }
317 fmt.Println("BTC:", balance["BTC"])
318 fmt.Println("USDT:", balance["USDT"])
319}
320```
321
322## Complete Method Reference
323
324### Market Data Methods
325
326#### Tickers & Prices
327- fetchTicker(symbol) - Fetch ticker for one symbol
328- fetchTickers([symbols]) - Fetch multiple tickers at once
329- fetchBidsAsks([symbols]) - Fetch best bid/ask for multiple symbols
330- fetchLastPrices([symbols]) - Fetch last prices
331- fetchMarkPrices([symbols]) - Fetch mark prices (derivatives)
332
333#### Order Books
334- fetchOrderBook(symbol, limit) - Fetch order book
335- fetchOrderBooks([symbols]) - Fetch multiple order books
336- fetchL2OrderBook(symbol) - Fetch level 2 order book
337- fetchL3OrderBook(symbol) - Fetch level 3 order book (if supported)
338
339#### Trades
340- fetchTrades(symbol, since, limit) - Fetch public trades
341- fetchMyTrades(symbol, since, limit) - Fetch your trades (auth required)
342- fetchOrderTrades(orderId, symbol) - Fetch trades for specific order
343
344#### OHLCV (Candlesticks)
345- fetchOHLCV(symbol, timeframe, since, limit) - Fetch candlestick data
346- fetchIndexOHLCV(symbol, timeframe) - Fetch index price OHLCV
347- fetchMarkOHLCV(symbol, timeframe) - Fetch mark price OHLCV
348- fetchPremiumIndexOHLCV(symbol, timeframe) - Fetch premium index OHLCV
349
350### Account & Balance
351
352- fetchBalance() - Fetch account balance (auth required)
353- fetchAccounts() - Fetch sub-accounts
354- fetchLedger(code, since, limit) - Fetch ledger history
355- fetchLedgerEntry(id, code) - Fetch specific ledger entry
356- fetchTransactions(code, since, limit) - Fetch transactions
357- fetchDeposits(code, since, limit) - Fetch deposit history
358- fetchWithdrawals(code, since, limit) - Fetch withdrawal history
359- fetchDepositsWithdrawals(code, since, limit) - Fetch both deposits and withdrawals
360
361### Trading Methods
362
363#### Creating Orders
364- createOrder(symbol, type, side, amount, price, params) - Create order (generic)
365- createLimitOrder(symbol, side, amount, price) - Create limit order
366- createMarketOrder(symbol, side, amount) - Create market order
367- createLimitBuyOrder(symbol, amount, price) - Buy limit order
368- createLimitSellOrder(symbol, amount, price) - Sell limit order
369- createMarketBuyOrder(symbol, amount) - Buy market order
370- createMarketSellOrder(symbol, amount) - Sell market order
371- createMarketBuyOrderWithCost(symbol, cost) - Buy with specific cost
372- createStopLimitOrder(symbol, side, amount, price, stopPrice) - Stop-limit order
373- createStopMarketOrder(symbol, side, amount, stopPrice) - Stop-market order
374- createStopLossOrder(symbol, side, amount, stopPrice) - Stop-loss order
375- createTakeProfitOrder(symbol, side, amount, takeProfitPrice) - Take-profit order
376- createTrailingAmountOrder(symbol, side, amount, trailingAmount) - Trailing stop
377- createTrailingPercentOrder(symbol, side, amount, trailingPercent) - Trailing stop %
378- createTriggerOrder(symbol, side, amount, triggerPrice) - Trigger order
379- createPostOnlyOrder(symbol, side, amount, price) - Post-only order
380- createReduceOnlyOrder(symbol, side, amount, price) - Reduce-only order
381- createOrders([orders]) - Create multiple orders at once
382- createOrderWithTakeProfitAndStopLoss(symbol, type, side, amount, price, tpPrice, slPrice) - OCO order
383
384#### Managing Orders
385- fetchOrder(orderId, symbol) - Fetch single order
386- fetchOrders(symbol, since, limit) - Fetch all orders
387- fetchOpenOrders(symbol, since, limit) - Fetch open orders
388- fetchClosedOrders(symbol, since, limit) - Fetch closed orders
389- fetchCanceledOrders(symbol, since, limit) - Fetch canceled orders
390- fetchOpenOrder(orderId, symbol) - Fetch specific open order
391- fetchOrdersByStatus(status, symbol) - Fetch orders by status
392- cancelOrder(orderId, symbol) - Cancel single order
393- cancelOrders([orderIds], symbol) - Cancel multiple orders
394- cancelAllOrders(symbol) - Cancel all orders for symbol
395- editOrder(orderId, symbol, type, side, amount, price) - Modify order
396
397### Margin & Leverage
398
399- fetchBorrowRate(code) - Fetch borrow rate for margin
400- fetchBorrowRates([codes]) - Fetch multiple borrow rates
401- fetchBorrowRateHistory(code, since, limit) - Historical borrow rates
402- fetchCrossBorrowRate(code) - Cross margin borrow rate
403- fetchIsolatedBorrowRate(symbol, code) - Isolated margin borrow rate
404- borrowMargin(code, amount, symbol) - Borrow margin
405- repayMargin(code, amount, symbol) - Repay margin
406- fetchLeverage(symbol) - Fetch leverage
407- setLeverage(leverage, symbol) - Set leverage
408- fetchLeverageTiers(symbols) - Fetch leverage tiers
409- fetchMarketLeverageTiers(symbol) - Leverage tiers for market
410- setMarginMode(marginMode, symbol) - Set margin mode (cross/isolated)
411- fetchMarginMode(symbol) - Fetch margin mode
412
413### Derivatives & Futures
414
415#### Positions
416- fetchPosition(symbol) - Fetch single position
417- fetchPositions([symbols]) - Fetch all positions
418- fetchPositionsForSymbol(symbol) - Fetch positions for symbol
419- fetchPositionHistory(symbol, since, limit) - Position history
420- fetchPositionsHistory(symbols, since, limit) - Multiple position history
421- fetchPositionMode(symbol) - Fetch position mode (one-way/hedge)
422- setPositionMode(hedged, symbol) - Set position mode
423- closePosition(symbol, side) - Close position
424- closeAllPositions() - Close all positions
425
426#### Funding & Settlement
427- fetchFundingRate(symbol) - Current funding rate
428- fetchFundingRates([symbols]) - Multiple funding rates
429- fetchFundingRateHistory(symbol, since, limit) - Funding rate history
430- fetchFundingHistory(symbol, since, limit) - Your funding payments
431- fetchFundingInterval(symbol) - Funding interval
432- fetchSettlementHistory(symbol, since, limit) - Settlement history
433- fetchMySettlementHistory(symbol, since, limit) - Your settlement history
434
435#### Open Interest & Liquidations
436- fetchOpenInterest(symbol) - Open interest for symbol
437- fetchOpenInterests([symbols]) - Multiple open interests
438- fetchOpenInterestHistory(symbol, timeframe, since, limit) - OI history
439- fetchLiquidations(symbol, since, limit) - Public liquidations
440- fetchMyLiquidations(symbol, since, limit) - Your liquidations
441
442#### Options
443- fetchOption(symbol) - Fetch option info
444- fetchOptionChain(code) - Fetch option chain
445- fetchGreeks(symbol) - Fetch option greeks
446- fetchVolatilityHistory(code, since, limit) - Volatility history
447- fetchUnderlyingAssets() - Fetch underlying assets
448
449### Fees & Limits
450
451- fetchTradingFee(symbol) - Trading fee for symbol
452- fetchTradingFees([symbols]) - Trading fees for multiple symbols
453- fetchTradingLimits([symbols]) - Trading limits
454- fetchTransactionFee(code) - Transaction/withdrawal fee
455- fetchTransactionFees([codes]) - Multiple transaction fees
456- fetchDepositWithdrawFee(code) - Deposit/withdrawal fee
457- fetchDepositWithdrawFees([codes]) - Multiple deposit/withdraw fees
458
459### Deposits & Withdrawals
460
461- fetchDepositAddress(code, params) - Get deposit address
462- fetchDepositAddresses([codes]) - Multiple deposit addresses
463- fetchDepositAddressesByNetwork(code) - Addresses by network
464- createDepositAddress(code, params) - Create new deposit address
465- fetchDeposit(id, code) - Fetch single deposit
466- fetchWithdrawal(id, code) - Fetch single withdrawal
467- fetchWithdrawAddresses(code) - Fetch withdrawal addresses
468- fetchWithdrawalWhitelist(code) - Fetch whitelist
469- withdraw(code, amount, address, tag, params) - Withdraw funds
470- deposit(code, amount, params) - Deposit funds (if supported)
471
472### Transfer & Convert
473
474- transfer(code, amount, fromAccount, toAccount) - Internal transfer
475- fetchTransfer(id, code) - Fetch transfer info
476- fetchTransfers(code, since, limit) - Fetch transfer history
477- fetchConvertCurrencies() - Currencies available for convert
478- fetchConvertQuote(fromCode, toCode, amount) - Get conversion quote
479- createConvertTrade(fromCode, toCode, amount) - Execute conversion
480- fetchConvertTrade(id) - Fetch convert trade
481- fetchConvertTradeHistory(code, since, limit) - Convert history
482
483### Market Info
484
485- fetchMarkets() - Fetch all markets
486- fetchCurrencies() - Fetch all currencies
487- fetchTime() - Fetch exchange server time
488- fetchStatus() - Fetch exchange status
489- fetchBorrowInterest(code, symbol, since, limit) - Borrow interest paid
490- fetchLongShortRatio(symbol, timeframe, since, limit) - Long/short ratio
491- fetchLongShortRatioHistory(symbol, timeframe, since, limit) - L/S ratio history
492
493### WebSocket Methods (ccxt.pro)
494
495All REST methods have WebSocket equivalents with watch* prefix:
496
497#### Real-time Market Data
498- watchTicker(symbol) - Watch single ticker
499- watchTickers([symbols]) - Watch multiple tickers
500- watchOrderBook(symbol) - Watch order book updates
501- watchOrderBookForSymbols([symbols]) - Watch multiple order books
502- watchTrades(symbol) - Watch public trades
503- watchOHLCV(symbol, timeframe) - Watch candlestick updates
504- watchBidsAsks([symbols]) - Watch best bid/ask
505
506#### Real-time Account Data (Auth Required)
507- watchBalance() - Watch balance updates
508- watchOrders(symbol) - Watch your order updates
509- watchMyTrades(symbol) - Watch your trade updates
510- watchPositions([symbols]) - Watch position updates
511- watchPositionsForSymbol(symbol) - Watch positions for symbol
512
513### Authentication Required
514
515Methods marked with 🔒 require API credentials:
516
517- All create* methods (creating orders, addresses)
518- All cancel* methods (canceling orders)
519- All edit* methods (modifying orders)
520- All fetchMy* methods (your trades, orders)
521- fetchBalance, fetchLedger, fetchAccounts
522- withdraw, transfer, deposit
523- Margin/leverage methods
524- Position methods
525- watchBalance, watchOrders, watchMyTrades, watchPositions
526
527### Checking Method Availability
528
529Not all exchanges support all methods. Check before using:
530
531```
532// Check if method is supported
533if (exchange.has['fetchOHLCV']) {
534 const candles = await exchange.fetchOHLCV('BTC/USDT', '1h')
535}
536
537// Check multiple capabilities
538console.log(exchange.has)
539// {
540// fetchTicker: true,
541// fetchOHLCV: true,
542// fetchMyTrades: true,
543// fetchPositions: false,
544// ...
545// }
546```
547
548### Method Naming Convention
549
550- fetch* - REST API methods (HTTP requests)
551- watch* - WebSocket methods (real-time streams)
552- create* - Create new resources (orders, addresses)
553- cancel* - Cancel existing resources
554- edit* - Modify existing resources
555- set* - Configure settings (leverage, margin mode)
556- *Ws suffix - WebSocket variant (some exchanges)
557
558
559
560## Proxy Configuration
561
562CCXT supports HTTP, HTTPS, and SOCKS proxies for both REST and WebSocket connections.
563
564### Setting Proxy
565
566```
567// HTTP Proxy
568exchange.httpProxy = 'http://your-proxy-host:port'
569
570// HTTPS Proxy
571exchange.httpsProxy = 'https://your-proxy-host:port'
572
573// SOCKS Proxy
574exchange.socksProxy = 'socks://your-proxy-host:port'
575
576// Proxy with authentication
577exchange.httpProxy = 'http://user:pass@proxy-host:port'
578```
579
580### Proxy for WebSocket
581
582WebSocket connections also respect proxy settings:
583
584```
585exchange.httpsProxy = 'https://proxy:8080'
586// WebSocket connections will use this proxy
587```
588
589### Testing Proxy Connection
590
591```
592exchange.httpProxy = 'http://localhost:8080'
593try {
594 await exchange.fetchTicker('BTC/USDT')
595 console.log('Proxy working!')
596} catch (error) {
597 console.error('Proxy connection failed:', error)
598}
599```
600
601## WebSocket-Specific Methods
602
603Some exchanges provide WebSocket variants of REST methods for faster order placement and management. These use the *Ws suffix:
604
605### Trading via WebSocket
606
607**Creating Orders:**
608- createOrderWs - Create order via WebSocket (faster than REST)
609- createLimitOrderWs - Create limit order via WebSocket
610- createMarketOrderWs - Create market order via WebSocket
611- createLimitBuyOrderWs - Buy limit order via WebSocket
612- createLimitSellOrderWs - Sell limit order via WebSocket
613- createMarketBuyOrderWs - Buy market order via WebSocket
614- createMarketSellOrderWs - Sell market order via WebSocket
615- createStopLimitOrderWs - Stop-limit order via WebSocket
616- createStopMarketOrderWs - Stop-market order via WebSocket
617- createStopLossOrderWs - Stop-loss order via WebSocket
618- createTakeProfitOrderWs - Take-profit order via WebSocket
619- createTrailingAmountOrderWs - Trailing stop via WebSocket
620- createTrailingPercentOrderWs - Trailing stop % via WebSocket
621- createPostOnlyOrderWs - Post-only order via WebSocket
622- createReduceOnlyOrderWs - Reduce-only order via WebSocket
623
624**Managing Orders:**
625- editOrderWs - Edit order via WebSocket
626- cancelOrderWs - Cancel order via WebSocket (faster than REST)
627- cancelOrdersWs - Cancel multiple orders via WebSocket
628- cancelAllOrdersWs - Cancel all orders via WebSocket
629
630**Fetching Data:**
631- fetchOrderWs - Fetch order via WebSocket
632- fetchOrdersWs - Fetch orders via WebSocket
633- fetchOpenOrdersWs - Fetch open orders via WebSocket
634- fetchClosedOrdersWs - Fetch closed orders via WebSocket
635- fetchMyTradesWs - Fetch your trades via WebSocket
636- fetchBalanceWs - Fetch balance via WebSocket
637- fetchPositionWs - Fetch position via WebSocket
638- fetchPositionsWs - Fetch positions via WebSocket
639- fetchPositionsForSymbolWs - Fetch positions for symbol via WebSocket
640- fetchTradingFeesWs - Fetch trading fees via WebSocket
641
642### When to Use WebSocket Methods
643
644**Use *Ws methods when:**
645- You need faster order placement (lower latency)
646- You're already connected via WebSocket
647- You want to reduce REST API rate limit usage
648- Trading strategies require sub-100ms latency
649
650**Use REST methods when:**
651- You need guaranteed execution confirmation
652- You're making one-off requests
653- The exchange doesn't support the WebSocket variant
654- You need detailed error responses
655
656### Example: Order Placement Comparison
657
658**REST API (slower, more reliable):**
659```
660const order = await exchange.createOrder('BTC/USDT', 'limit', 'buy', 0.01, 50000)
661```
662
663**WebSocket API (faster, lower latency):**
664```
665const order = await exchange.createOrderWs('BTC/USDT', 'limit', 'buy', 0.01, 50000)
666```
667
668### Checking WebSocket Method Availability
669
670Not all exchanges support WebSocket trading methods:
671
672```
673if (exchange.has['createOrderWs']) {
674 // Exchange supports WebSocket order creation
675 const order = await exchange.createOrderWs('BTC/USDT', 'limit', 'buy', 0.01, 50000)
676} else {
677 // Fall back to REST
678 const order = await exchange.createOrder('BTC/USDT', 'limit', 'buy', 0.01, 50000)
679}
680```
681
682
683## Authentication
684
685### Setting API Keys
686
687```go
688import "os"
689
690// During instantiation
691exchange := binance.New()
692exchange.ApiKey = os.Getenv("BINANCE_API_KEY")
693exchange.Secret = os.Getenv("BINANCE_SECRET")
694exchange.EnableRateLimit = true
695```
696
697### Testing Authentication
698```go
699balance, err := exchange.FetchBalance()
700if err != nil {
701 if _, ok := err.(*ccxt.AuthenticationError); ok {
702 fmt.Println("Invalid API credentials")
703 } else {
704 panic(err)
705 }
706} else {
707 fmt.Println("Authentication successful!")
708}
709```
710
711## Error Handling
712
713### Error Types
714```
715BaseError
716├─ NetworkError (recoverable - retry)
717│ ├─ RequestTimeout
718│ ├─ ExchangeNotAvailable
719│ ├─ RateLimitExceeded
720│ └─ DDoSProtection
721└─ ExchangeError (non-recoverable - don't retry)
722 ├─ AuthenticationError
723 ├─ InsufficientFunds
724 ├─ InvalidOrder
725 └─ NotSupported
726```
727
728### Basic Error Handling
729```go
730import "github.com/ccxt/ccxt/go/v4/ccxt"
731
732ticker, err := exchange.FetchTicker("BTC/USDT")
733if err != nil {
734 switch e := err.(type) {
735 case *ccxt.NetworkError:
736 fmt.Println("Network error - retry:", e.Message)
737 case *ccxt.ExchangeError:
738 fmt.Println("Exchange error - do not retry:", e.Message)
739 default:
740 fmt.Println("Unknown error:", err)
741 }
742}
743```
744
745### Specific Error Handling
746```go
747order, err := exchange.CreateOrder("BTC/USDT", "limit", "buy", 0.01, 50000, nil)
748if err != nil {
749 switch err.(type) {
750 case *ccxt.InsufficientFunds:
751 fmt.Println("Not enough balance")
752 case *ccxt.InvalidOrder:
753 fmt.Println("Invalid order parameters")
754 case *ccxt.RateLimitExceeded:
755 fmt.Println("Rate limit hit - wait before retrying")
756 time.Sleep(1 * time.Second)
757 case *ccxt.AuthenticationError:
758 fmt.Println("Check your API credentials")
759 default:
760 panic(err)
761 }
762}
763```
764
765### Retry Logic for Network Errors
766```go
767import "time"
768
769func fetchWithRetry(exchange *binance.Exchange, maxRetries int) (*ccxt.Ticker, error) {
770 for i := 0; i < maxRetries; i++ {
771 ticker, err := exchange.FetchTicker("BTC/USDT")
772 if err == nil {
773 return ticker, nil
774 }
775
776 if _, ok := err.(*ccxt.NetworkError); ok && i < maxRetries-1 {
777 fmt.Printf("Retry %d/%d\n", i+1, maxRetries)
778 time.Sleep(time.Duration(i+1) * time.Second) // Exponential backoff
779 } else {
780 return nil, err
781 }
782 }
783 return nil, fmt.Errorf("all retries failed")
784}
785```
786
787## Rate Limiting
788
789### Built-in Rate Limiter (Recommended)
790```go
791exchange := binance.New()
792exchange.EnableRateLimit = true // Automatically throttles requests
793```
794
795### Manual Delays
796```go
797import "time"
798
799exchange.FetchTicker("BTC/USDT")
800time.Sleep(time.Duration(exchange.RateLimit) * time.Millisecond)
801exchange.FetchTicker("ETH/USDT")
802```
803
804### Checking Rate Limit
805```go
806fmt.Println(exchange.RateLimit) // Milliseconds between requests
807```
808
809## Common Pitfalls
810
811### Not Checking Error Returns
812```go
813// Wrong - ignores errors
814ticker, _ := exchange.FetchTicker("BTC/USDT")
815fmt.Println(ticker.Last) // May panic if ticker is nil!
816
817// Correct - check errors
818ticker, err := exchange.FetchTicker("BTC/USDT")
819if err != nil {
820 panic(err)
821}
822fmt.Println(ticker.Last)
823```
824
825### Wrong Import Path
826```go
827// Wrong - missing /v4
828import "github.com/ccxt/ccxt/go/binance" // ERROR!
829
830// Correct - must include /v4
831import "github.com/ccxt/ccxt/go/v4/binance"
832
833// Correct - WebSocket with /v4/pro
834import "github.com/ccxt/ccxt/go/v4/pro/binance"
835```
836
837### Using REST for Real-time Monitoring
838```go
839// Wrong - wastes rate limits
840for {
841 ticker, _ := exchange.FetchTicker("BTC/USDT") // REST
842 fmt.Println(ticker.Last)
843 time.Sleep(1 * time.Second)
844}
845
846// Correct - use WebSocket
847import "github.com/ccxt/ccxt/go/v4/pro/binance"
848
849exchange := binance.New()
850defer exchange.Close()
851
852for {
853 ticker, err := exchange.WatchTicker("BTC/USDT") // WebSocket
854 if err != nil {
855 panic(err)
856 }
857 fmt.Println(ticker.Last)
858}
859```
860
861### Not Closing WebSocket Connections
862```go
863// Wrong - memory leak
864exchange := binance.New()
865ticker, _ := exchange.WatchTicker("BTC/USDT")
866// Forgot to close!
867
868// Correct - always defer Close()
869exchange := binance.New()
870defer exchange.Close()
871
872for {
873 ticker, err := exchange.WatchTicker("BTC/USDT")
874 if err != nil {
875 break
876 }
877 fmt.Println(ticker.Last)
878}
879```
880
881### Incorrect Symbol Format
882```go
883// Wrong symbol formats
884"BTCUSDT" // Wrong - no separator
885"BTC-USDT" // Wrong - dash separator
886"btc/usdt" // Wrong - lowercase
887
888// Correct symbol format
889"BTC/USDT" // Unified CCXT format
890```
891
892## Troubleshooting
893
894### Common Issues
895
896**1. "package github.com/ccxt/ccxt/go/v4/binance: cannot find package"**
897- Solution: Run go get github.com/ccxt/ccxt/go/v4
898
899**2. "RateLimitExceeded"**
900- Solution: Set exchange.EnableRateLimit = true
901
902**3. "AuthenticationError"**
903- Solution: Check API key and secret
904- Verify API key permissions on exchange
905- Check system clock is synced
906
907**4. "InvalidNonce"**
908- Solution: Sync system clock
909- Use only one exchange instance per API key
910
911**5. "InsufficientFunds"**
912- Solution: Check available balance (balance["BTC"].Free)
913- Account for trading fees
914
915**6. "ExchangeNotAvailable"**
916- Solution: Check exchange status/maintenance
917- Retry after a delay
918
919### Debugging
920
921```go
922// Enable verbose logging
923exchange.Verbose = true
924
925// Check exchange capabilities
926fmt.Println(exchange.Has)
927// map[string]bool{
928// "fetchTicker": true,
929// "fetchOrderBook": true,
930// "createOrder": true,
931// ...
932// }
933
934// Check market information
935market := exchange.Markets["BTC/USDT"]
936fmt.Println(market)
937
938// Check last request/response
939fmt.Println(exchange.LastHttpResponse)
940fmt.Println(exchange.LastJsonResponse)
941```
942
943## Prediction Markets
944
945CCXT supports prediction-market exchanges (Polymarket, Kalshi, Limitless, Myriad, Hyperliquid) in a dedicated go/v4/prediction package. They use the same unified API, but prices are quoted **0–1** (USDC per outcome share) and the tradeable unit is an **outcome** (e.g. a market's YES/NO token), not a regular market symbol.
946
947```go
948import (
949 ccxt "github.com/ccxt/ccxt/go/v4"
950 ccxtprediction "github.com/ccxt/ccxt/go/v4/prediction"
951)
952
953ex := ccxtprediction.NewPolymarket(map[string]interface{}{})
954ex.LoadMarkets() // outcomes load automatically (outcome handle, outcomeId, market, label)
955// an outcome handle looks like 'TRUMP_OUT_PRESIDENT_2027:YES'
956handle := "TRUMP_OUT_PRESIDENT_2027:YES"
957ticker, _ := ex.FetchTicker(handle)
958book, _ := ex.FetchOrderBook(handle)
959// limit buy 5 YES shares @ 0.40 USDC (price is 0..1 per share)
960order, err := ex.CreateOrder(handle, "limit", "buy", 5, ccxt.WithCreateOrderPrice(0.40))
961if err == nil {
962 ex.CancelOrder(*order.Id, ccxtprediction.WithCancelOrderOutcome(handle))
963}
964```
965
966- Price/trade methods (FetchTicker, FetchOrderBook, FetchOHLCV, FetchTrades, CreateOrder, CancelOrder, …) take an **outcome handle or outcomeId** — passed positionally or via the With…Outcome / With…Outcomes option, not a market symbol.
967- Discover markets via FetchEvents / FetchEvent (or LoadMarkets).
968
969## Learn More
970
971- [CCXT Manual](https://docs.ccxt.com/)
972- [CCXT Pro Documentation](https://docs.ccxt.com/en/latest/ccxt.pro.html)
973- [Supported Exchanges](https://github.com/ccxt/ccxt#supported-cryptocurrency-exchange-markets)
974- [GitHub Repository](https://github.com/ccxt/ccxt)
975
In the file
SKILL.md3,488 words
Files1
LicenceMIT
Why you can read it

Nothing in a skill executes. The client loads the text and the model follows it, so a skill can be audited the way a runbook is — by reading it.

What it costs in context

Skills are not billed by the call. They are paid for in context: every token the instructions occupy is a token your code, your diff and your conversation cannot use. Here is what this one takes and when it takes it.

≈100
always loaded
The name and description, so the model knows the skill exists and when to reach for it.
7,200
on trigger
The instruction body, read only when the skill fires.
3.6%
of a 200k window
Ten skills this size would take about 37% of the window before you open a file.
050k100k150k200k context window

7.3k tokens, estimated from the bundle at four bytes to the token, held for the rest of the session once it triggers. Heavy. Teams tend to install this one per project rather than globally, and load it only when the job comes up.

Servers bill, skills cost

A server charges by the month. A skill charges once per session, in context, and then keeps charging it for as long as the session lives.

Before and after

The same question, put to the same model twice: once as it comes, and once with these instructions loaded.

No worked example has been published for this skill yet.

Adoption
Installsnone yet
Ratingno reviews yet

The procedure it runs

The procedure has not been published here. It is in the skill’s own SKILL.md, which its author has not sent to the marketplace yet.

Prose, not code

These steps are written for a model to follow, not executed by a runtime. It can still be told to skip one, and it will say so when it does.

Servers it uses

None. This skill calls no MCP servers at all.

Everything it needs is in the instructions, so it works in a project with nothing connected — the model reads the file and changes how it works with what it can already reach.

It writes no files and reaches no network. All it changes is how the model reasons and writes.

What it asks for
Writes filesno
Network accessno

Read from the allowed-tools line of this skill’s own SKILL.md. A skill grants no permissions of its own — it can only ask for tools your client already has.

What it will not do

Every skill is narrow, and the useful ones say where they stop. These are the jobs this one is the wrong tool for.

What this skill is not for has not been published here. Nothing is implied by that: it is a section the author has not filled in.

What is in the bundle

1 file, 29.2 kB on disk. A bundle is text throughout: the instructions the model reads, plus the templates it fills in.

  • SKILL.md29.2 kB
What is not in it

No dependencies and nothing executable: a skill is text the agent reads, so the bundle is 1 file you can review in full before installing. The MIT licence covers the templates and examples as well as the instructions.

Install

Installing copies the bundle into your project. Nothing runs at install time — the files sit on disk until the model reads them.

# CCXT for Go · 7.3k tokens when loaded npx mcprush@latest skill add ccxt/ccxt-for-go

Writes to .claude/skills/ccxt-for-go/ in the current project. Add --global to put it in your home directory instead, for every project.

Which clients pick it up on their own

A skill is a folder of text. A client with a skills folder reads it without being told; everywhere else the same text works, it is just handed to the model rather than found.

Claude Code.claude/skills/
Claude Desktop
ChatGPT
Cursor.cursor/skills/
VS Code.github/skills/
Codex CLI.agents/skills/
Gemini CLI.gemini/skills/
Grok.grok/skills/
Zed.agents/skills/
Windsurf.windsurf/skills/
Agent SDK.claude/skills/
HTTP / API
This release
Versionnot versioned
Publishedno release date on file
PriceFree
Referenceccxt/ccxt-for-go

Versions

Its author publishes no version number, so there is nothing here to pin to: what you install is the folder as it stands today. Instructions change more often than APIs do — a skill can be rewritten entirely without anything it depends on moving.

v
  • No earlier releases have been published to the marketplace.
Pinning

Nothing to pin to: this skill carries no version number of its own. What you install is what the folder holds on the day you install it.

Reviews

no reviews yet · no installs yet

Nobody has reviewed this skill yet. The rating is the mean of the reviews written here, so there is none until somebody writes the first.

Who can post

Only accounts that have had the skill installed for fourteen days, so a review is written after living with it rather than after reading it. Publishers may reply once.

Who wrote it

CC
ccxt

Publishes on mcprush.

0 servers listed1 skill listednot claimed
Profile
Publisher
Servers0
Claim this skill