krakenapi

package module
v0.0.0-...-6929ab9 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: MIT Imports: 16 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 are also some strongly typed methods available
	ticker, err := api.Ticker(krakenapi.XXBTZEUR)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(ticker.XXBTZEUR.OpeningPrice)
}

Contributors

  • Piega
  • Glavic
  • MarinX
  • bjorand
  • khezen

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 (
	MinimumREP  = 0.3
	MinimumXBT  = 0.002
	MinimumBCH  = 0.002
	MinimumDASH = 0.03
	MinimumDOGE = 3000.0
	MinimumEOS  = 3.0
	MinimumETH  = 0.02
	MinimumETC  = 0.3
	MinimumGNO  = 0.03
	MinimumICN  = 2.0
	MinimumLTC  = 0.1
	MinimumMLN  = 0.1
	MinimumXMR  = 0.1
	MinimumXRP  = 30.0
	MinimumXLM  = 300.0
	MinimumZEC  = 0.02
	MinimumUSDT = 5.0
)

These represent the minimum order sizes for the respective coins Should be monitored through here: https://support.kraken.com/hc/en-us/articles/205893708-What-is-the-minimum-order-size-

View Source
const (
	ADACAD   = "ADACAD"
	ADAETH   = "ADAETH"
	ADAEUR   = "ADAEUR"
	ADAUSD   = "ADAUSD"
	ADAXBT   = "ADAXBT"
	AAVEUSD  = "AAVEUSD"
	BCHEUR   = "BCHEUR"
	BCHUSD   = "BCHUSD"
	BCHXBT   = "BCHXBT"
	DASHEUR  = "DASHEUR"
	DASHUSD  = "DASHUSD"
	DASHXBT  = "DASHXBT"
	EOSETH   = "EOSETH"
	EOSEUR   = "EOSEUR"
	EOSUSD   = "EOSUSD"
	EOSXBT   = "EOSXBT"
	GNOETH   = "GNOETH"
	GNOEUR   = "GNOEUR"
	GNOUSD   = "GNOUSD"
	GNOXBT   = "GNOXBT"
	QTUMCAD  = "QTUMCAD"
	QTUMETH  = "QTUMETH"
	QTUMEUR  = "QTUMEUR"
	QTUMUSD  = "QTUMUSD"
	QTUMXBT  = "QTUMXBT"
	USDTZUSD = "USDTZUSD"
	XBTUSDT  = "XBTUSDT"
	XETCXETH = "XETCXETH"
	XETCXXBT = "XETCXXBT"
	XETCZEUR = "XETCZEUR"
	XETCZUSD = "XETCZUSD"
	XETHXXBT = "XETHXXBT"
	XETHZCAD = "XETHZCAD"
	XETHZEUR = "XETHZEUR"
	XETHZGBP = "XETHZGBP"
	XETHZJPY = "XETHZJPY"
	XETHZUSD = "XETHZUSD"
	XICNXETH = "XICNXETH"
	XICNXXBT = "XICNXXBT"
	XLTCXXBT = "XLTCXXBT"
	XLTCZEUR = "XLTCZEUR"
	XLTCZUSD = "XLTCZUSD"
	XMLNXETH = "XMLNXETH"
	XMLNXXBT = "XMLNXXBT"
	XREPXETH = "XREPXETH"
	XREPXXBT = "XREPXXBT"
	XREPZEUR = "XREPZEUR"
	XREPZUSD = "XREPZUSD"
	XTZCAD   = "XTZCAD"
	XTZETH   = "XTZETH"
	XTZEUR   = "XTZEUR"
	XTZUSD   = "XTZUSD"
	XTZXBT   = "XTZXBT"
	XXBTZCAD = "XXBTZCAD"
	XXBTZEUR = "XXBTZEUR"
	XXBTZGBP = "XXBTZGBP"
	XXBTZJPY = "XXBTZJPY"
	XXBTZUSD = "XXBTZUSD"
	XXDGXXBT = "XXDGXXBT"
	XXLMXXBT = "XXLMXXBT"
	XXLMZEUR = "XXLMZEUR"
	XXLMZUSD = "XXLMZUSD"
	XXMRXXBT = "XXMRXXBT"
	XXMRZEUR = "XXMRZEUR"
	XXMRZUSD = "XXMRZUSD"
	XXRPXXBT = "XXRPXXBT"
	XXRPZCAD = "XXRPZCAD"
	XXRPZEUR = "XXRPZEUR"
	XXRPZJPY = "XXRPZJPY"
	XXRPZUSD = "XXRPZUSD"
	XZECXXBT = "XZECXXBT"
	XZECZEUR = "XZECZEUR"
	XZECZUSD = "XZECZUSD"
)

trade pairs constants

View Source
const (
	BUY    = "b"
	SELL   = "s"
	MARKET = "m"
	LIMIT  = "l"
)

actions constants

Variables

This section is empty.

Functions

This section is empty.

Types

type AddOrderResponse

type AddOrderResponse struct {
	Description    OrderDescription `json:"descr"`
	TransactionIds []string         `json:"txid"`
}

AddOrderResponse response when adding an order

type AssetInfo

type AssetInfo struct {
	// Alternate name
	Altname string
	// Asset class
	AssetClass string `json:"aclass"`
	// 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 []float64 `json:"leverage_buy"`
	// Array of leverage amounts available when selling
	LeverageSell []float64 `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 {
	ADACAD   AssetPairInfo
	AAVEUSD  AssetPairInfo
	ADAETH   AssetPairInfo
	ADAEUR   AssetPairInfo
	ADAUSD   AssetPairInfo
	ADAXBT   AssetPairInfo
	BCHEUR   AssetPairInfo
	BCHUSD   AssetPairInfo
	BCHXBT   AssetPairInfo
	DASHEUR  AssetPairInfo
	DASHUSD  AssetPairInfo
	DASHXBT  AssetPairInfo
	EOSETH   AssetPairInfo
	EOSEUR   AssetPairInfo
	EOSUSD   AssetPairInfo
	EOSXBT   AssetPairInfo
	GNOETH   AssetPairInfo
	GNOEUR   AssetPairInfo
	GNOUSD   AssetPairInfo
	GNOXBT   AssetPairInfo
	QTUMCAD  AssetPairInfo
	QTUMETH  AssetPairInfo
	QTUMEUR  AssetPairInfo
	QTUMUSD  AssetPairInfo
	QTUMXBT  AssetPairInfo
	USDTZUSD AssetPairInfo
	XETCXETH AssetPairInfo
	XETCXXBT AssetPairInfo
	XETCZEUR AssetPairInfo
	XETCZUSD AssetPairInfo
	XETHXXBT AssetPairInfo
	XETHZCAD AssetPairInfo
	XETHZEUR AssetPairInfo
	XETHZGBP AssetPairInfo
	XETHZJPY AssetPairInfo
	XETHZUSD AssetPairInfo
	XICNXETH AssetPairInfo
	XICNXXBT AssetPairInfo
	XLTCXXBT AssetPairInfo
	XLTCZEUR AssetPairInfo
	XLTCZUSD AssetPairInfo
	XMLNXETH AssetPairInfo
	XMLNXXBT AssetPairInfo
	XREPXETH AssetPairInfo
	XREPXXBT AssetPairInfo
	XREPZEUR AssetPairInfo
	XREPZUSD AssetPairInfo
	XTZCAD   AssetPairInfo
	XTZETH   AssetPairInfo
	XTZEUR   AssetPairInfo
	XTZUSD   AssetPairInfo
	XTZXBT   AssetPairInfo
	XXBTZCAD AssetPairInfo
	XXBTZEUR AssetPairInfo
	XXBTZGBP AssetPairInfo
	XXBTZJPY AssetPairInfo
	XXBTZUSD AssetPairInfo
	XXDGXXBT AssetPairInfo
	XXLMXXBT AssetPairInfo
	XXLMZEUR AssetPairInfo
	XXLMZUSD AssetPairInfo
	XXMRXXBT AssetPairInfo
	XXMRZEUR AssetPairInfo
	XXMRZUSD AssetPairInfo
	XXRPXXBT AssetPairInfo
	XXRPZCAD AssetPairInfo
	XXRPZEUR AssetPairInfo
	XXRPZJPY AssetPairInfo
	XXRPZUSD AssetPairInfo
	XZECXXBT AssetPairInfo
	XZECZEUR AssetPairInfo
	XZECZUSD AssetPairInfo
}

AssetPairsResponse includes asset pair informations

type AssetsResponse

type AssetsResponse struct {
	ADA  AssetInfo
	AAVE AssetInfo
	BCH  AssetInfo
	DASH AssetInfo
	EOS  AssetInfo
	GNO  AssetInfo
	KFEE AssetInfo
	QTUM AssetInfo
	USDT AssetInfo
	XDAO AssetInfo
	XETC AssetInfo
	XETH AssetInfo
	XICN AssetInfo
	XLTC AssetInfo
	XMLN AssetInfo
	XNMC AssetInfo
	XREP AssetInfo
	XXBT AssetInfo
	XXDG AssetInfo
	XXLM AssetInfo
	XXMR AssetInfo
	XXRP AssetInfo
	XTZ  AssetInfo
	XXVN AssetInfo
	XZEC AssetInfo
	ZCAD AssetInfo
	ZEUR AssetInfo
	ZGBP AssetInfo
	ZJPY AssetInfo
	ZKRW AssetInfo
	ZUSD AssetInfo
}

AssetsResponse includes asset informations

type BalanceResponse

type BalanceResponse struct {
	ADA  float64 `json:"ADA,string"`
	AAVE float64 `json:"AAVE,string"`
	BCH  float64 `json:"BCH,string"`
	DASH float64 `json:"DASH,string"`
	EOS  float64 `json:"EOS,string"`
	GNO  float64 `json:"GNO,string"`
	QTUM float64 `json:"QTUM,string"`
	KFEE float64 `json:"KFEE,string"`
	USDT float64 `json:"USDT,string"`
	XDAO float64 `json:"XDAO,string"`
	XETC float64 `json:"XETC,string"`
	XETH float64 `json:"XETH,string"`
	XICN float64 `json:"XICN,string"`
	XLTC float64 `json:"XLTC,string"`
	XMLN float64 `json:"XMLN,string"`
	XNMC float64 `json:"XNMC,string"`
	XREP float64 `json:"XREP,string"`
	XXBT float64 `json:"XXBT,string"`
	XXDG float64 `json:"XXDG,string"`
	XXLM float64 `json:"XXLM,string"`
	XXMR float64 `json:"XXMR,string"`
	XXRP float64 `json:"XXRP,string"`
	XTZ  float64 `json:"XTZ,string"`
	XXVN float64 `json:"XXVN,string"`
	XZEC float64 `json:"XZEC,string"`
	ZCAD float64 `json:"ZCAD,string"`
	ZEUR float64 `json:"ZEUR,string"`
	ZGBP float64 `json:"ZGBP,string"`
	ZJPY float64 `json:"ZJPY,string"`
	ZKRW float64 `json:"ZKRW,string"`
	ZUSD float64 `json:"ZUSD,string"`
	TRX  float64 `json:"TRX,string"`
}

BalanceResponse represents the account's balances (list of currencies)

type CancelOrderResponse

type CancelOrderResponse struct {
	Count   int  `json:"count"`
	Pending bool `json:"pending"`
}

CancelOrderResponse response when cancelling and order

type ClosedOrdersResponse

type ClosedOrdersResponse struct {
	Closed map[string]Order `json:"closed"`
	Count  int              `json:"count"`
}

ClosedOrdersResponse represents a list of closed orders, indexed by id

type DepositAddressesResponse

type DepositAddressesResponse []struct {
	Address  string `json:"address"`
	Expiretm string `json:"expiretm"`
	New      bool   `json:"new,omitempty"`
}

DepositAddressesResponse is the response type of a DepositAddresses query to the Kraken API.

type DepthResponse

type DepthResponse map[string]OrderBook

DepthResponse is a response from kraken to Depth request.

type Direction

type Direction string
const (
	Buy  Direction = "buy"
	Sell Direction = "sell"
)

type FeeInfo

type FeeInfo struct {
	Fee        float64 `json:"fee,string"`
	MinFee     float64 `json:"minfee,string"`
	MaxFee     float64 `json:"maxfee,string"`
	NextFee    float64 `json:"nextfee,string"`
	NextVolume float64 `json:"nextvolume,string"`
	TierVolume float64 `json:"tiervolume,string"`
}

FeeInfo represents a fee information

type Fees

type Fees struct {
	ADACAD   FeeInfo
	ADAETH   FeeInfo
	ADAEUR   FeeInfo
	ADAUSD   FeeInfo
	ADAXBT   FeeInfo
	AAVEUSD  FeeInfo
	BCHEUR   FeeInfo
	BCHUSD   FeeInfo
	BCHXBT   FeeInfo
	DASHEUR  FeeInfo
	DASHUSD  FeeInfo
	DASHXBT  FeeInfo
	EOSETH   FeeInfo
	EOSEUR   FeeInfo
	EOSUSD   FeeInfo
	EOSXBT   FeeInfo
	GNOETH   FeeInfo
	GNOEUR   FeeInfo
	GNOUSD   FeeInfo
	GNOXBT   FeeInfo
	QTUMCAD  FeeInfo
	QTUMETH  FeeInfo
	QTUMEUR  FeeInfo
	QTUMUSD  FeeInfo
	QTUMXBT  FeeInfo
	USDTZUSD FeeInfo
	XETCXETH FeeInfo
	XETCXXBT FeeInfo
	XETCZEUR FeeInfo
	XETCZUSD FeeInfo
	XETHXXBT FeeInfo
	XETHZCAD FeeInfo
	XETHZEUR FeeInfo
	XETHZGBP FeeInfo
	XETHZJPY FeeInfo
	XETHZUSD FeeInfo
	XICNXETH FeeInfo
	XICNXXBT FeeInfo
	XLTCXXBT FeeInfo
	XLTCZEUR FeeInfo
	XLTCZUSD FeeInfo
	XMLNXETH FeeInfo
	XMLNXXBT FeeInfo
	XREPXETH FeeInfo
	XREPXXBT FeeInfo
	XREPZEUR FeeInfo
	XREPZUSD FeeInfo
	XTZCAD   FeeInfo
	XTZETH   FeeInfo
	XTZEUR   FeeInfo
	XTZUSD   FeeInfo
	XTZXBT   FeeInfo
	XXBTZCAD FeeInfo
	XXBTZEUR FeeInfo
	XXBTZGBP FeeInfo
	XXBTZJPY FeeInfo
	XXBTZUSD FeeInfo
	XXDGXXBT FeeInfo
	XXLMXXBT FeeInfo
	XXLMZEUR FeeInfo
	XXLMZUSD FeeInfo
	XXMRXXBT FeeInfo
	XXMRZEUR FeeInfo
	XXMRZUSD FeeInfo
	XXRPXXBT FeeInfo
	XXRPZCAD FeeInfo
	XXRPZEUR FeeInfo
	XXRPZJPY FeeInfo
	XXRPZUSD FeeInfo
	XZECXXBT FeeInfo
	XZECZEUR FeeInfo
	XZECZUSD FeeInfo
}

Fees includes fees information for different currencies

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 NewWithClient

func NewWithClient(key, secret string, httpClient *http.Client) *KrakenAPI

NewWithClient creates a new Kraken API client with custom http client

func (*KrakenAPI) AddOrder

func (api *KrakenAPI) AddOrder(pair string, direction Direction, orderType OrderType, volume string, args map[string]string) (*AddOrderResponse, error)

AddOrder adds new order

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) Balance

func (api *KrakenAPI) Balance() (*BalanceResponse, error)

Balance returns all account asset balances

func (*KrakenAPI) CancelOrder

func (api *KrakenAPI) CancelOrder(txid string) (*CancelOrderResponse, error)

CancelOrder cancels order

func (*KrakenAPI) ClosedOrders

func (api *KrakenAPI) ClosedOrders(args map[string]string) (*ClosedOrdersResponse, error)

ClosedOrders returns all closed orders

func (*KrakenAPI) DepositAddresses

func (api *KrakenAPI) DepositAddresses(asset string, method string) (*DepositAddressesResponse, error)

DepositAddresses returns deposit addresses

func (*KrakenAPI) Depth

func (api *KrakenAPI) Depth(pair string, count int) (*OrderBook, error)

Depth returns the order book for given pair and orders count.

func (*KrakenAPI) Ledgers

func (api *KrakenAPI) Ledgers(args map[string]string) (*LedgersResponse, error)

Ledgers returns ledgers informations

func (*KrakenAPI) OHLC

func (api *KrakenAPI) OHLC(pair string) (*OHLCResponse, error)

OHLC returns a OHLCResponse struct based on the given pair

func (*KrakenAPI) OpenOrders

func (api *KrakenAPI) OpenOrders(args map[string]string) (*OpenOrdersResponse, error)

OpenOrders returns all open orders

func (*KrakenAPI) Query

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

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

func (*KrakenAPI) QueryOrders

func (api *KrakenAPI) QueryOrders(txids string, args map[string]string) (*QueryOrdersResponse, error)

QueryOrders shows order

func (*KrakenAPI) Ticker

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

Ticker returns the ticker for given comma separated pairs

func (*KrakenAPI) Time

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

Time returns the server's time

func (*KrakenAPI) TradeBalance

func (api *KrakenAPI) TradeBalance(args map[string]string) (*TradeBalanceResponse, error)

TradeBalance returns trade balance info

func (*KrakenAPI) TradeVolume

func (api *KrakenAPI) TradeVolume(args map[string]string) (*TradeVolumeResponse, error)

TradeVolume returns trade volume info

func (*KrakenAPI) Trades

func (api *KrakenAPI) Trades(pair string, since int64) (*TradesResponse, error)

Trades returns the recent trades for given pair

func (*KrakenAPI) TradesHistory

func (api *KrakenAPI) TradesHistory(start int64, end int64, args map[string]string) (*TradesHistoryResponse, error)

TradesHistory returns the Trades History within a specified time frame (start to end).

func (*KrakenAPI) WithClient

func (api *KrakenAPI) WithClient(httpClient *http.Client) *KrakenAPI

WithClient adds an HTTP client into the KrakenAPI

func (*KrakenAPI) Withdraw

func (api *KrakenAPI) Withdraw(asset string, key string, amount *big.Float) (*WithdrawResponse, error)

Withdraw executes a withdrawal, returning a reference ID

func (*KrakenAPI) WithdrawInfo

func (api *KrakenAPI) WithdrawInfo(asset string, key string, amount *big.Float) (*WithdrawInfoResponse, error)

WithdrawInfo returns withdrawal information

type KrakenApi

type KrakenApi = KrakenAPI

KrakenApi represents a Kraken API Client connection

type KrakenResponse

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

KrakenResponse wraps the Kraken API JSON response

type LedgerInfo

type LedgerInfo struct {
	RefID   string    `json:"refid"`
	Time    float64   `json:"time"`
	Type    string    `json:"type"`
	Aclass  string    `json:"aclass"`
	Asset   string    `json:"asset"`
	Amount  big.Float `json:"amount"`
	Fee     big.Float `json:"fee"`
	Balance big.Float `json:"balance"`
}

LedgerInfo Represents the ledger informations

type LedgersResponse

type LedgersResponse struct {
	Ledger map[string]LedgerInfo `json:"ledger"`
}

LedgersResponse represents an associative array of ledgers infos

type OHLC

type OHLC struct {
	Time   time.Time `json:"time"`
	Open   float64   `json:"open"`
	High   float64   `json:"high"`
	Low    float64   `json:"low"`
	Close  float64   `json:"close"`
	Vwap   float64   `json:"vwap"`
	Volume float64   `json:"volume"`
	Count  int       `json:"count"`
}

OHLC represents the "Open-high-low-close chart"

func NewOHLC

func NewOHLC(input []interface{}) (*OHLC, error)

NewOHLC constructor for OHLC

type OHLCResponse

type OHLCResponse struct {
	Pair string  `json:"pair"`
	OHLC []*OHLC `json:"OHLC"`
	Last float64 `json:"last"`
}

OHLCResponse represents the OHLC's response

type OpenOrdersResponse

type OpenOrdersResponse struct {
	Open  map[string]Order `json:"open"`
	Count int              `json:"count"`
}

OpenOrdersResponse response when opening an order

type Order

type Order struct {
	TransactionID  string           `json:"txid"`
	ReferenceID    string           `json:"refid"`
	UserRef        int              `json:"userref"`
	Status         OrderStatus      `json:"status"`
	OpenTime       float64          `json:"opentm"`
	StartTime      float64          `json:"starttm"`
	ExpireTime     float64          `json:"expiretm"`
	Description    OrderDescription `json:"descr"`
	Volume         float64          `json:"vol,string"`
	VolumeExecuted float64          `json:"vol_exec,string"`
	Cost           float64          `json:"cost,string"`
	Fee            float64          `json:"fee,string"`
	Price          float64          `json:"price,string"`
	StopPrice      float64          `json:"stopprice.string"`
	LimitPrice     float64          `json:"limitprice,string"`
	Misc           string           `json:"misc"`
	OrderFlags     string           `json:"oflags"`
	CloseTime      float64          `json:"closetm"`
	Reason         string           `json:"reason"`
	Trades         []string         `json:"trades"`
}

Order represents a single order

type OrderBook

type OrderBook struct {
	Asks []OrderBookItem
	Bids []OrderBookItem
}

OrderBook contains top asks and bids.

type OrderBookItem

type OrderBookItem struct {
	Price  float64
	Amount float64
	Ts     int64
}

OrderBookItem is a piece of information about an order.

func (*OrderBookItem) UnmarshalJSON

func (o *OrderBookItem) UnmarshalJSON(data []byte) error

UnmarshalJSON takes a json array from kraken and converts it into an OrderBookItem.

type OrderDescription

type OrderDescription struct {
	AssetPair      string    `json:"pair"`
	Close          string    `json:"close"`
	Leverage       string    `json:"leverage"`
	Order          string    `json:"order"`
	OrderType      OrderType `json:"ordertype"`
	PrimaryPrice   float64   `json:"price,string"`
	SecondaryPrice float64   `json:"price2,string"`
	Type           Direction `json:"type"`
}

OrderDescription represents an orders description

type OrderStatus

type OrderStatus string
const (
	Pending  OrderStatus = "pending"  // order pending book entry
	Open     OrderStatus = "open"     // open order
	Closed   OrderStatus = "closed"   // closed order
	Canceled OrderStatus = "canceled" // order canceled
	Expired  OrderStatus = "expired"  // order expired
)

type OrderType

type OrderType string
const (
	Market          OrderType = "market"
	Limit           OrderType = "limit"             // (price = limit price)
	StopLoss        OrderType = "stop-loss"         // (price = stop loss price)
	TakeProfit      OrderType = "take-profit"       // (price = take profit price)
	StopLossLimit   OrderType = "stop-loss-limit"   // (price = stop loss trigger price, price2 = triggered limit price)
	TakeProfitLimit OrderType = "take-profit-limit" // (price = take profit trigger price, price2 = triggered limit price)
	SettlePosition  OrderType = "settle-position"
)

OrderTypes for AddOrder

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 float64 `json:"o,string"`
}

PairTickerInfo represents ticker information for a pair

type QueryOrdersResponse

type QueryOrdersResponse map[string]Order

QueryOrdersResponse response when checking all orders

type TickerResponse

type TickerResponse struct {
	AAVEAUD   PairTickerInfo
	AAVEETH   PairTickerInfo
	AAVEEUR   PairTickerInfo
	AAVEGBP   PairTickerInfo
	AAVEUSD   PairTickerInfo
	AAVEXBT   PairTickerInfo
	ADAAUD    PairTickerInfo
	ADAETH    PairTickerInfo
	ADAEUR    PairTickerInfo
	ADAGBP    PairTickerInfo
	ADAUSD    PairTickerInfo
	ADAUSDT   PairTickerInfo
	ADAXBT    PairTickerInfo
	ALGOETH   PairTickerInfo
	ALGOEUR   PairTickerInfo
	ALGOGBP   PairTickerInfo
	ALGOUSD   PairTickerInfo
	ALGOXBT   PairTickerInfo
	ANTETH    PairTickerInfo
	ANTEUR    PairTickerInfo
	ANTUSD    PairTickerInfo
	ANTXBT    PairTickerInfo
	ATOMAUD   PairTickerInfo
	ATOMETH   PairTickerInfo
	ATOMEUR   PairTickerInfo
	ATOMGBP   PairTickerInfo
	ATOMUSD   PairTickerInfo
	ATOMXBT   PairTickerInfo
	AUDJPY    PairTickerInfo
	AUDUSD    PairTickerInfo
	BALETH    PairTickerInfo
	BALEUR    PairTickerInfo
	BALUSD    PairTickerInfo
	BALXBT    PairTickerInfo
	BATETH    PairTickerInfo
	BATEUR    PairTickerInfo
	BATUSD    PairTickerInfo
	BATXBT    PairTickerInfo
	BCHAUD    PairTickerInfo
	BCHETH    PairTickerInfo
	BCHEUR    PairTickerInfo
	BCHGBP    PairTickerInfo
	BCHJPY    PairTickerInfo
	BCHUSD    PairTickerInfo
	BCHUSDT   PairTickerInfo
	BCHXBT    PairTickerInfo
	COMPETH   PairTickerInfo
	COMPEUR   PairTickerInfo
	COMPUSD   PairTickerInfo
	COMPXBT   PairTickerInfo
	CRVETH    PairTickerInfo
	CRVEUR    PairTickerInfo
	CRVUSD    PairTickerInfo
	CRVXBT    PairTickerInfo
	DAIEUR    PairTickerInfo
	DAIUSD    PairTickerInfo
	DAIUSDT   PairTickerInfo
	DASHEUR   PairTickerInfo
	DASHUSD   PairTickerInfo
	DASHXBT   PairTickerInfo
	DOTAUD    PairTickerInfo
	DOTETH    PairTickerInfo
	DOTEUR    PairTickerInfo
	DOTGBP    PairTickerInfo
	DOTUSD    PairTickerInfo
	DOTUSDT   PairTickerInfo
	DOTXBT    PairTickerInfo
	EOSETH    PairTickerInfo
	EOSEUR    PairTickerInfo
	EOSUSD    PairTickerInfo
	EOSUSDT   PairTickerInfo
	EOSXBT    PairTickerInfo
	ETH2SETH  PairTickerInfo `json:"ETH2.SETH"`
	ETHAUD    PairTickerInfo
	ETHCHF    PairTickerInfo
	ETHDAI    PairTickerInfo
	ETHUSDC   PairTickerInfo
	ETHUSDT   PairTickerInfo
	EURAUD    PairTickerInfo
	EURCAD    PairTickerInfo
	EURCHF    PairTickerInfo
	EURGBP    PairTickerInfo
	EURJPY    PairTickerInfo
	FILAUD    PairTickerInfo
	FILETH    PairTickerInfo
	FILEUR    PairTickerInfo
	FILGBP    PairTickerInfo
	FILUSD    PairTickerInfo
	FILXBT    PairTickerInfo
	FLOWETH   PairTickerInfo
	FLOWEUR   PairTickerInfo
	FLOWGBP   PairTickerInfo
	FLOWUSD   PairTickerInfo
	FLOWXBT   PairTickerInfo
	GNOETH    PairTickerInfo
	GNOEUR    PairTickerInfo
	GNOUSD    PairTickerInfo
	GNOXBT    PairTickerInfo
	GRTAUD    PairTickerInfo
	GRTETH    PairTickerInfo
	GRTEUR    PairTickerInfo
	GRTGBP    PairTickerInfo
	GRTUSD    PairTickerInfo
	GRTXBT    PairTickerInfo
	ICXETH    PairTickerInfo
	ICXEUR    PairTickerInfo
	ICXUSD    PairTickerInfo
	ICXXBT    PairTickerInfo
	KAVAETH   PairTickerInfo
	KAVAEUR   PairTickerInfo
	KAVAUSD   PairTickerInfo
	KAVAXBT   PairTickerInfo
	KEEPETH   PairTickerInfo
	KEEPEUR   PairTickerInfo
	KEEPUSD   PairTickerInfo
	KEEPXBT   PairTickerInfo
	KNCETH    PairTickerInfo
	KNCEUR    PairTickerInfo
	KNCUSD    PairTickerInfo
	KNCXBT    PairTickerInfo
	KSMAUD    PairTickerInfo
	KSMETH    PairTickerInfo
	KSMEUR    PairTickerInfo
	KSMGBP    PairTickerInfo
	KSMUSD    PairTickerInfo
	KSMXBT    PairTickerInfo
	LINKAUD   PairTickerInfo
	LINKETH   PairTickerInfo
	LINKEUR   PairTickerInfo
	LINKGBP   PairTickerInfo
	LINKUSD   PairTickerInfo
	LINKUSDT  PairTickerInfo
	LINKXBT   PairTickerInfo
	LSKETH    PairTickerInfo
	LSKEUR    PairTickerInfo
	LSKUSD    PairTickerInfo
	LSKXBT    PairTickerInfo
	LTCAUD    PairTickerInfo
	LTCETH    PairTickerInfo
	LTCGBP    PairTickerInfo
	LTCUSDT   PairTickerInfo
	MANAETH   PairTickerInfo
	MANAEUR   PairTickerInfo
	MANAUSD   PairTickerInfo
	MANAXBT   PairTickerInfo
	NANOETH   PairTickerInfo
	NANOEUR   PairTickerInfo
	NANOUSD   PairTickerInfo
	NANOXBT   PairTickerInfo
	OMGETH    PairTickerInfo
	OMGEUR    PairTickerInfo
	OMGUSD    PairTickerInfo
	OMGXBT    PairTickerInfo
	OXTETH    PairTickerInfo
	OXTEUR    PairTickerInfo
	OXTUSD    PairTickerInfo
	OXTXBT    PairTickerInfo
	PAXGETH   PairTickerInfo
	PAXGEUR   PairTickerInfo
	PAXGUSD   PairTickerInfo
	PAXGXBT   PairTickerInfo
	QTUMETH   PairTickerInfo
	QTUMEUR   PairTickerInfo
	QTUMUSD   PairTickerInfo
	QTUMXBT   PairTickerInfo
	REPV2ETH  PairTickerInfo
	REPV2EUR  PairTickerInfo
	REPV2USD  PairTickerInfo
	REPV2XBT  PairTickerInfo
	SCETH     PairTickerInfo
	SCEUR     PairTickerInfo
	SCUSD     PairTickerInfo
	SCXBT     PairTickerInfo
	SNXAUD    PairTickerInfo
	SNXETH    PairTickerInfo
	SNXEUR    PairTickerInfo
	SNXGBP    PairTickerInfo
	SNXUSD    PairTickerInfo
	SNXXBT    PairTickerInfo
	STORJETH  PairTickerInfo
	STORJEUR  PairTickerInfo
	STORJUSD  PairTickerInfo
	STORJXBT  PairTickerInfo
	TBTCETH   PairTickerInfo
	TBTCEUR   PairTickerInfo
	TBTCUSD   PairTickerInfo
	TBTCXBT   PairTickerInfo
	TRXETH    PairTickerInfo
	TRXEUR    PairTickerInfo
	TRXUSD    PairTickerInfo
	TRXXBT    PairTickerInfo
	UNIETH    PairTickerInfo
	UNIEUR    PairTickerInfo
	UNIUSD    PairTickerInfo
	UNIXBT    PairTickerInfo
	USDCAUD   PairTickerInfo
	USDCEUR   PairTickerInfo
	USDCGBP   PairTickerInfo
	USDCHF    PairTickerInfo
	USDCUSD   PairTickerInfo
	USDCUSDT  PairTickerInfo
	USDTAUD   PairTickerInfo
	USDTCAD   PairTickerInfo
	USDTCHF   PairTickerInfo
	USDTEUR   PairTickerInfo
	USDTGBP   PairTickerInfo
	USDTJPY   PairTickerInfo
	USDTZUSD  PairTickerInfo
	WAVESETH  PairTickerInfo
	WAVESEUR  PairTickerInfo
	WAVESUSD  PairTickerInfo
	WAVESXBT  PairTickerInfo
	XBTAUD    PairTickerInfo
	XBTCHF    PairTickerInfo
	XBTDAI    PairTickerInfo
	XBTUSDC   PairTickerInfo
	XBTUSDT   PairTickerInfo
	XDGEUR    PairTickerInfo
	XDGUSD    PairTickerInfo
	XETCXETH  PairTickerInfo
	XETCXXBT  PairTickerInfo
	XETCZEUR  PairTickerInfo
	XETCZUSD  PairTickerInfo
	XETHXXBT  PairTickerInfo
	XETHXXBTd PairTickerInfo `json:"XETHXXBT.d"`
	XETHZCAD  PairTickerInfo
	XETHZCADd PairTickerInfo `json:"XETHZCAD.d"`
	XETHZEUR  PairTickerInfo
	XETHZEURd PairTickerInfo `json:"XETHZEUR.d"`
	XETHZGBP  PairTickerInfo
	XETHZGBPd PairTickerInfo `json:"XETHZGBP.d"`
	XETHZJPY  PairTickerInfo
	XETHZJPYd PairTickerInfo `json:"XETHZJPY.d"`
	XETHZUSD  PairTickerInfo
	XETHZUSDd PairTickerInfo `json:"XETHZUSD.d"`
	XLTCXXBT  PairTickerInfo
	XLTCZEUR  PairTickerInfo
	XLTCZJPY  PairTickerInfo
	XLTCZUSD  PairTickerInfo
	XMLNXETH  PairTickerInfo
	XMLNXXBT  PairTickerInfo
	XMLNZEUR  PairTickerInfo
	XMLNZUSD  PairTickerInfo
	XREPXETH  PairTickerInfo
	XREPXXBT  PairTickerInfo
	XREPZEUR  PairTickerInfo
	XREPZUSD  PairTickerInfo
	XRPAUD    PairTickerInfo
	XRPETH    PairTickerInfo
	XRPGBP    PairTickerInfo
	XRPUSDT   PairTickerInfo
	XTZAUD    PairTickerInfo
	XTZETH    PairTickerInfo
	XTZEUR    PairTickerInfo
	XTZGBP    PairTickerInfo
	XTZUSD    PairTickerInfo
	XTZXBT    PairTickerInfo
	XXBTZCAD  PairTickerInfo
	XXBTZCADd PairTickerInfo `json:"XXBTZCAD.d"`
	XXBTZEUR  PairTickerInfo
	XXBTZEURd PairTickerInfo `json:"XXBTZEUR.d"`
	XXBTZGBP  PairTickerInfo
	XXBTZGBPd PairTickerInfo `json:"XXBTZGBP.d"`
	XXBTZJPY  PairTickerInfo
	XXBTZJPYd PairTickerInfo `json:"XXBTZJPY.d"`
	XXBTZUSD  PairTickerInfo
	XXBTZUSDd PairTickerInfo `json:"XXBTZUSD.d"`
	XXDGXXBT  PairTickerInfo
	XXLMXXBT  PairTickerInfo
	XXLMZAUD  PairTickerInfo
	XXLMZEUR  PairTickerInfo
	XXLMZGBP  PairTickerInfo
	XXLMZUSD  PairTickerInfo
	XXMRXXBT  PairTickerInfo
	XXMRZEUR  PairTickerInfo
	XXMRZUSD  PairTickerInfo
	XXRPXXBT  PairTickerInfo
	XXRPZCAD  PairTickerInfo
	XXRPZEUR  PairTickerInfo
	XXRPZJPY  PairTickerInfo
	XXRPZUSD  PairTickerInfo
	XZECXXBT  PairTickerInfo
	XZECZEUR  PairTickerInfo
	XZECZUSD  PairTickerInfo
	YFIAUD    PairTickerInfo
	YFIETH    PairTickerInfo
	YFIEUR    PairTickerInfo
	YFIGBP    PairTickerInfo
	YFIUSD    PairTickerInfo
	YFIXBT    PairTickerInfo
	ZEURZUSD  PairTickerInfo
	ZGBPZUSD  PairTickerInfo
	ZUSDZCAD  PairTickerInfo
	ZUSDZJPY  PairTickerInfo
}

TickerResponse includes the requested ticker pairs

func (*TickerResponse) GetPairTickerInfo

func (v *TickerResponse) GetPairTickerInfo(pair string) PairTickerInfo

GetPairTickerInfo is a helper method that returns given `pair`'s `PairTickerInfo`

type TimeResponse

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

TimeResponse represents the server's time

type TradeBalanceResponse

type TradeBalanceResponse struct {
	EquivalentBalance         float64 `json:"eb,string"`
	TradeBalance              float64 `json:"tb,string"`
	MarginOP                  float64 `json:"m,string"`
	UnrealizedNetProfitLossOP float64 `json:"n,string"`
	CostBasisOP               float64 `json:"c,string"`
	CurrentValuationOP        float64 `json:"v,string"`
	Equity                    float64 `json:"e,string"`
	FreeMargin                float64 `json:"mf,string"`
	MarginLevel               float64 `json:"ml,string"`
}

TradeBalanceResponse struct used as the response for the TradeBalance method

type TradeHistoryInfo

type TradeHistoryInfo struct {
	TransactionID string  `json:"ordertxid"`
	PostxID       string  `json:"postxid"`
	AssetPair     string  `json:"pair"`
	Time          float64 `json:"time"`
	Type          string  `json:"type"`
	OrderType     string  `json:"ordertype"`
	Price         float64 `json:"price,string"`
	Cost          float64 `json:"cost,string"`
	Fee           float64 `json:"fee,string"`
	Volume        float64 `json:"vol,string"`
	Margin        float64 `json:"margin,string"`
	Misc          string  `json:"misc"`
}

TradeHistoryInfo represents a transaction

type TradeInfo

type TradeInfo struct {
	Price         string
	PriceFloat    float64
	Volume        string
	VolumeFloat   float64
	Time          int64
	Buy           bool
	Sell          bool
	Market        bool
	Limit         bool
	Miscellaneous string
}

TradeInfo represents a trades information

type TradeVolumeResponse

type TradeVolumeResponse struct {
	Volume    float64 `json:"volume,string"`
	Currency  string  `json:"currency"`
	Fees      Fees    `json:"fees"`
	FeesMaker Fees    `json:"fees_maker"`
}

TradeVolumeResponse represents the response for trade volume

type TradesHistoryResponse

type TradesHistoryResponse struct {
	Trades map[string]TradeHistoryInfo `json:"trades"`
	Count  int                         `json:"count"`
}

TradesHistoryResponse represents a list of executed trade

type TradesResponse

type TradesResponse struct {
	Last   int64
	Trades []TradeInfo
}

TradesResponse represents a list of the last trades

type WithdrawInfoResponse

type WithdrawInfoResponse struct {
	Method string    `json:"method"`
	Limit  big.Float `json:"limit"`
	Amount big.Float `json:"amount"`
	Fee    big.Float `json:"fee"`
}

WithdrawInfoResponse is the response type showing withdrawal information for a selected withdrawal method.

type WithdrawResponse

type WithdrawResponse struct {
	RefID string `json:"refid"`
}

WithdrawResponse is the response type of a Withdraw query to the Kraken API.

Jump to

Keyboard shortcuts

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