Documentation ¶
Index ¶
- Constants
- type API
- type AddOrderResponse
- type AssetInfo
- type AssetPairInfo
- type AssetPairs
- type AssetPairsResponse
- type Assets
- type AssetsResponse
- type BalanceResponse
- type Balances
- type CancelOrderResponse
- type ClosedOrdersResponse
- type DepositAddressesResponse
- type DepthResponse
- type FeeInfo
- type Fees
- type FeesMap
- type KrakenClient
- type KrakenPrivate
- func (api *KrakenPrivate) AddOrder(pair string, direction string, orderType string, volume string, ...) (*AddOrderResponse, error)
- func (api *KrakenPrivate) Balance() (BalanceResponse, error)
- func (api *KrakenPrivate) CancelOrder(txid string) (*CancelOrderResponse, error)
- func (api *KrakenPrivate) ClosedOrders(args map[string]string) (*ClosedOrdersResponse, error)
- func (api *KrakenPrivate) DepositAddresses(asset string, method string) (*DepositAddressesResponse, error)
- func (api *KrakenPrivate) Ledgers(args map[string]string) (*LedgersResponse, error)
- func (api *KrakenPrivate) OpenOrders(args map[string]string) (*OpenOrdersResponse, error)
- func (api *KrakenPrivate) QueryOrders(txids string, args map[string]string) (*QueryOrdersResponse, error)
- func (api *KrakenPrivate) TradeBalance(args map[string]string) (*TradeBalanceResponse, error)
- func (api *KrakenPrivate) TradeVolume(args map[string]string) (*TradeVolumeResponse, error)
- func (api *KrakenPrivate) TradesHistory(start int64, end int64, args map[string]string) (*TradesHistoryResponse, error)
- func (api *KrakenPrivate) Withdraw(asset string, key string, amount *big.Float) (*WithdrawResponse, error)
- func (api *KrakenPrivate) WithdrawInfo(asset string, key string, amount *big.Float) (*WithdrawInfoResponse, error)
- type KrakenPublic
- func (api *KrakenPublic) AssetPairs() (AssetPairsResponse, error)
- func (api *KrakenPublic) Assets() (AssetsResponse, error)
- func (api *KrakenPublic) Depth(pair string, count int) (*OrderBook, error)
- func (api *KrakenPublic) OHLC(pair string, interval string, since int64) (*OHLCResponse, error)
- func (api *KrakenPublic) OHLCMinutes(pair string) (*OHLCResponse, error)
- func (api *KrakenPublic) Ticker(pairs ...string) (TickerResponse, error)
- func (api *KrakenPublic) Time() (*TimeResponse, error)
- func (api *KrakenPublic) Trades(pair string, since int64) (*TradesResponse, error)
- type KrakenResponse
- type LedgerInfo
- type LedgersResponse
- type OHLC
- type OHLCResponse
- type OpenOrdersResponse
- type Order
- type OrderBook
- type OrderBookItem
- type OrderDescription
- type PairTickerInfo
- type PrivateAPI
- type PublicAPI
- type QueryOrdersResponse
- type TickerResponse
- type Tickers
- type TimeResponse
- type TradeBalanceResponse
- type TradeHistoryInfo
- type TradeInfo
- type TradeVolumeResponse
- type TradesHistoryResponse
- type TradesResponse
- type WithdrawInfoResponse
- type WithdrawResponse
Constants ¶
const ( // APIURL is the official Kraken API Endpoint APIURL = "https://api.kraken.com" // APIVersion is the official Kraken API Version Number APIVersion = "0" )
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
const ( BUY = "b" SELL = "s" MARKET = "m" LIMIT = "l" )
actions constants
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 (
// APIUserAgent identifies this library with the Kraken API
APIUserAgent = "Kraken-Go Agent"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { Public() PublicAPI Private() PrivateAPI }
KrakenApi represents a Kraken API Client connection
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"` // wsname = WebSocket pair name (if available) WSName string `json:"wsname"` // 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"` // minimum order volume for pair OrderMin string `json:"ordermin"` }
AssetPairInfo represents asset pair information
type AssetPairs ¶
type AssetPairs map[string]AssetPairInfo
func (*AssetPairs) GetAssetPair ¶
func (ap *AssetPairs) GetAssetPair(pair string) AssetPairInfo
func (*AssetPairs) GetPairs ¶
func (ap *AssetPairs) GetPairs() []string
type AssetPairsResponse ¶
type AssetPairsResponse interface { // GetAsset is a helper method that returns given `pair`'s `AssetInfo` GetAssetPair(pair string) AssetPairInfo GetPairs() []string }
AssetPairsResponse includes asset pair informations
type AssetsResponse ¶
type AssetsResponse interface { // GetAsset is a helper method that returns given `pair`'s `AssetInfo` GetAsset(asset string) AssetInfo GetAssets() []string }
AssetsResponse includes asset informations
type BalanceResponse ¶
type Balances ¶
func (*Balances) GetBalance ¶
type CancelOrderResponse ¶
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 ¶
DepthResponse is a response from kraken to Depth request.
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 FeesMap ¶
func (*FeesMap) GetFeeInfo ¶
type KrakenClient ¶
type KrakenClient struct {
// contains filtered or unexported fields
}
krakenAPI represents a Kraken API Client connection
type KrakenPrivate ¶
type KrakenPrivate struct { KrakenClient // contains filtered or unexported fields }
krakenAPI represents a Kraken API Client connection
func (*KrakenPrivate) AddOrder ¶
func (api *KrakenPrivate) AddOrder(pair string, direction string, orderType string, volume string, args map[string]string) (*AddOrderResponse, error)
AddOrder adds new order
func (*KrakenPrivate) Balance ¶
func (api *KrakenPrivate) Balance() (BalanceResponse, error)
Balance returns all account asset balances
func (*KrakenPrivate) CancelOrder ¶
func (api *KrakenPrivate) CancelOrder(txid string) (*CancelOrderResponse, error)
CancelOrder cancels order
func (*KrakenPrivate) ClosedOrders ¶
func (api *KrakenPrivate) ClosedOrders(args map[string]string) (*ClosedOrdersResponse, error)
ClosedOrders returns all closed orders
func (*KrakenPrivate) DepositAddresses ¶
func (api *KrakenPrivate) DepositAddresses(asset string, method string) (*DepositAddressesResponse, error)
DepositAddresses returns deposit addresses
func (*KrakenPrivate) Ledgers ¶
func (api *KrakenPrivate) Ledgers(args map[string]string) (*LedgersResponse, error)
Ledgers returns ledgers informations
func (*KrakenPrivate) OpenOrders ¶
func (api *KrakenPrivate) OpenOrders(args map[string]string) (*OpenOrdersResponse, error)
OpenOrders returns all open orders
func (*KrakenPrivate) QueryOrders ¶
func (api *KrakenPrivate) QueryOrders(txids string, args map[string]string) (*QueryOrdersResponse, error)
QueryOrders shows order
func (*KrakenPrivate) TradeBalance ¶
func (api *KrakenPrivate) TradeBalance(args map[string]string) (*TradeBalanceResponse, error)
TradeBalance returns trade balance info
func (*KrakenPrivate) TradeVolume ¶
func (api *KrakenPrivate) TradeVolume(args map[string]string) (*TradeVolumeResponse, error)
TradeVolume returns trade volume info
func (*KrakenPrivate) TradesHistory ¶
func (api *KrakenPrivate) 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 (*KrakenPrivate) Withdraw ¶
func (api *KrakenPrivate) Withdraw(asset string, key string, amount *big.Float) (*WithdrawResponse, error)
Withdraw executes a withdrawal, returning a reference ID
func (*KrakenPrivate) WithdrawInfo ¶
func (api *KrakenPrivate) WithdrawInfo(asset string, key string, amount *big.Float) (*WithdrawInfoResponse, error)
WithdrawInfo returns withdrawal information
type KrakenPublic ¶
type KrakenPublic struct {
KrakenClient
}
krakenAPI represents a Kraken API Client connection
func (*KrakenPublic) AssetPairs ¶
func (api *KrakenPublic) AssetPairs() (AssetPairsResponse, error)
AssetPairs returns the servers available asset pairs
func (*KrakenPublic) Assets ¶
func (api *KrakenPublic) Assets() (AssetsResponse, error)
Assets returns the servers available assets
func (*KrakenPublic) Depth ¶
func (api *KrakenPublic) Depth(pair string, count int) (*OrderBook, error)
Depth returns the order book for given pair and orders count.
func (*KrakenPublic) OHLC ¶
func (api *KrakenPublic) OHLC(pair string, interval string, since int64) (*OHLCResponse, error)
OHLCWithInterval returns a OHLCResponse struct based on the given pair
func (*KrakenPublic) OHLCMinutes ¶
func (api *KrakenPublic) OHLCMinutes(pair string) (*OHLCResponse, error)
OHLC returns a OHLCResponse struct based on the given pair Backward compatible with previous version
func (*KrakenPublic) Ticker ¶
func (api *KrakenPublic) Ticker(pairs ...string) (TickerResponse, error)
Ticker returns the ticker for given comma separated pairs
func (*KrakenPublic) Time ¶
func (api *KrakenPublic) Time() (*TimeResponse, error)
Time returns the server's time
func (*KrakenPublic) Trades ¶
func (api *KrakenPublic) Trades(pair string, since int64) (*TradesResponse, error)
Trades returns the recent trades for given pair
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"
type OHLCResponse ¶
type OHLCResponse struct { Pair string `json:"pair"` OHLC []*OHLC `json:"OHLC"` Last int64 `json:"last"` }
OHLCResponse represents the OHLC's response
type OpenOrdersResponse ¶
OpenOrdersResponse response when opening an order
type Order ¶
type Order struct { TransactionID string `json:"-"` ReferenceID string `json:"refid"` UserRef int `json:"userref"` Status string `json:"status"` OpenTime float64 `json:"opentm"` StartTime float64 `json:"starttm"` ExpireTime float64 `json:"expiretm"` Description OrderDescription `json:"descr"` Volume string `json:"vol"` 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"` }
Order represents a single order
type OrderBook ¶
type OrderBook struct { Asks []OrderBookItem Bids []OrderBookItem }
OrderBook contains top asks and bids.
type OrderBookItem ¶
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 string `json:"ordertype"` PrimaryPrice string `json:"price"` SecondaryPrice string `json:"price2"` Type string `json:"type"` }
OrderDescription represents an orders description
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 PrivateAPI ¶
type PrivateAPI interface { TradesHistory(start int64, end int64, args map[string]string) (*TradesHistoryResponse, error) Balance() (BalanceResponse, error) TradeBalance(args map[string]string) (*TradeBalanceResponse, error) TradeVolume(args map[string]string) (*TradeVolumeResponse, error) OpenOrders(args map[string]string) (*OpenOrdersResponse, error) ClosedOrders(args map[string]string) (*ClosedOrdersResponse, error) CancelOrder(txid string) (*CancelOrderResponse, error) QueryOrders(txids string, args map[string]string) (*QueryOrdersResponse, error) AddOrder(pair string, direction string, orderType string, volume string, args map[string]string) (*AddOrderResponse, error) Ledgers(args map[string]string) (*LedgersResponse, error) DepositAddresses(asset string, method string) (*DepositAddressesResponse, error) Withdraw(asset string, key string, amount *big.Float) (*WithdrawResponse, error) WithdrawInfo(asset string, key string, amount *big.Float) (*WithdrawInfoResponse, error) }
type PublicAPI ¶
type PublicAPI interface { Time() (*TimeResponse, error) Assets() (AssetsResponse, error) AssetPairs() (AssetPairsResponse, error) Ticker(pairs ...string) (TickerResponse, error) OHLC(pair string, interval string, since int64) (*OHLCResponse, error) OHLCMinutes(pair string) (*OHLCResponse, error) Trades(pair string, since int64) (*TradesResponse, error) Depth(pair string, count int) (*OrderBook, error) }
type QueryOrdersResponse ¶
QueryOrdersResponse response when checking all orders
type TickerResponse ¶
type TickerResponse interface { // GetPairTickerInfo is a helper method that returns given `pair`'s `PairTickerInfo` GetPairTickerInfo(pair string) PairTickerInfo GetPairs() []string }
TickerResponse includes the requested ticker pairs
type Tickers ¶
type Tickers map[string]PairTickerInfo
func (*Tickers) GetPairTickerInfo ¶
func (t *Tickers) GetPairTickerInfo(pair string) 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 ¶
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.