Skip to content

astaluego/golang-kraken

Repository files navigation

golang-kraken

Golang client for the Kraken API.

Getting Started

Installing

go get github.com/astaluego/golang-kraken

Quick start

package main

import (
    "fmt"
    kraken "github.com/astaluego/golang-kraken"
)

func main() {
    client := kraken.New()
    client.SetTimezone("UTC") // optional, configures the localization for time.Time Objects

    // Public calls
    time, err := client.ServerTime()
    if err != nil {
        fmt.Println(err)
    } else {
        fmt.Println(time)
    }

    assets, err := client.Assets(kraken.AssetsConfig{
        AssetClass: kraken.Currency,
        Assets:     []kraken.Asset{kraken.XBT},
    })
    if err != nil {
        fmt.Println(err)
    } else {
        fmt.Println(assets)
    }

    // Private calls
    client.WithAuthentification("YOUR_API_KEY", "YOUR_PRIVATE_KEY") // To generate a new one --> https://www.kraken.com/u/security/api

    accountBalance, err := client.AccountBalance()
    if err != nil {
        fmt.Println(err)
    } else {
        fmt.Println(accountBalance)
    }
}

Supported calls

Public market data

  • Get server time
  • Get system status
  • Get asset info
  • Get tradable asset pairs
  • Get ticker information
  • Get OHLC data
  • Get order book
  • Get recent trades
  • Get recent spread data

Private user data

  • Get account balance
  • Get trade balance
  • Get open orders
  • Get closed orders
  • Query orders info
  • Get trades history
  • Query trades info
  • Get open positions
  • Get ledgers info
  • Query ledgers
  • Get trade volume
  • Request export report
  • Get export statuses
  • Get export report
  • Remove export report

Private user trading

  • Add order
  • Add order batch
  • Edit order
  • Cancel order
  • Cancel all orders
  • Cancel all orders after X
  • Cancel order batch

Private user funding

  • Get deposit methods
  • Get deposit addresses
  • Get status of recent deposits
  • Get withdrawal information
  • Withdraw funds
  • Get status of recent withdrawals
  • Request withdrawal cancelation
  • Request wallet transfer

Private user staking

  • Stake asset
  • Unstake asset
  • List of stakeable assets
  • Get pending staking transactions
  • List of staking transactions

Generated code

In the generate/ folder, you will find the source code to update assets.go and asset_pairs.go. Two calls on the Kraken API are made in order to get the list of the assets and asset pairs available on the plateform. Then the code is generated through the text/template feature of Golang.

The aim is to have a list of assets and asset pairs in Golang constants to simplify the usage of the library.

NB: assets.go and asset_pairs.go should not be manually edited. To update these files, run the make generate command.

References

About

Golang client for Kraken API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published