kraken

package
v0.0.0-...-eb07c7e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2019 License: MIT Imports: 22 Imported by: 0

README

GoCryptoTrader package Kraken

Build Status Software License GoDoc Coverage Status Go Report Card

This kraken package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progresss on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Kraken Exchange

Current Features
  • REST Support
How to enable
  // Exchanges will be abstracted out in further updates and examples will be
  // supplied then
How to do REST public/private calls
  • If enabled via "configuration".json file the exchange will be added to the IBotExchange array in the go var bot Bot and you will only be able to use the wrapper interface functions for accessing exchange data. View routines.go for an example of integration usage with GoCryptoTrader. Rudimentary example below:

main.go

var k exchange.IBotExchange

for i := range bot.exchanges {
  if bot.exchanges[i].GetName() == "Kraken" {
    k = bot.exchanges[i]
  }
}

// Public calls - wrapper functions

// Fetches current ticker information
tick, err := k.GetTickerPrice()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := k.GetOrderbookEx()
if err != nil {
  // Handle error
}

// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
// set and AuthenticatedAPISupport is set to true

// Fetches current account information
accountInfo, err := k.GetAccountInfo()
if err != nil {
  // Handle error
}
  • If enabled via individually importing package, rudimentary example below:
// Public calls

// Fetches current ticker information
ticker, err := k.GetTicker()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := k.GetOrderBook()
if err != nil {
  // Handle error
}

// Private calls - make sure your APIKEY and APISECRET are set and
// AuthenticatedAPISupport is set to true

// GetUserInfo returns account info
accountInfo, err := k.GetUserInfo(...)
if err != nil {
  // Handle error
}

// Submits an order and the exchange and returns its tradeID
tradeID, err := k.Trade(...)
if err != nil {
  // Handle error
}
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DepositFees = map[currency.Code]float64{
	currency.XTZ: 0.05,
}

DepositFees the large list of predefined deposit fees Prone to change

View Source
var WithdrawalFees = map[currency.Code]float64{
	currency.ZUSD: 5,
	currency.ZEUR: 5,
	currency.USD:  5,
	currency.EUR:  5,
	currency.REP:  0.01,
	currency.XXBT: 0.0005,
	currency.BTC:  0.0005,
	currency.XBT:  0.0005,
	currency.BCH:  0.0001,
	currency.ADA:  0.3,
	currency.DASH: 0.005,
	currency.XDG:  2,
	currency.EOS:  0.05,
	currency.ETH:  0.005,
	currency.ETC:  0.005,
	currency.GNO:  0.005,
	currency.ICN:  0.2,
	currency.LTC:  0.001,
	currency.MLN:  0.003,
	currency.XMR:  0.05,
	currency.QTUM: 0.01,
	currency.XRP:  0.02,
	currency.XLM:  0.00002,
	currency.USDT: 5,
	currency.XTZ:  0.05,
	currency.ZEC:  0.0001,
}

WithdrawalFees the large list of predefined withdrawal fees Prone to change

Functions

func GetError

func GetError(apiErrors []string) error

GetError parse Exchange errors in response and return the first one Error format from API doc:

error = array of error messages in the format of:
    <char-severity code><string-error category>:<string-error type>[:<string-extra info>]
    severity code can be E for error or W for warning

Types

type AddOrderOptions

type AddOrderOptions struct {
	UserRef        int32
	Oflags         string
	StartTm        string
	ExpireTm       string
	CloseOrderType string
	ClosePrice     float64
	ClosePrice2    float64
	Validate       bool
}

AddOrderOptions represents the AddOrder options

type AddOrderResponse

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

AddOrderResponse type

type Asset

type Asset struct {
	Altname         string `json:"altname"`
	AclassBase      string `json:"aclass_base"`
	Decimals        int    `json:"decimals"`
	DisplayDecimals int    `json:"display_decimals"`
}

Asset holds asset information

type AssetPairs

type AssetPairs struct {
	Altname           string      `json:"altname"`
	AclassBase        string      `json:"aclass_base"`
	Base              string      `json:"base"`
	AclassQuote       string      `json:"aclass_quote"`
	Quote             string      `json:"quote"`
	Lot               string      `json:"lot"`
	PairDecimals      int         `json:"pair_decimals"`
	LotDecimals       int         `json:"lot_decimals"`
	LotMultiplier     int         `json:"lot_multiplier"`
	LeverageBuy       []int       `json:"leverage_buy"`
	LeverageSell      []int       `json:"leverage_sell"`
	Fees              [][]float64 `json:"fees"`
	FeesMaker         [][]float64 `json:"fees_maker"`
	FeeVolumeCurrency string      `json:"fee_volume_currency"`
	MarginCall        int         `json:"margin_call"`
	MarginStop        int         `json:"margin_stop"`
}

AssetPairs holds asset pair information

type CancelOrderResponse

type CancelOrderResponse struct {
	Count   int64       `json:"count"`
	Pending interface{} `json:"pending"`
}

CancelOrderResponse type

type ClosedOrders

type ClosedOrders struct {
	Closed map[string]OrderInfo `json:"closed"`
	Count  int64                `json:"count"`
}

ClosedOrders type

type DepositAddress

type DepositAddress struct {
	Address    string `json:"address"`
	ExpireTime int64  `json:"expiretm,string"`
	New        bool   `json:"new"`
}

DepositAddress defines a deposit address

type DepositMethods

type DepositMethods struct {
	Method          string      `json:"method"`
	Limit           interface{} `json:"limit"` // If no limit amount, this comes back as boolean
	Fee             float64     `json:"fee,string"`
	AddressSetupFee float64     `json:"address-setup-fee,string"`
}

DepositMethods Used to check deposit fees

type GetClosedOrdersOptions

type GetClosedOrdersOptions struct {
	Trades    bool
	UserRef   int32
	Start     string
	End       string
	Ofs       int64
	CloseTime string
}

GetClosedOrdersOptions type

type GetLedgersOptions

type GetLedgersOptions struct {
	Aclass string
	Asset  string
	Type   string
	Start  string
	End    string
	Ofs    int64
}

GetLedgersOptions type

type GetTradesHistoryOptions

type GetTradesHistoryOptions struct {
	Type   string
	Trades bool
	Start  string
	End    string
	Ofs    int64
}

GetTradesHistoryOptions type

type Kraken

type Kraken struct {
	exchange.Base
	WebsocketConn      *websocket.Conn
	CryptoFee, FiatFee float64
	// contains filtered or unexported fields
}

Kraken is the overarching type across the alphapoint package

func (*Kraken) AddOrder

func (k *Kraken) AddOrder(symbol, side, orderType string, volume, price, price2, leverage float64, args *AddOrderOptions) (AddOrderResponse, error)

AddOrder adds a new order for Kraken exchange

func (*Kraken) AuthenticateWebsocket

func (k *Kraken) AuthenticateWebsocket() error

AuthenticateWebsocket sends an authentication message to the websocket

func (*Kraken) CancelAllOrders

CancelAllOrders cancels all orders associated with a currency pair

func (*Kraken) CancelExistingOrder

func (k *Kraken) CancelExistingOrder(txid string) (CancelOrderResponse, error)

CancelExistingOrder cancels order by orderID

func (*Kraken) CancelOrder

func (k *Kraken) CancelOrder(order *exchange.OrderCancellation) error

CancelOrder cancels an order by its corresponding ID number

func (*Kraken) GenerateDefaultSubscriptions

func (k *Kraken) GenerateDefaultSubscriptions()

GenerateDefaultSubscriptions Adds default subscriptions to websocket to be handled by ManageSubscriptions()

func (*Kraken) GetAccountInfo

func (k *Kraken) GetAccountInfo() (exchange.AccountInfo, error)

GetAccountInfo retrieves balances for all enabled currencies for the Kraken exchange - to-do

func (*Kraken) GetActiveOrders

func (k *Kraken) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error)

GetActiveOrders retrieves any orders that are active/open

func (*Kraken) GetAssetPairs

func (k *Kraken) GetAssetPairs() (map[string]AssetPairs, error)

GetAssetPairs returns a full asset pair list

func (*Kraken) GetAssets

func (k *Kraken) GetAssets() (map[string]Asset, error)

GetAssets returns a full asset list

func (*Kraken) GetBalance

func (k *Kraken) GetBalance() (map[string]float64, error)

GetBalance returns your balance associated with your keys

func (*Kraken) GetClosedOrders

func (k *Kraken) GetClosedOrders(args GetClosedOrdersOptions) (ClosedOrders, error)

GetClosedOrders returns a list of closed orders

func (*Kraken) GetCryptoDepositAddress

func (k *Kraken) GetCryptoDepositAddress(method, code string) (string, error)

GetCryptoDepositAddress returns a deposit address for a cryptocurrency

func (*Kraken) GetDepositAddress

func (k *Kraken) GetDepositAddress(cryptocurrency currency.Code, _ string) (string, error)

GetDepositAddress returns a deposit address for a specified currency

func (*Kraken) GetDepositMethods

func (k *Kraken) GetDepositMethods(currency string) ([]DepositMethods, error)

GetDepositMethods gets withdrawal fees

func (*Kraken) GetDepth

func (k *Kraken) GetDepth(symbol string) (Orderbook, error)

GetDepth returns the orderbook for a particular currency

func (*Kraken) GetExchangeHistory

func (k *Kraken) GetExchangeHistory(p currency.Pair, assetType string) ([]exchange.TradeHistory, error)

GetExchangeHistory returns historic trade data since exchange opening.

func (*Kraken) GetFee

func (k *Kraken) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error)

GetFee returns an estimate of fee based on type of transaction

func (*Kraken) GetFeeByType

func (k *Kraken) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error)

GetFeeByType returns an estimate of fee based on type of transaction

func (*Kraken) GetFundingHistory

func (k *Kraken) GetFundingHistory() ([]exchange.FundHistory, error)

GetFundingHistory returns funding history, deposits and withdrawals

func (*Kraken) GetLedgers

func (k *Kraken) GetLedgers(args ...GetLedgersOptions) (Ledgers, error)

GetLedgers returns current ledgers

func (*Kraken) GetOHLC

func (k *Kraken) GetOHLC(symbol string) ([]OpenHighLowClose, error)

GetOHLC returns an array of open high low close values of a currency pair

func (*Kraken) GetOpenOrders

func (k *Kraken) GetOpenOrders(args OrderInfoOptions) (OpenOrders, error)

GetOpenOrders returns all current open orders

func (*Kraken) GetOrderHistory

func (k *Kraken) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]exchange.OrderDetail, error)

GetOrderHistory retrieves account order information Can Limit response to specific order status

func (*Kraken) GetOrderInfo

func (k *Kraken) GetOrderInfo(orderID string) (exchange.OrderDetail, error)

GetOrderInfo returns information on a current open order

func (*Kraken) GetOrderbookEx

func (k *Kraken) GetOrderbookEx(p currency.Pair, assetType string) (orderbook.Base, error)

GetOrderbookEx returns orderbook base on the currency pair

func (*Kraken) GetServerTime

func (k *Kraken) GetServerTime() (TimeResponse, error)

GetServerTime returns current server time

func (*Kraken) GetSpread

func (k *Kraken) GetSpread(symbol string) ([]Spread, error)

GetSpread returns the full spread on Kraken

func (*Kraken) GetSubscriptions

func (k *Kraken) GetSubscriptions() ([]exchange.WebsocketChannelSubscription, error)

GetSubscriptions returns a copied list of subscriptions

func (*Kraken) GetTicker

func (k *Kraken) GetTicker(symbol string) (Ticker, error)

GetTicker returns ticker information from kraken

func (*Kraken) GetTickerPrice

func (k *Kraken) GetTickerPrice(p currency.Pair, assetType string) (ticker.Price, error)

GetTickerPrice returns the ticker for a currency pair

func (*Kraken) GetTickers

func (k *Kraken) GetTickers(pairList string) (Tickers, error)

GetTickers supports fetching multiple tickers from Kraken pairList must be in the format pairs separated by commas ("LTCUSD,ETCUSD")

func (*Kraken) GetTradeBalance

func (k *Kraken) GetTradeBalance(args ...TradeBalanceOptions) (TradeBalanceInfo, error)

GetTradeBalance returns full information about your trades on Kraken

func (*Kraken) GetTradeVolume

func (k *Kraken) GetTradeVolume(feeinfo bool, symbol ...string) (TradeVolumeResponse, error)

GetTradeVolume returns your trade volume by currency

func (*Kraken) GetTrades

func (k *Kraken) GetTrades(symbol string) ([]RecentTrades, error)

GetTrades returns current trades on Kraken

func (*Kraken) GetTradesHistory

func (k *Kraken) GetTradesHistory(args ...GetTradesHistoryOptions) (TradesHistory, error)

GetTradesHistory returns trade history information

func (*Kraken) GetWebsocket

func (k *Kraken) GetWebsocket() (*exchange.Websocket, error)

GetWebsocket returns a pointer to the exchange websocket

func (*Kraken) GetWithdrawInfo

func (k *Kraken) GetWithdrawInfo(currency string, amount float64) (WithdrawInformation, error)

GetWithdrawInfo gets withdrawal fees

func (*Kraken) ModifyOrder

func (k *Kraken) ModifyOrder(action *exchange.ModifyOrder) (string, error)

ModifyOrder will allow of changing orderbook placement and limit to market conversion

func (*Kraken) OpenPositions

func (k *Kraken) OpenPositions(docalcs bool, txids ...string) (map[string]Position, error)

OpenPositions returns current open positions

func (*Kraken) QueryLedgers

func (k *Kraken) QueryLedgers(id string, ids ...string) (map[string]LedgerInfo, error)

QueryLedgers queries an individual ledger by ID

func (*Kraken) QueryOrdersInfo

func (k *Kraken) QueryOrdersInfo(args OrderInfoOptions, txid string, txids ...string) (map[string]OrderInfo, error)

QueryOrdersInfo returns order information

func (*Kraken) QueryTrades

func (k *Kraken) QueryTrades(trades bool, txid string, txids ...string) (map[string]TradeInfo, error)

QueryTrades returns information on a specific trade

func (*Kraken) Run

func (k *Kraken) Run()

Run implements the Kraken wrapper

func (*Kraken) SendAuthenticatedHTTPRequest

func (k *Kraken) SendAuthenticatedHTTPRequest(method string, params url.Values, result interface{}) (err error)

SendAuthenticatedHTTPRequest sends an authenticated HTTP request

func (*Kraken) SendHTTPRequest

func (k *Kraken) SendHTTPRequest(path string, result interface{}) error

SendHTTPRequest sends an unauthenticated HTTP requests

func (*Kraken) SetDefaults

func (k *Kraken) SetDefaults()

SetDefaults sets current default settings

func (*Kraken) Setup

func (k *Kraken) Setup(exch *config.ExchangeConfig)

Setup sets current exchange configuration

func (*Kraken) Start

func (k *Kraken) Start(wg *sync.WaitGroup)

Start starts the Kraken go routine

func (*Kraken) SubmitOrder

func (k *Kraken) SubmitOrder(p currency.Pair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, _ string) (exchange.SubmitOrderResponse, error)

SubmitOrder submits a new order

func (*Kraken) Subscribe

func (k *Kraken) Subscribe(channelToSubscribe exchange.WebsocketChannelSubscription) error

Subscribe sends a websocket message to receive data from the channel

func (*Kraken) SubscribeToWebsocketChannels

func (k *Kraken) SubscribeToWebsocketChannels(channels []exchange.WebsocketChannelSubscription) error

SubscribeToWebsocketChannels appends to ChannelsToSubscribe which lets websocket.manageSubscriptions handle subscribing

func (*Kraken) Unsubscribe

func (k *Kraken) Unsubscribe(channelToSubscribe exchange.WebsocketChannelSubscription) error

Unsubscribe sends a websocket message to stop receiving data from the channel

func (*Kraken) UnsubscribeToWebsocketChannels

func (k *Kraken) UnsubscribeToWebsocketChannels(channels []exchange.WebsocketChannelSubscription) error

UnsubscribeToWebsocketChannels removes from ChannelsToSubscribe which lets websocket.manageSubscriptions handle unsubscribing

func (*Kraken) UpdateOrderbook

func (k *Kraken) UpdateOrderbook(p currency.Pair, assetType string) (orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*Kraken) UpdateTicker

func (k *Kraken) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*Kraken) Withdraw

func (k *Kraken) Withdraw(asset, key string, amount float64) (string, error)

Withdraw withdraws funds

func (*Kraken) WithdrawCancel

func (k *Kraken) WithdrawCancel(c currency.Code, refID string) (bool, error)

WithdrawCancel sends a withdrawal cancelation request

func (*Kraken) WithdrawCryptocurrencyFunds

func (k *Kraken) WithdrawCryptocurrencyFunds(withdrawRequest *exchange.WithdrawRequest) (string, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal Populate exchange.WithdrawRequest.TradePassword with withdrawal key name, as set up on your account

func (*Kraken) WithdrawFiatFunds

func (k *Kraken) WithdrawFiatFunds(withdrawRequest *exchange.WithdrawRequest) (string, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*Kraken) WithdrawFiatFundsToInternationalBank

func (k *Kraken) WithdrawFiatFundsToInternationalBank(withdrawRequest *exchange.WithdrawRequest) (string, error)

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

func (*Kraken) WithdrawStatus

func (k *Kraken) WithdrawStatus(c currency.Code, method string) ([]WithdrawStatusResponse, error)

WithdrawStatus gets the status of recent withdrawals

func (*Kraken) WsConnect

func (k *Kraken) WsConnect() error

WsConnect initiates a websocket connection

func (*Kraken) WsHandleData

func (k *Kraken) WsHandleData()

WsHandleData handles the read data from the websocket connection

func (*Kraken) WsHandleDataResponse

func (k *Kraken) WsHandleDataResponse(response WebsocketDataResponse)

WsHandleDataResponse classifies the WS response and sends to appropriate handler

func (*Kraken) WsHandleEventResponse

func (k *Kraken) WsHandleEventResponse(response *WebsocketEventResponse)

WsHandleEventResponse classifies the WS response and sends to appropriate handler

func (*Kraken) WsReadData

func (k *Kraken) WsReadData() (exchange.WebsocketResponse, error)

WsReadData reads data from the websocket connection

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  float64 `json:"amount,string"`
	Fee     float64 `json:"fee,string"`
	Balance float64 `json:"balance,string"`
}

LedgerInfo type

type Ledgers

type Ledgers struct {
	Ledger map[string]LedgerInfo `json:"ledger"`
	Count  int64                 `json:"count"`
}

Ledgers type

type OpenHighLowClose

type OpenHighLowClose struct {
	Time   float64
	Open   float64
	High   float64
	Low    float64
	Close  float64
	Vwap   float64
	Volume float64
	Count  float64
}

OpenHighLowClose contains ticker event information

type OpenOrders

type OpenOrders struct {
	Open  map[string]OrderInfo `json:"open"`
	Count int64                `json:"count"`
}

OpenOrders type

type OrderDescription

type OrderDescription struct {
	Close string `json:"close"`
	Order string `json:"order"`
}

OrderDescription represents an orders description

type OrderInfo

type OrderInfo struct {
	RefID    string  `json:"refid"`
	UserRef  int32   `json:"userref"`
	Status   string  `json:"status"`
	OpenTm   float64 `json:"opentm"`
	StartTm  float64 `json:"starttm"`
	ExpireTm float64 `json:"expiretm"`
	Descr    struct {
		Pair      string  `json:"pair"`
		Type      string  `json:"type"`
		OrderType string  `json:"ordertype"`
		Price     float64 `json:"price,string"`
		Price2    float64 `json:"price2,string"`
		Leverage  string  `json:"leverage"`
		Order     string  `json:"order"`
		Close     string  `json:"close"`
	} `json:"descr"`
	Vol        float64  `json:"vol,string"`
	VolExec    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"`
	Oflags     string   `json:"oflags"`
	Trades     []string `json:"trades"`
}

OrderInfo type

type OrderInfoOptions

type OrderInfoOptions struct {
	Trades  bool
	UserRef int32
}

OrderInfoOptions type

type Orderbook

type Orderbook struct {
	Bids []OrderbookBase
	Asks []OrderbookBase
}

Orderbook stores the bids and asks orderbook data

type OrderbookBase

type OrderbookBase struct {
	Price  float64
	Amount float64
}

OrderbookBase stores the orderbook price and amount data

type Position

type Position struct {
	Ordertxid  string  `json:"ordertxid"`
	Pair       string  `json:"pair"`
	Time       float64 `json:"time"`
	Type       string  `json:"type"`
	OrderType  string  `json:"ordertype"`
	Cost       float64 `json:"cost,string"`
	Fee        float64 `json:"fee,string"`
	Vol        float64 `json:"vol,string"`
	VolClosed  float64 `json:"vol_closed,string"`
	Margin     float64 `json:"margin,string"`
	Rollovertm int64   `json:"rollovertm,string"`
	Misc       string  `json:"misc"`
	Oflags     string  `json:"oflags"`
	PosStatus  string  `json:"posstatus"`
	Net        string  `json:"net"`
	Terms      string  `json:"terms"`
}

Position holds the opened position

type RecentTrades

type RecentTrades struct {
	Price         float64
	Volume        float64
	Time          float64
	BuyOrSell     string
	MarketOrLimit string
	Miscellaneous interface{}
}

RecentTrades holds recent trade data

type Spread

type Spread struct {
	Time float64
	Bid  float64
	Ask  float64
}

Spread holds the spread between trades

type Ticker

type Ticker struct {
	Ask    float64
	Bid    float64
	Last   float64
	Volume float64
	VWAP   float64
	Trades int64
	Low    float64
	High   float64
	Open   float64
}

Ticker is a standard ticker type

type TickerResponse

type TickerResponse struct {
	Ask    []string `json:"a"`
	Bid    []string `json:"b"`
	Last   []string `json:"c"`
	Volume []string `json:"v"`
	VWAP   []string `json:"p"`
	Trades []int64  `json:"t"`
	Low    []string `json:"l"`
	High   []string `json:"h"`
	Open   string   `json:"o"`
}

TickerResponse holds ticker information before its put into the Ticker struct

type Tickers

type Tickers map[string]Ticker

Tickers stores a map of tickers

type TimeResponse

type TimeResponse struct {
	Unixtime int64  `json:"unixtime"`
	Rfc1123  string `json:"rfc1123"`
}

TimeResponse type

type TradeBalanceInfo

type TradeBalanceInfo struct {
	EquivalentBalance float64 `json:"eb,string"` // combined balance of all currencies
	TradeBalance      float64 `json:"tb,string"` // combined balance of all equity currencies
	MarginAmount      float64 `json:"m,string"`  // margin amount of open positions
	Net               float64 `json:"n,string"`  // unrealized net profit/loss of open positions
	Equity            float64 `json:"e,string"`  // trade balance + unrealized net profit/loss
	FreeMargin        float64 `json:"mf,string"` // equity - initial margin (maximum margin available to open new positions)
	MarginLevel       float64 `json:"ml,string"` // (equity / initial margin) * 100
}

TradeBalanceInfo type

type TradeBalanceOptions

type TradeBalanceOptions struct {
	Aclass string
	Asset  string
}

TradeBalanceOptions type

type TradeInfo

type TradeInfo struct {
	OrderTxID string   `json:"ordertxid"`
	Pair      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"`
	Vol       float64  `json:"vol,string"`
	Margin    float64  `json:"margin,string"`
	Misc      string   `json:"misc"`
	PosTxID   string   `json:"postxid"`
	Cprice    float64  `json:"cprice,string"`
	Cfee      float64  `json:"cfee,string"`
	Cvol      float64  `json:"cvol,string"`
	Cmargin   float64  `json:"cmargin,string"`
	Trades    []string `json:"trades"`
	PosStatus string   `json:"posstatus"`
}

TradeInfo type

type TradeVolumeFee

type TradeVolumeFee 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"`
}

TradeVolumeFee type

type TradeVolumeResponse

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

TradeVolumeResponse type

type TradesHistory

type TradesHistory struct {
	Trades map[string]TradeInfo `json:"trades"`
	Count  int64                `json:"count"`
}

TradesHistory type

type WebsocketChannelData

type WebsocketChannelData struct {
	Subscription string
	Pair         currency.Pair
	ChannelID    int64
}

WebsocketChannelData Holds relevant data for channels to identify what we're doing

type WebsocketDataResponse

type WebsocketDataResponse []interface{}

WebsocketDataResponse defines a websocket data type

type WebsocketErrorResponse

type WebsocketErrorResponse struct {
	ErrorMessage string `json:"errorMessage"`
}

WebsocketErrorResponse defines a websocket error response

type WebsocketEventResponse

type WebsocketEventResponse struct {
	Event        string                            `json:"event"`
	Status       string                            `json:"status"`
	Pair         currency.Pair                     `json:"pair,omitempty"`
	RequestID    int64                             `json:"reqid,omitempty"` // Optional, client originated ID reflected in response message.
	Subscription WebsocketSubscriptionResponseData `json:"subscription,omitempty"`
	ChannelName  string                            `json:"channelName,omitempty"`
	WebsocketSubscriptionEventResponse
	WebsocketStatusResponse
	WebsocketErrorResponse
}

WebsocketEventResponse holds all data response types

type WebsocketStatusResponse

type WebsocketStatusResponse struct {
	ConnectionID float64 `json:"connectionID"`
	Version      string  `json:"version"`
}

WebsocketStatusResponse defines a websocket status response

type WebsocketSubscriptionData

type WebsocketSubscriptionData struct {
	Name     string `json:"name,omitempty"`     // ticker|ohlc|trade|book|spread|*, * for all (ohlc interval value is 1 if all channels subscribed)
	Interval int64  `json:"interval,omitempty"` // Optional - Time interval associated with ohlc subscription in minutes. Default 1. Valid Interval values: 1|5|15|30|60|240|1440|10080|21600
	Depth    int64  `json:"depth,omitempty"`    // Optional - depth associated with book subscription in number of levels each side, default 10. Valid Options are: 10, 25, 100, 500, 1000
}

WebsocketSubscriptionData contains details on WS channel

type WebsocketSubscriptionEventRequest

type WebsocketSubscriptionEventRequest struct {
	Event        string                    `json:"event"`           // subscribe
	RequestID    int64                     `json:"reqid,omitempty"` // Optional, client originated ID reflected in response message.
	Pairs        []string                  `json:"pair"`            // Array of currency pairs (pair1,pair2,pair3).
	Subscription WebsocketSubscriptionData `json:"subscription,omitempty"`
}

WebsocketSubscriptionEventRequest handles WS subscription events

type WebsocketSubscriptionEventResponse

type WebsocketSubscriptionEventResponse struct {
	ChannelID int64 `json:"channelID"`
}

WebsocketSubscriptionEventResponse defines a websocket socket event response

type WebsocketSubscriptionResponseData

type WebsocketSubscriptionResponseData struct {
	Name string `json:"name"`
}

WebsocketSubscriptionResponseData defines a websocket subscription response

type WebsocketUnsubscribeByChannelIDEventRequest

type WebsocketUnsubscribeByChannelIDEventRequest struct {
	Event     string   `json:"event"`           // unsubscribe
	RequestID int64    `json:"reqid,omitempty"` // Optional, client originated ID reflected in response message.
	Pairs     []string `json:"pair,omitempty"`  // Array of currency pairs (pair1,pair2,pair3).
	ChannelID int64    `json:"channelID,omitempty"`
}

WebsocketUnsubscribeByChannelIDEventRequest handles WS unsubscribe events

type WithdrawInformation

type WithdrawInformation struct {
	Method string  `json:"method"`
	Limit  float64 `json:"limit,string"`
	Fee    float64 `json:"fee,string"`
}

WithdrawInformation Used to check withdrawal fees

type WithdrawStatusResponse

type WithdrawStatusResponse struct {
	Method string  `json:"method"`
	Aclass string  `json:"aclass"`
	Asset  string  `json:"asset"`
	Refid  string  `json:"refid"`
	TxID   string  `json:"txid"`
	Info   string  `json:"info"`
	Amount float64 `json:"amount,string"`
	Fee    float64 `json:"fee,string"`
	Time   float64 `json:"time"`
	Status string  `json:"status"`
}

WithdrawStatusResponse defines a withdrawal status response

Jump to

Keyboard shortcuts

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