krakenapi

package module
v0.0.0-...-46e15c2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2017 License: MIT Imports: 11 Imported by: 0

README

Kraken GO API Client

build status

A simple API Client for the Kraken Trading platform.

Example usage:

package main

import (
	"fmt"
	"log"

	"github.com/Beldur/kraken-go-api-client"
)

func main() {
	api := krakenapi.New("KEY", "SECRET")
	result, err := api.Query("Ticker", map[string]string{
		"pair": "XXBTZEUR",
	})

	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Result: %+v\n", result)

	// There also some strongly typed methods available
	ticker, err := api.Ticker(krakenapi.XXBTZEUR)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(ticker.XXBTZEUR.OpeningPrice)
}

If you find this useful, you can send me a fraction of a bitcoin!

1Q3P96LcTkbS9VwZkV5ndQa6t4EcR4GzSL

Documentation

Index

Constants

View Source
const (
	// APIURL is the official Kraken API Endpoint
	APIURL = "https://api.kraken.com"
	// APIVersion is the official Kraken API Version Number
	APIVersion = "0"
	// APIUserAgent identifies this library with the Kraken API
	APIUserAgent = "Kraken GO API Agent (https://github.com/beldur/kraken-go-api-client)"
)
View Source
const (
	XETHXXBT = "XETHXXBT"
	XETHZCAD = "XETHZCAD"
	XETHZEUR = "XETHZEUR"
	XETHZGBP = "XETHZGBP"
	XETHZJPY = "XETHZJPY"
	XETHZUSD = "XETHZUSD"
	XLTCZCAD = "XLTCZCAD"
	XLTCZEUR = "XLTCZEUR"
	XLTCZUSD = "XLTCZUSD"
	XXBTXLTC = "XXBTXLTC"
	XXBTXNMC = "XXBTXNMC"
	XXBTXXDG = "XXBTXXDG"
	XXBTXXLM = "XXBTXXLM"
	XXBTXXRP = "XXBTXXRP"
	XXBTZCAD = "XXBTZCAD"
	XXBTZEUR = "XXBTZEUR"
	XXBTZGBP = "XXBTZGBP"
	XXBTZJPY = "XXBTZJPY"
	XXBTZUSD = "XXBTZUSD"
	XXMRZUSD = "XXMRZUSD"
	XXMRZEUR = "XXMRZEUR"
	XXMRXXBT = "XXMRXXBT"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetInfo

type AssetInfo struct {
	// Alternate name
	Altname string
	// Asset class
	AssetClass string
	// Scaling decimal places for record keeping
	Decimals int
	// Scaling decimal places for output display
	DisplayDecimals int `json:"display_decimals"`
}

AssetInfo represents an asset information

type AssetPairInfo

type AssetPairInfo struct {
	// Alternate pair name
	Altname string `json:"altname"`
	// Asset class of base component
	AssetClassBase string `json:"aclass_base"`
	// Asset id of base component
	Base string `json:"base"`
	// Asset class of quote component
	AssetClassQuote string `json:"aclass_quote"`
	// Asset id of quote component
	Quote string `json:"quote"`
	// Volume lot size
	Lot string `json:"lot"`
	// Scaling decimal places for pair
	PairDecimals int `json:"pair_decimals"`
	// Scaling decimal places for volume
	LotDecimals int `json:"lot_decimals"`
	// Amount to multiply lot volume by to get currency volume
	LotMultiplier int `json:"lot_multiplier"`
	// Array of leverage amounts available when buying
	LeverageBuy []float32 `json:"leverage_buy"`
	// Array of leverage amounts available when selling
	LeverageSell []float32 `json:"leverage_sell"`
	// Fee schedule array in [volume, percent fee] tuples
	Fees [][]float64 `json:"fees"`
	// // Maker fee schedule array in [volume, percent fee] tuples (if on maker/taker)
	FeesMaker [][]float64 `json:"fees_maker"`
	// // Volume discount currency
	FeeVolumeCurrency string `json:"fee_volume_currency"`
	// Margin call level
	MarginCall int `json:"margin_call"`
	// Stop-out/Liquidation margin level
	MarginStop int `json:"margin_stop"`
}

AssetPairInfo represents asset pair information

type AssetPairsResponse

type AssetPairsResponse struct {
	XETHXXBT AssetPairInfo
	XETHZCAD AssetPairInfo
	XETHZEUR AssetPairInfo
	XETHZGBP AssetPairInfo
	XETHZJPY AssetPairInfo
	XETHZUSD AssetPairInfo
	XLTCZCAD AssetPairInfo
	XLTCZEUR AssetPairInfo
	XLTCZUSD AssetPairInfo
	XXBTXLTC AssetPairInfo
	XXBTXNMC AssetPairInfo
	XXBTXXDG AssetPairInfo
	XXBTXXLM AssetPairInfo
	XXBTXXRP AssetPairInfo
	XXBTZCAD AssetPairInfo
	XXBTZEUR AssetPairInfo
	XXBTZGBP AssetPairInfo
	XXBTZJPY AssetPairInfo
	XXBTZUSD AssetPairInfo
	XXMRZUSD AssetPairInfo
	XXMRZEUR AssetPairInfo
	XXMRZXBT AssetPairInfo
}

AssetPairsResponse includes asset pair informations

type AssetsResponse

type AssetsResponse struct {
	KFEE AssetInfo
	XETH AssetInfo
	XLTC AssetInfo
	XNMC AssetInfo
	XXBT AssetInfo
	XXDG AssetInfo
	XXLM AssetInfo
	XXRP AssetInfo
	XXVN AssetInfo
	XXMR AssetInfo
	ZCAD AssetInfo
	ZEUR AssetInfo
	ZGBP AssetInfo
	ZJPY AssetInfo
	ZKRW AssetInfo
	ZUSD AssetInfo
}

AssetsResponse includes asset informations

type KrakenApi

type KrakenApi struct {
	// contains filtered or unexported fields
}

KrakenApi represents a Kraken API Client connection

func New

func New(key, secret string) *KrakenApi

New creates a new Kraken API client

func NewKrakenApi

func NewKrakenApi(key, secret string) *KrakenApi

NewKrakenApi creates a new Kraken API Client @deprecated Use New instead to avoid stutter

func (*KrakenApi) AssetPairs

func (api *KrakenApi) AssetPairs() (*AssetPairsResponse, error)

AssetPairs returns the servers available asset pairs

func (*KrakenApi) Assets

func (api *KrakenApi) Assets() (*AssetsResponse, error)

Assets returns the servers available assets

func (*KrakenApi) Query

func (api *KrakenApi) Query(method string, data map[string]string, typ interface{}) (interface{}, error)

Query sends a query to Kraken api for given method and parameters

func (*KrakenApi) Ticker

func (api *KrakenApi) Ticker(pairs ...string) (*TickerResponse, error)

Ticker returns the ticker for given comma seperated pais

func (*KrakenApi) Time

func (api *KrakenApi) Time() (*TimeResponse, error)

Time returns the server's time

type KrakenResponse

type KrakenResponse struct {
	Error  []string    `json:"error"`
	Result interface{} `json:"result"`
}

KrakenResponse wraps the Kraken API JSON response

type PairTickerInfo

type PairTickerInfo struct {
	// Ask array(<price>, <whole lot volume>, <lot volume>)
	Ask []string `json:"a"`
	// Bid array(<price>, <whole lot volume>, <lot volume>)
	Bid []string `json:"b"`
	// Last trade closed array(<price>, <lot volume>)
	Close []string `json:"c"`
	// Volume array(<today>, <last 24 hours>)
	Volume []string `json:"v"`
	// Volume weighted average price array(<today>, <last 24 hours>)
	VolumeAveragePrice []string `json:"p"`
	// Number of trades array(<today>, <last 24 hours>)
	Trades []int `json:"t"`
	// Low array(<today>, <last 24 hours>)
	Low []string `json:"l"`
	// High array(<today>, <last 24 hours>)
	High []string `json:"h"`
	// Today's opening price
	OpeningPrice float32 `json:"o,string"`
}

PairTickerInfo represents ticker information for a pair

type TickerResponse

type TickerResponse struct {
	XETHXXBT PairTickerInfo
	XETHZCAD PairTickerInfo
	XETHZEUR PairTickerInfo
	XETHZGBP PairTickerInfo
	XETHZJPY PairTickerInfo
	XETHZUSD PairTickerInfo
	XLTCZCAD PairTickerInfo
	XLTCZEUR PairTickerInfo
	XLTCZUSD PairTickerInfo
	XXBTXLTC PairTickerInfo
	XXBTXNMC PairTickerInfo
	XXBTXXDG PairTickerInfo
	XXBTXXLM PairTickerInfo
	XXBTXXRP PairTickerInfo
	XXBTZCAD PairTickerInfo
	XXBTZEUR PairTickerInfo
	XXBTZGBP PairTickerInfo
	XXBTZJPY PairTickerInfo
	XXBTZUSD PairTickerInfo
	XXMRZUSD PairTickerInfo
	XXMRZEUR PairTickerInfo
	XXMRXXBT PairTickerInfo
}

TickerResponse includes the requested ticker pairs

type TimeResponse

type TimeResponse struct {
	// Unix timestamp
	Unixtime int64
	// RFC 1123 time format
	Rfc1123 string
}

TimeResponse represents the server's time

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL