CCXT GO
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
NICE!!! By the way, will you be developing the WS next?
@chenenyu yes we but we don't have a release date yet.
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 I will check the best way of achieving this behavior and I will let you know.
@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 thanks for bringing your attention to this, yes will replace go get with go install as suggested.
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!
Please take a look. A problem occurred when the request id was entered hyperliquid
@Shinning888 Can you please open a new issue and post all the information there?
спасибо за golang
@gschurck I will check the best way of achieving this behavior and I will let you know.
Thanks, did you find a solution ? @carlosmiei
Eagerly hope to support websocket. 🚀
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!
Apex currently does not support create order in Go language
@Mr-XiaoLei correct apex right now is not supported in go
@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)
}
@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
Eagerly hope to support websocket. 🚀
https://github.com/ccxt/ccxt/pull/26440
v4.4.97 CostToPrecision, PriceToPrecision, AmountToPrecision undefined
v4.4.97 CostToPrecision, PriceToPrecision, AmountToPrecision undefined
What are you running to get that?
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
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.CreateExchangeexchange_typed_interface.gonot 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
Hi, will there be GOlang support for websocket?
Hi, will there be GOlang support for websocket?
https://github.com/ccxt/ccxt/pull/26440
@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
WOW!!! THANKS A LOT!
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 |