ccxt icon indicating copy to clipboard operation
ccxt copied to clipboard

CCXT GO

Open carlosmiei opened this issue 11 months ago • 16 comments

Hello, CCXT community!

We're excited to announce that we publicly released the GO version of CCXT (for now, only Rest capabilities). It works very similarly to the other languages.

You can check the package here: https://pkg.go.dev/github.com/ccxt/ccxt/go/v4

Install go install github.com/ccxt/ccxt/go/v4@latest

Examples

package main
import (
	"github.com/ccxt/ccxt/go/v4"
	"fmt"
)

func main() {
	exchange := ccxt.NewBinance(map[string]interface{}{
		"apiKey": "MY KEY",
		"secret": "MY SECRET",
	})
	orderParams := map[string]interface{}{
		"clientOrderId": "myOrderId68768678",
	}

    <-exchange.LoadMarkets() // not required, but you can pre-load the markets

	order, err := exchange.CreateOrder("BTC/USDT", "limit", "buy", 0.001, ccxt.WithCreateOrderPrice(6000), ccxt.WithCreateOrderParams(orderParams))
	if err != nil {
		if ccxtError, ok := err.(*ccxt.Error); ok {
			if ccxtError.Type == "InvalidOrder" {
				fmt.Println("Invalid order")
			} else {
				fmt.Println("Some other error")
			}
		}
	} else {
		fmt.Println(*order.Id)
	}
}

You can check some examples here: https://github.com/ccxt/ccxt/tree/master/examples/go/

Thank you for using CCXT!

Yours, the CCXT Dev Team

Discord Telegram Telegram Twitter Follow

carlosmiei avatar Feb 03 '25 21:02 carlosmiei

NICE!!! By the way, will you be developing the WS next?

chenenyu avatar Feb 05 '25 07:02 chenenyu

@chenenyu yes we but we don't have a release date yet.

carlosmiei avatar Feb 05 '25 09:02 carlosmiei

Good job ! Is it possible to create an exchange instance dynamically from its name like in Python ?

exchanges = {}

for id in ccxt.exchanges:
   exchange = getattr(ccxt, id)
   exchanges[id] = exchange()

gschurck avatar Mar 02 '25 12:03 gschurck

@gschurck I will check the best way of achieving this behavior and I will let you know.

carlosmiei avatar Mar 02 '25 12:03 carlosmiei

@carlosmiei Good News that ccxt will have a Go version. Expecting better overall performance in a compiled language.

I would like to suggest an update to the go command for "INSTALL" in initial post. FROM: go get github.com/ccxt/ccxt/go/v4 TO..: go install github.com/ccxt/ccxt/go/v4@latest

The reason is that 'go get' is DEPRECATED for for installing executables since GO 1.17. Current stable GO version is 1.24.1. Reference: "Starting in Go 1.17, installing executables with go get is deprecated. go install may be used instead." And 'go install' may require package ccxt version information (@latest). https://go.dev/doc/go-get-install-deprecation.

csotto avatar Mar 07 '25 01:03 csotto

@csotto thanks for bringing your attention to this, yes will replace go get with go install as suggested.

carlosmiei avatar Mar 07 '25 10:03 carlosmiei

Congratulations on the release of the Go version of CCXT! This is a great addition to the Go ecosystem and provides developers with a new way to integrate trading functionalities. I’m looking forward to future developments, especially the addition of WebSocket capabilities. Thanks to the entire development team for your hard work!

bentrnr21 avatar Mar 07 '25 19:03 bentrnr21

Please take a look. A problem occurred when the request id was entered hyperliquid

Shinning888 avatar Mar 11 '25 15:03 Shinning888

Image

Shinning888 avatar Mar 11 '25 15:03 Shinning888

@Shinning888 Can you please open a new issue and post all the information there?

carlosmiei avatar Mar 11 '25 16:03 carlosmiei

спасибо за golang

suenot avatar Mar 14 '25 22:03 suenot

@gschurck I will check the best way of achieving this behavior and I will let you know.

Thanks, did you find a solution ? @carlosmiei

gschurck avatar Mar 15 '25 22:03 gschurck

Eagerly hope to support websocket. 🚀

chenenyu avatar Mar 26 '25 07:03 chenenyu

Amazing! I bet a lot of devs were expecting this hehe. I was building my own endpoints using Golang, but with that, it will speed up a lot the development proccess. Thank you!

douglaspetrin avatar Mar 27 '25 14:03 douglaspetrin

Apex currently does not support create order in Go language

Mr-XiaoLei avatar May 06 '25 22:05 Mr-XiaoLei

@Mr-XiaoLei correct apex right now is not supported in go

carlosmiei avatar May 07 '25 08:05 carlosmiei

@gschurck Now you can do this:

 exchanges := []string{"binance", "bybit", "okx"}
	symbol := "BTC/USDT"
	for _, exchangeName := range exchanges {
		exchange := ccxt.CreateExchange(exchangeName, nil)

		ticker, _ := exchange.FetchTicker(symbol)
		fmt.Println("Ticker for", exchangeName, ":", ticker.Last)
	}

carlosmiei avatar Jul 24 '25 08:07 carlosmiei

@gschurck Now you can do this:

 exchanges := []string{"binance", "bybit", "okx"}
	symbol := "BTC/USDT"
	for _, exchangeName := range exchanges {
		exchange := ccxt.CreateExchange(exchangeName, nil)

		ticker, _ := exchange.FetchTicker(symbol)
		fmt.Println("Ticker for", exchangeName, ":", ticker.Last)
	}

Nice thank you

gschurck avatar Jul 24 '25 11:07 gschurck

Eagerly hope to support websocket. 🚀

https://github.com/ccxt/ccxt/pull/26440

caoilainnl avatar Jul 24 '25 11:07 caoilainnl

v4.4.97 CostToPrecision, PriceToPrecision, AmountToPrecision undefined

anbuhckr avatar Jul 31 '25 07:07 anbuhckr

v4.4.97 CostToPrecision, PriceToPrecision, AmountToPrecision undefined

What are you running to get that?

caoilainnl avatar Jul 31 '25 07:07 caoilainnl

v4.4.97 CostToPrecision, PriceToPrecision, AmountToPrecision undefined

What are you running to get that?

exchanges := []string{"binance", "bybit", "okx"}
symbol := "BTC/USDT"
for _, exchangeName := range exchanges {
	exchange := ccxt.CreateExchange(exchangeName, nil)
	exchange.CostToPrecision(symbol, 10)
}

SetLeverage is not available for ccxt.CreateExchange exchange_typed_interface.go not have SetLeverage

anbuhckr avatar Jul 31 '25 08:07 anbuhckr

v4.4.97 CostToPrecision, PriceToPrecision, AmountToPrecision undefined

What are you running to get that?

exchanges := []string{"binance", "bybit", "okx"} symbol := "BTC/USDT" for _, exchangeName := range exchanges { exchange := ccxt.CreateExchange(exchangeName, nil) exchange.CostToPrecision(symbol, 10) }

SetLeverage is not available for ccxt.CreateExchange exchange_typed_interface.go not have SetLeverage

I added those methods to this PR, I don't know if it will ever get merged though, you can try using DecimalToPrecision, because AmountToPrecision, CostToPrecision, ... are just wrappers that implement DecimalToPrecision

caoilainnl avatar Jul 31 '25 10:07 caoilainnl

Hi, will there be GOlang support for websocket?

hekman316 avatar Sep 15 '25 01:09 hekman316

Hi, will there be GOlang support for websocket?

https://github.com/ccxt/ccxt/pull/26440

caoilainnl avatar Sep 15 '25 09:09 caoilainnl

@hekman316 @chenenyu

Thanks to the help of @caoilainnl, we have released websockets support 🥳

https://discord.com/channels/690203284119617602/1057748769690619984/1426243633916674210 https://t.me/ccxt_announcements/93

carlosmiei avatar Oct 10 '25 16:10 carlosmiei

WOW!!! THANKS A LOT!

suenot avatar Oct 10 '25 19:10 suenot

WOW!!! THANKS A LOT!

Hey my pleasure! If you would REALLY like to thank me

Network Address TAG
BTC 1N3kZ6sGucyrBMczRDwFWbqrow4cdFsHyA
ETH 0x0cceb75463da5051c80f775a0519df1abcc58291
ARBITRUM ONE 0x0cceb75463da5051c80f775a0519df1abcc58291
POLYGON 0x0cceb75463da5051c80f775a0519df1abcc58291
SOL 2J83WkTaxB7nfa6QAmt84di4127AWRkLgk9nniYKUkhH
LTC LcvA7hVE554RCxnV48HxxCy4DHRbRUTnkV
ADA Ae2tdPwUPEZ9EkSSErYEC2kRMQzCUJyV5iCSQJZLrgxBtreDqwrVHnhZEHa
ALGO FHJ27NPNS4EUU4NQTPQPIS6KJHHJUUVXL5CDYINVYHBCYXDNH3XZKR7XWI
XLM GBD6CUO335LQMOIZ53CE3L6QJ3X3DAQVC7F5TWE2BKI7AQWTHDUHFNJ4 420977839
XRP rGDreBvnHrX1get7na3J4oowN19ny4GzFn 878263644
AVAX C-Chain 0x0cceb75463da5051c80f775a0519df1abcc58291
AVAX X-Chain X-avax1320gzukyp3nfm5hssn57k2ttd5fqete7893t22
NEAR 61d9a73d4a3cae5181c2a17286c36fb0f11b1b76c28d2981b6e063b695d05cf4
TON UQAW9M6LqubkCTHCP-80AqUHBt84fS1r-ka6TOxQUmumreo_
DOT 1k5ruzuYo6YvsrBpALMEKq6VJM8NtoipSwsehnvqF5XfjuR

caoilainnl avatar Oct 12 '25 00:10 caoilainnl