FTX exchange golang library
go get github.com/grishinsana/goftx
See examples directory and test cases for more examples
- Wallet
- Funding Payments
- Leveraged Tokens
- Options
- SRM Staking
package main
import (
"fmt"
"net/http"
"time"
"github.com/grishinsana/goftx"
)
func main() {
client := goftx.New(
goftx.WithAuth("API-KEY", "API-SECRET"),
goftx.WithHTTPClient(&http.Client{
Timeout: 5 * time.Second,
}),
)
info, err := client.Account.GetAccountInformation()
if err != nil {
panic(err)
}
fmt.Println(info)
}
package main
import (
"context"
"log"
"os"
"os/signal"
"syscall"
"time"
"github.com/grishinsana/goftx"
)
func main() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
ctx, cancel := context.WithCancel(context.Background())
client := goftx.New()
client.Stream.SetDebugMode(true)
data, err := client.Stream.SubscribeToTickers(ctx, "ETH/BTC")
if err != nil {
log.Fatalf("%+v", err)
}
go func() {
for {
select {
case <-ctx.Done():
return
case msg, ok := <-data:
if !ok {
return
}
log.Printf("%+v\n", msg)
}
}
}()
<-sigs
cancel()
time.Sleep(time.Second)
}
If you need to use FTX US than you could set goftx.WithFTXUS option
client := goftx.New(
goftx.WithFTXUS(),
)
If need, it is possible to set debug mode to look error and system messages in stream methods
client := goftx.New()
client.Stream.SetDebugMode(true)
"Not logged in" errors usually come from a wrong signatures. FTX released an article on how to authenticate https://blog.ftx.com/blog/api-authentication/
If you have unauthorized error to private methods, then you need to use SetServerTimeDiff()
ftx := New()
ftx.SetServerTimeDiff()