Help us shape the future of Go! Take the 2026 Go Developer Survey

kraken

package module
v0.0.0-...-407db11 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: MIT Imports: 7 Imported by: 0

README

kraken

build Go Report Card Go Reference

A CLI and Go Client for the Kaken API.

Note that this project is a work in progress. It is not ready for public use yet.

Usage

CLI

There is still a lot of work to be done for the CLI, check back later for installation and usage instructions.

Go Client

kraken can also be used as a Go library to interact with Kraken's API.

go get -u github.com/shaunbennett/kraken

Now you can use kraken in your application:

import "github.com/shaunbennett/kraken"

api := kraken.New("API_KEY")

The Go client provides types functions for each API call in the Kraken API. If needed, you can also make API calls directly, deserializing into your own type or raw json values.

Examples

See the examples folder for small examples using both the CLI and library.

License

This code is licensed under the MIT License.

Documentation

Index

Constants

View Source
const AssetCurrency = "currency"

The asset class for currencies TODO: Can't find documentation on other asset classes, do they exist?

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	// Alternative name for the asset
	AltName string `json:"altname"`
	// The asset class
	Class string `json:"aclass"`
	// Number of decimals used for record keeping
	Decimals int `json:"decimals"`
	// Number of decimals used for output display
	DisplayDecimals int `json:"display_decimals"`
}

An Asset inside of Kraken's API

type AssetOptions

type AssetOptions struct {
	// The info for assets to retrieve from the server. Defaults to all info.
	Info string
	// The asset class to retrieve data for. Defaults to "currency".
	AssetClass string
	// Assets to retrieve data for. Defaults to all assets if none are specified.
	Assets []string
}

AssetOptions represent the options that can be used when retrieving asset data

func (AssetOptions) QueryString

func (a AssetOptions) QueryString() string

type AssetPair

type AssetPair struct {
	// Alternative pair name
	AltName string `json:"altname"`
	// WebSocket pair name (if available)
	WebSocketName string `json:"wsname"`
	// Asset class of the base component
	ClassBase string `json:"aclass_base"`
	// Asset id of the base component
	Base string `json:"base"`
	// Asset class of the quote component
	ClassQuote string `json:"aclass_quote"`
	// Asset id of the quote component
	Quote string `json:"quote"`
	// Volume lot size
	Lot string `json:"lot"`
	// Scaling decimal places for the pair
	PairDecimals int `json:"pair_decimals"`
	// Scaling decimal places for volume
	LotDecimals int `json:"lot_decimals"`
	// Amount to multiply the lot volume by to get the currency volume
	LotMultiplier int `json:"lot_multiplier"`
	// Array of possible leverage amounts when buying
	LeverageBuy []int `json:"leverage_buy"`
	// Array of possible leverage amounts when selling
	LeverageSell []int `json:"leverage_sell"`
	// Fee schedule in the form [[volume, percent fee], ...]
	Fees [][]float32 `json:"fees"`
	// Maker fee schedule in the form [[volume, percent fee], ...]
	FeesMaker [][]float32 `json:"fees_maker"`
	// Volume discount currency
	FeeVolumeCurrency string `json:"fee_volume_currency"`
	// Margin call level
	MarginCall int `json:"margin_call"`
	// Stop/liquidation margin level
	MarginStop int `json:"margin_stop"`
	// Minimum order volume for the pair
	OrderMin string `json:"ordermin"`
}

A tradable asset pair

type AssetPairOptions

type AssetPairOptions struct {
	Info  string
	Pairs []string
}

func (AssetPairOptions) QueryString

func (a AssetPairOptions) QueryString() string

type AssetPairs

type AssetPairs map[string]AssetPair

A map of asset pair ids to their data

type Assets

type Assets map[string]Asset

A map of asset names to their data

type Error

type Error []string

Error represents a list of error strings returned by the kraken api TODO: Parse and handle errors sent back from the Kraken API

type Kraken

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

func New

func New() *Kraken

func (*Kraken) AssetPairs

func (k *Kraken) AssetPairs(opts AssetPairOptions) (pairs AssetPairs, err error)

func (*Kraken) Assets

func (k *Kraken) Assets(opts AssetOptions) (assets Assets, err error)

func (*Kraken) ServerTime

func (k *Kraken) ServerTime() (time.Time, error)

type Response

type Response struct {
	Errors []string    `json:"error"`
	Result interface{} `json:"result"`
}

A Response represents the json structure that the Kraken API outputs. All API outputs are wrapped.

type ServerTime

type ServerTime struct {
	UnixTime int64 `json:"unixtime"`
}

Kraken: /0/public/Time result

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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