Documentation ¶
Index ¶
- Constants
- type AddOrderResponse
- type Asset
- type AssetPair
- type BalanceResponse
- type CancelResponse
- type Candle
- type CloseLevel
- type ClosedOrdersResponse
- type Fees
- type GetWebSocketTokenResponse
- type Kraken
- func (api *Kraken) AddOrder(pair string, side string, orderType string, volume float64, ...) (AddOrderResponse, error)
- func (api *Kraken) AssetPairs(pairs ...string) (map[string]AssetPair, error)
- func (api *Kraken) Assets(assets ...string) (map[string]Asset, error)
- func (api *Kraken) Cancel(orderID string) (CancelResponse, error)
- func (api *Kraken) Candles(pair string, interval int64, since int64) (OHLCResponse, error)
- func (api *Kraken) GetAccountBalances() (BalanceResponse, error)
- func (api *Kraken) GetClosedOrders(needTrades bool, userRef string, start int64, end int64) (ClosedOrdersResponse, error)
- func (api *Kraken) GetLedgersInfo(ledgerType string, start int64, end int64, assets ...string) (LedgerInfoResponse, error)
- func (api *Kraken) GetOpenOrders(needTrades bool, userRef string) (OpenOrdersResponse, error)
- func (api *Kraken) GetOpenPositions(docalcs bool, txIDs ...string) (map[string]Position, error)
- func (api *Kraken) GetOrderBook(pair string, depth int64) (map[string]OrderBook, error)
- func (api *Kraken) GetSpread(pair string, since int64) (SpreadResponse, error)
- func (api *Kraken) GetTradeBalance(baseAsset string) (TradeBalanceResponse, error)
- func (api *Kraken) GetTradeVolume(needFeeInfo bool, pairs ...string) (TradeVolumeResponse, error)
- func (api *Kraken) GetTrades(pair string, since int64) (TradeResponse, error)
- func (api *Kraken) GetTradesHistory(tradeType string, needTrades bool, start int64, end int64) (TradesHistoryResponse, error)
- func (api *Kraken) GetWebSocketsToken() (GetWebSocketTokenResponse, error)
- func (api *Kraken) QueryLedgers(ledgerIds ...string) (map[string]Ledger, error)
- func (api *Kraken) QueryOrders(needTrades bool, userRef string, txIDs ...string) (map[string]OrderInfo, error)
- func (api *Kraken) QueryTrades(trades bool, txIDs ...string) (map[string]PrivateTrade, error)
- func (api *Kraken) Ticker(pairs ...string) (map[string]Ticker, error)
- func (api *Kraken) Time() (TimeResponse, error)
- type KrakenResponse
- type Ledger
- type LedgerInfoResponse
- type Level
- type OHLCResponse
- type OpenOrdersResponse
- type OrderBook
- type OrderBookItem
- type OrderDescription
- type OrderInfo
- type Position
- type PrivateTrade
- type Spread
- type SpreadResponse
- type Ticker
- type TimeLevel
- type TimeResponse
- type Trade
- type TradeBalanceResponse
- type TradeResponse
- type TradeVolumeResponse
- type TradesHistoryResponse
Constants ¶
const ( // APIUrl - Kraken API Endpoint APIUrl = "https://api.kraken.com" // APIVersion - Kraken API Version Number APIVersion = "0" )
const ( Interval1m = 1 Interval5m = 5 Interval15m = 15 Interval30m = 30 Interval1h = 60 Interval4h = 240 Interval1d = 1440 Interval7d = 10080 Interval1M = 21600 )
Interval values
const ( TradeBuy = "b" TradeSell = "s" Buy = "buy" Sell = "sell" )
Order Sides
const ( TradeLimit = "l" TradeMarket = "m" Limit = "limit" Market = "market" )
Order types
const ( ADA = "ADA" ATOM = "ATOM" BCH = "BCH" BSV = "BSV" DASH = "DASH" EOS = "EOS" GNO = "GNO" KFEE = "KFEE" QTUM = "QTUM" USDT = "USDT" XDAO = "XDAO" XETC = "XETC" XETH = "XETH" XICN = "XICN" XLTC = "XLTC" XMLN = "XMLN" XNMC = "XNMC" XREP = "XREP" XTZ = "XTZ" XXBT = "XXBT" XXDG = "XXDG" XXLM = "XXLM" XXMR = "XXMR" XXRP = "XXRP" XXVN = "XXVN" XZEC = "XZEC" ZCAD = "ZCAD" ZEUR = "ZEUR" ZGBP = "ZGBP" ZJPY = "ZJPY" ZKRW = "ZKRW" ZUSD = "ZUSD" )
Assets
const ( TradeTypeAll = "all" TradeTypeAnyPosition = "any position" TradeTypeClosedPosition = "closed position" TradeTypeClosingPosition = "closing position" TradeTypeNoPosition = "no position" )
Trade types
const ( LedgerTypeAll = "all" LedgerTypeDeposit = "deposit" LedgerTypeWithdrawal = "withdrawal" LedgerTypeTrade = "trade" LedgerTypeMargin = "margin" LedgerTypeRollover = "rollover" )
Ledger types
const ( OTMarket = "market" OTLimit = "limit" // (price = limit price) OTStopLoss = "stop-loss" // (price = stop loss price) OTTakeProfi = "take-profit" // (price = take profit price) OTStopLossProfit = "stop-loss-profit" // (price = stop loss price, price2 = take profit price) OTStopLossProfitLimit = "stop-loss-profit-limit" // (price = stop loss price, price2 = take profit price) OTStopLossLimit = "stop-loss-limit" // (price = stop loss trigger price, price2 = triggered limit price) OTTakeProfitLimit = "take-profit-limit" // (price = take profit trigger price, price2 = triggered limit price) OTTrailingStop = "trailing-stop" // (price = trailing stop offset) OTTrailingStopLimit = "trailing-stop-limit" // (price = trailing stop offset, price2 = triggered limit offset) OTStopLossAndLimit = "stop-loss-and-limit" // (price = stop loss price, price2 = limit price) OTSettlePosition = "settle-position" )
OrderTypes for AddOrder
const ( StatusPending = "pending" StatusOpen = "open" StatusClosed = "closed" StatusCancelled = "canceled" StatusExpired = "expired" )
OrderStatuses
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 on AddOrder request
type Asset ¶
type Asset struct { AlternateName string `json:"altname"` AssetClass string `json:"aclass"` Decimals int `json:"decimals"` DisplayDecimals int `json:"display_decimals"` }
Asset - asset information
type AssetPair ¶
type AssetPair struct { Altname string `json:"altname"` AssetClassBase string `json:"aclass_base"` Base string `json:"base"` AssetClassQuote 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 []float64 `json:"leverage_buy"` LeverageSell []float64 `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"` WSName string `json:"wsname"` }
AssetPair - asset pair information
type BalanceResponse ¶
type BalanceResponse struct { ADA float64 `json:",string"` BCH float64 `json:",string"` BSV float64 `json:",string"` DASH float64 `json:",string"` EOS float64 `json:",string"` GNO float64 `json:",string"` KFEE float64 `json:",string"` QTUM float64 `json:",string"` USDT float64 `json:",string"` XDAO float64 `json:",string"` XETC float64 `json:",string"` XETH float64 `json:",string"` XICN float64 `json:",string"` XLTC float64 `json:",string"` XMLN float64 `json:",string"` XNMC float64 `json:",string"` XREP float64 `json:",string"` XXBT float64 `json:",string"` XXDG float64 `json:",string"` XXLM float64 `json:",string"` XXMR float64 `json:",string"` XXRP float64 `json:",string"` XXTZ float64 `json:",string"` XXVN float64 `json:",string"` XZEC float64 `json:",string"` ZCAD float64 `json:",string"` ZEUR float64 `json:",string"` ZGBP float64 `json:",string"` ZJPY float64 `json:",string"` ZKRW float64 `json:",string"` ZUSD float64 `json:",string"` }
BalanceResponse - response on account balance request
type CancelResponse ¶
CancelResponse - response on CancelOrder request
type Candle ¶
type Candle struct { Time int64 Open float64 `json:",string"` High float64 `json:",string"` Low float64 `json:",string"` Close float64 `json:",string"` VolumeWAP float64 `json:",string"` Volume float64 `json:",string"` Count int64 }
Candle - OHLC item
type CloseLevel ¶
CloseLevel - ticker structure for Close
func (*CloseLevel) UnmarshalJSON ¶
func (item *CloseLevel) UnmarshalJSON(buf []byte) error
UnmarshalJSON -
type ClosedOrdersResponse ¶
type ClosedOrdersResponse struct { Count int64 `json:"count"` Orders map[string]OrderInfo `json:"closed"` }
ClosedOrdersResponse - response on ClosedOrders request
type Fees ¶
type Fees 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"` }
Fees - structure of fees info
type GetWebSocketTokenResponse ¶
type GetWebSocketTokenResponse struct { Token string `json:"token"` Expires int64 `json:"expires"` }
GetWebSocketTokenResponse - response on GetWebSocketsToken request
type Kraken ¶
type Kraken struct {
// contains filtered or unexported fields
}
Kraken - object wraps API
func (*Kraken) AddOrder ¶
func (api *Kraken) AddOrder(pair string, side string, orderType string, volume float64, args map[string]interface{}) (AddOrderResponse, error)
AddOrder - method sends order to exchange
func (*Kraken) AssetPairs ¶
AssetPairs - Gets array of pair names and their info passed through `pairs` arg. `pairs` - array of needed pairs. All by default if empty array passed or `pairs` is nil.
func (*Kraken) Assets ¶
Assets - Gets info about assets passed through `assets` arg. `assets` - array of needed assets. All by default if empty array passed or `assets` is nil.
func (*Kraken) Cancel ¶
func (api *Kraken) Cancel(orderID string) (CancelResponse, error)
Cancel - method cancels order
func (*Kraken) GetAccountBalances ¶
func (api *Kraken) GetAccountBalances() (BalanceResponse, error)
GetAccountBalances - methods returns account balances
func (*Kraken) GetClosedOrders ¶
func (api *Kraken) GetClosedOrders(needTrades bool, userRef string, start int64, end int64) (ClosedOrdersResponse, error)
GetClosedOrders - returns account closed order
func (*Kraken) GetLedgersInfo ¶
func (api *Kraken) GetLedgersInfo(ledgerType string, start int64, end int64, assets ...string) (LedgerInfoResponse, error)
GetLedgersInfo - returns ledgers info
func (*Kraken) GetOpenOrders ¶
func (api *Kraken) GetOpenOrders(needTrades bool, userRef string) (OpenOrdersResponse, error)
GetOpenOrders - returns account open order
func (*Kraken) GetOpenPositions ¶
GetOpenPositions - returns list of open positions
func (*Kraken) GetOrderBook ¶
GetOrderBook - Gets order book for `pair` with `depth`
func (*Kraken) GetSpread ¶
func (api *Kraken) GetSpread(pair string, since int64) (SpreadResponse, error)
GetSpread - return array of pair name and recent spread data
func (*Kraken) GetTradeBalance ¶
func (api *Kraken) GetTradeBalance(baseAsset string) (TradeBalanceResponse, error)
GetTradeBalance - returns tradable balances info
func (*Kraken) GetTradeVolume ¶
func (api *Kraken) GetTradeVolume(needFeeInfo bool, pairs ...string) (TradeVolumeResponse, error)
GetTradeVolume - returns trade volumes
func (*Kraken) GetTrades ¶
func (api *Kraken) GetTrades(pair string, since int64) (TradeResponse, error)
GetTrades - returns trades on pair from since date
func (*Kraken) GetTradesHistory ¶
func (api *Kraken) GetTradesHistory(tradeType string, needTrades bool, start int64, end int64) (TradesHistoryResponse, error)
GetTradesHistory - returns account's trade history
func (*Kraken) GetWebSocketsToken ¶
func (api *Kraken) GetWebSocketsToken() (GetWebSocketTokenResponse, error)
GetWebSocketsToken - WebSockets authentication
func (*Kraken) QueryLedgers ¶
QueryLedgers - get ledgers by ID
func (*Kraken) QueryOrders ¶
func (api *Kraken) QueryOrders(needTrades bool, userRef string, txIDs ...string) (map[string]OrderInfo, error)
QueryOrders - returns account's order by IDs
func (*Kraken) QueryTrades ¶
QueryTrades - returns trades by IDs
func (*Kraken) Ticker ¶
Ticker - Gets array of tickers passed through `pairs` arg. `pairs` - array of needed pairs. All by default if empty array passed or `pairs` is nil.
func (*Kraken) Time ¶
func (api *Kraken) Time() (TimeResponse, error)
Time - Gets server time. Note: This is to aid in approximating the skew time between the server and client.
type KrakenResponse ¶
type KrakenResponse struct { Error []string `json:"error"` Result interface{} `json:"result"` }
KrakenResponse - template of Kraken API response
type Ledger ¶
type Ledger struct { RefID string `json:"refid"` Time float64 `json:"time"` LedgerType string `json:"type"` AssetClass string `json:"aclass"` Asset string `json:"asset"` Amount float64 `json:"amount,string"` Fee float64 `json:"fee,string"` Balance float64 `json:"balance,string"` }
Ledger - structure of account's ledger
type LedgerInfoResponse ¶
LedgerInfoResponse - response on ledger request
type OHLCResponse ¶
OHLCResponse - response of OHLC request
func (*OHLCResponse) UnmarshalJSON ¶
func (item *OHLCResponse) UnmarshalJSON(buf []byte) error
UnmarshalJSON -
type OpenOrdersResponse ¶
OpenOrdersResponse - response on OpenOrders request
type OrderBook ¶
type OrderBook struct { Asks []OrderBookItem `json:"asks"` Bids []OrderBookItem `json:"bids"` }
OrderBook - struct of order book levels
type OrderBookItem ¶
OrderBookItem - one price level in orderbook
func (*OrderBookItem) UnmarshalJSON ¶
func (item *OrderBookItem) UnmarshalJSON(buf []byte) error
UnmarshalJSON -
type OrderDescription ¶
type OrderDescription struct { Pair string `json:"pair"` Side string `json:"type"` OrderType string `json:"ordertype"` Price float64 `json:"price,string"` Price2 float64 `json:"price2,string"` Leverage string `json:"leverage"` Info string `json:"order"` CloseCondition string `json:"close"` }
OrderDescription - structure of order description
type OrderInfo ¶
type OrderInfo struct { RefID *string `json:"refid"` UserRef interface{} `json:"userref"` Status string `json:"status"` Reason string `json:"reason,omitempty"` OpenTimestamp float64 `json:"opentm"` StartTimestamp float64 `json:"starttm"` CloseTimestamp float64 `json:"closetm,omitempty"` ExpireTimestamp 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"` AveragePrice float64 `json:"price,string"` StopPrice float64 `json:"stopprice,string"` LimitPrice float64 `json:"limitprice,string"` Misc string `json:"misc"` Flags string `json:"oflags"` }
OrderInfo - structure contains order information
type Position ¶
type Position struct { OrderID string `json:"ordertxid"` Status string `json:"posstatus"` Pair string `json:"pair"` Time float64 `json:"time"` Side 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"` VolumeClosed float64 `json:"vol_closed,string"` Margin float64 `json:"margin,string"` Misc string `json:"misc"` Value float64 `json:"value,omitempty,string"` Profit float64 `json:"net,omitempty,string"` Terms string `json:"terms,omitempty"` RolloverTime float64 `json:"rollovertm,omitempty,string"` Flags string `json:"oflags"` }
Position - structure of account position
type PrivateTrade ¶
type PrivateTrade struct { OrderID string `json:"ordertxid"` PositionID string `json:"postxid"` Pair string `json:"pair"` Time float64 `json:"time"` Side 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"` PositionStatus string `json:"posstatus,omitempty"` PositionAveragePrice float64 `json:"cprice,omitempty,string"` PositionCost float64 `json:"ccost,omitempty,string"` PositionFee float64 `json:"cfee,omitempty,string"` PositionVolume float64 `json:"cvol,omitempty,string"` PositionMargin float64 `json:"cmargin,omitempty,string"` PositionProfit float64 `json:"net,omitempty,string"` PositionTrades []string `json:"trades,omitempty"` }
PrivateTrade - structure of account's trades
type SpreadResponse ¶
type SpreadResponse struct { Last float64 `json:"last"` ADACAD []Spread ADAETH []Spread ADAEUR []Spread ADAUSD []Spread ADAXBT []Spread BCHEUR []Spread BCHUSD []Spread BCHXBT []Spread DASHEUR []Spread DASHUSD []Spread DASHXBT []Spread EOSETH []Spread EOSEUR []Spread EOSUSD []Spread EOSXBT []Spread GNOETH []Spread GNOEUR []Spread GNOUSD []Spread GNOXBT []Spread QTUMCAD []Spread QTUMETH []Spread QTUMEUR []Spread QTUMUSD []Spread QTUMXBT []Spread USDTZUSD []Spread XETCXETH []Spread XETCXXBT []Spread XETCZEUR []Spread XETCZUSD []Spread XETHXXBT []Spread XETHZCAD []Spread XETHZEUR []Spread XETHZGBP []Spread XETHZJPY []Spread XETHZUSD []Spread XICNXETH []Spread XICNXXBT []Spread XLTCXXBT []Spread XLTCZEUR []Spread XLTCZUSD []Spread XMLNXETH []Spread XMLNXXBT []Spread XREPXETH []Spread XREPXXBT []Spread XREPZEUR []Spread XREPZUSD []Spread XXBTZCAD []Spread XXBTZEUR []Spread XXBTZGBP []Spread XXBTZJPY []Spread XXBTZUSD []Spread XXDGXXBT []Spread XXLMXXBT []Spread XXLMZEUR []Spread XXLMZUSD []Spread XXMRXXBT []Spread XXMRZEUR []Spread XXMRZUSD []Spread XXRPXXBT []Spread XXRPZCAD []Spread XXRPZEUR []Spread XXRPZJPY []Spread XXRPZUSD []Spread XTZCAD []Spread XTZETH []Spread XTZEUR []Spread XTZUSD []Spread XTZXBT []Spread XZECXXBT []Spread XZECZEUR []Spread XZECZUSD []Spread }
SpreadResponse - response of spread request
type Ticker ¶
type Ticker struct { Ask Level `json:"a"` Bid Level `json:"b"` Close CloseLevel `json:"c"` Volume CloseLevel `json:"v"` VolumeAveragePrice CloseLevel `json:"p"` Trades TimeLevel `json:"t"` Low CloseLevel `json:"l"` High CloseLevel `json:"h"` OpeningPrice float64 `json:"o,string"` }
Ticker - struct of ticker response
type TimeLevel ¶
TimeLevel - ticker structure for Volume, VolumeAveragePrice, Low, High
func (*TimeLevel) UnmarshalJSON ¶
UnmarshalJSON -
type TimeResponse ¶
TimeResponse - Result of Time request
type Trade ¶
type Trade struct { Price float64 Volume float64 Time float64 Side string OrderType string Misc string }
Trade - structure of public trades
type TradeBalanceResponse ¶
type TradeBalanceResponse struct { EquivalentBalance float64 `json:"eb,string"` TradeBalance float64 `json:"tb,string"` OpenMargin float64 `json:"m,string"` UnrealizedProfit float64 `json:"n,string"` CostPositions float64 `json:"c,string"` CurrentValue float64 `json:"v,string"` Equity float64 `json:"e,string"` FreeMargin float64 `json:"mf,string"` MarginLevel float64 `json:"ml,string"` }
TradeBalanceResponse - response of get trade balance request
type TradeResponse ¶
type TradeResponse struct { Last float64 `json:"last"` ADACAD []Trade ADAETH []Trade ADAEUR []Trade ADAUSD []Trade ADAXBT []Trade BCHEUR []Trade BCHUSD []Trade BCHXBT []Trade DASHEUR []Trade DASHUSD []Trade DASHXBT []Trade EOSETH []Trade EOSEUR []Trade EOSUSD []Trade EOSXBT []Trade GNOETH []Trade GNOEUR []Trade GNOUSD []Trade GNOXBT []Trade QTUMCAD []Trade QTUMETH []Trade QTUMEUR []Trade QTUMUSD []Trade QTUMXBT []Trade USDTZUSD []Trade XETCXETH []Trade XETCXXBT []Trade XETCZEUR []Trade XETCZUSD []Trade XETHXXBT []Trade XETHZCAD []Trade XETHZEUR []Trade XETHZGBP []Trade XETHZJPY []Trade XETHZUSD []Trade XICNXETH []Trade XICNXXBT []Trade XLTCXXBT []Trade XLTCZEUR []Trade XLTCZUSD []Trade XMLNXETH []Trade XMLNXXBT []Trade XREPXETH []Trade XREPXXBT []Trade XREPZEUR []Trade XREPZUSD []Trade XXBTZCAD []Trade XXBTZEUR []Trade XXBTZGBP []Trade XXBTZJPY []Trade XXBTZUSD []Trade XXDGXXBT []Trade XXLMXXBT []Trade XXLMZEUR []Trade XXLMZUSD []Trade XXMRXXBT []Trade XXMRZEUR []Trade XXMRZUSD []Trade XXRPXXBT []Trade XXRPZCAD []Trade XXRPZEUR []Trade XXRPZJPY []Trade XXRPZUSD []Trade XTZCAD []Trade XTZETH []Trade XTZEUR []Trade XTZUSD []Trade XTZXBT []Trade XZECXXBT []Trade XZECZEUR []Trade XZECZUSD []Trade }
TradeResponse - all pairs in trade response
type TradeVolumeResponse ¶
type TradeVolumeResponse struct { Currency string `json:"currency"` Volume float64 `json:"volume,string"` Fees map[string]Fees `json:"fees,omitempty"` FeesMaker map[string]Fees `json:"fees_maker,omitempty"` }
TradeVolumeResponse - response on TradeVolume request
type TradesHistoryResponse ¶
type TradesHistoryResponse struct { Trades map[string]PrivateTrade `json:"trades"` Count int64 `json:"count"` }
TradesHistoryResponse - respons on TradesHistory request