kraken

package module
v0.0.0-...-ce9754d Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2021 License: MIT Imports: 20 Imported by: 0

README

Documentation

kraken

Simple kraken api client: lib + command.

See usage examples in ./cmd/kraken/main.go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStopped = errors.New("stopped")

Functions

This section is empty.

Types

type Asset

type Asset struct {
	Name            string `json:"name"`
	AltName         string `json:"altname"`
	AssetClass      string `json:"aclass"`
	Decimals        int    `json:"decimals"`
	DisplayDecimals int    `json:"display_decimals"`
}

type AssetPair

type AssetPair struct {
	Name              string  `json:"name"`
	AltName           string  `json:"altname,omitempty"`
	WSName            string  `json:"wsname,omitempty"`
	AssetClassBase    string  `json:"aclass_base,omitempty"`
	Base              string  `json:"base,omitempty"`
	AssetClassQuote   string  `json:"aclass_quote,omitempty"`
	Quote             string  `json:"quote,omitempty"`
	Lot               string  `json:"lot,omitempty"`
	PairDecimals      int     `json:"pair_decimals,omitempty"`
	LotDecimals       int     `json:"lot_decimals,omitempty"`
	LotMultiplier     int     `json:"lot_multiplier,omitempty"`
	LeverageBuy       []int   `json:"leverage_buy,omitempty"`
	LeverageSell      []int   `json:"leverage_sell,omitempty"`
	Fees              Fees    `json:"fees,omitempty"`
	FeesMaker         Fees    `json:"fees_maker,omitempty"`
	FeeVolumeCurrency string  `json:"fee_volume_currency,omitempty"`
	MarginCall        int     `json:"margin_call,omitempty"`
	MarginStop        int     `json:"margin_stop,omitempty"`
	MarginLevel       int     `json:"margin_level,omitempty"`
	OrderMin          Decimal `json:"ordermin,omitempty"`
}

type Candle

type Candle struct {
	Time   int64   `json:"time"`
	Open   Decimal `json:"open"`
	High   Decimal `json:"high"`
	Low    Decimal `json:"low"`
	Close  Decimal `json:"close"`
	VWap   Decimal `json:"vwap"`
	Volume Decimal `json:"volume"`
	Count  int64   `json:"count"`
}

func (*Candle) UnmarshalJSON

func (c *Candle) UnmarshalJSON(data []byte) (err error)

type Client

type Client struct {
	UserAgent string
	// contains filtered or unexported fields
}

func New

func New(key, secret string) (*Client, error)

func (*Client) AddOrder

func (c *Client) AddOrder() (r json.RawMessage, err error)

func (*Client) AssetPairs

func (c *Client) AssetPairs(pairs []string, info string) (r map[string]AssetPair, err error)

func (*Client) Assets

func (c *Client) Assets() (r map[string]Asset, err error)

func (*Client) Balance

func (c *Client) Balance() (r map[string]Decimal, err error)

func (*Client) Candles

func (c *Client) Candles(pair string, interval time.Duration, since string) (cs []Candle, last string, err error)

func (*Client) Depth

func (c *Client) Depth(pair string, cnt int) (d Depth, err error)

func (*Client) OpenOrders

func (c *Client) OpenOrders(trades bool, userref string) (r json.RawMessage, err error)

func (*Client) PrivateWebsocket

func (c *Client) PrivateWebsocket(ctx context.Context) (s *Websocket, err error)

func (*Client) Spread

func (c *Client) Spread(pair string, since string) (ss []Spread, last string, err error)

func (*Client) SystemStatus

func (c *Client) SystemStatus() (s SystemStatus, err error)

func (*Client) Ticker

func (c *Client) Ticker(pairs []string) (r map[string]Ticker, err error)

func (*Client) Time

func (c *Client) Time() (t time.Time, err error)

func (*Client) TradeBalance

func (c *Client) TradeBalance(asset, aclass string) (r TradeBalance, err error)

func (*Client) Trades

func (c *Client) Trades(pair string, since string) (ts []Trade, last string, err error)

func (*Client) Websocket

func (c *Client) Websocket(ctx context.Context) (s *Websocket, err error)

type Decimal

type Decimal = decimal.Decimal

type Depth

type Depth struct {
	Asks []PriceLevel `json:"asks"`
	Bids []PriceLevel `json:"bids"`
	C    Decimal      `json:"c"`
}

func (*Depth) UnmarshalJSON

func (d *Depth) UnmarshalJSON(data []byte) (err error)

type Event

type Event struct {
	Channel string      `json:"channel,omitempty"`
	Pair    string      `json:"pair,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

type Fees

type Fees []struct {
	Volume Decimal `json:"volume"`
	Fee    Decimal `json:"fee"`
}

func (*Fees) UnmarshalJSON

func (f *Fees) UnmarshalJSON(data []byte) (err error)

type NumberSummary

type NumberSummary struct {
	Today       int64
	Last24Hours int64
}

type Option

type Option struct {
	Name  string
	Value interface{}
}

func WithOption

func WithOption(n string, v interface{}) Option

type Order

type Order struct {
	TxID   string  `json:"txid,omitempty"`
	Status string  `json:"status,omitempty"`
	Pair   string  `json:"pair,omitempty"`
	Side   Side    `json:"side,omitempty"` // buy/sell
	Type   string  `json:"type,omitempty"` // market/limit
	Price  Decimal `json:"price,omitempty"`
	Volume Decimal `json:"volume,omitempty"`

	Rest map[string]interface{} `json:"rest"`
}

func (*Order) UnmarshalJSON

func (o *Order) UnmarshalJSON(data []byte) (err error)

type PriceLevel

type PriceLevel struct {
	Price     Decimal `json:"price"`
	Volume    Decimal `json:"volume"`
	Timestamp int64   `json:"timestamp"`
}

func (*PriceLevel) UnmarshalJSON

func (l *PriceLevel) UnmarshalJSON(data []byte) (err error)

type PriceSummary

type PriceSummary = VolumeSummary

type RemoteError

type RemoteError string

func (RemoteError) Error

func (e RemoteError) Error() string

type RemoteErrors

type RemoteErrors []RemoteError

func (RemoteErrors) Error

func (e RemoteErrors) Error() string

type Side

type Side bool
const (
	Buy  Side = true
	Sell Side = false
)

func (Side) MarshalJSON

func (s Side) MarshalJSON() ([]byte, error)

func (Side) String

func (s Side) String() string

func (*Side) UnmarshalJSON

func (s *Side) UnmarshalJSON(data []byte) (err error)

type Spread

type Spread struct {
	Time      int64   `json:"time"`
	Bid       Decimal `json:"bid"`
	Ask       Decimal `json:"ask"`
	BidVolume Decimal `json:"bid_volume"`
	AskVolume Decimal `json:"ask_volume"`
}

func (*Spread) UnmarshalJSON

func (s *Spread) UnmarshalJSON(data []byte) (err error)

type SystemStatus

type SystemStatus struct {
	Status    string    `json:"status"`
	Timestamp time.Time `json:"timestamp"`
}

type Ticker

type Ticker struct {
	AskPrice          Decimal
	AskLotVolume      Decimal
	AskWholeLotVolume Decimal

	BidPrice          Decimal
	BidLotVolume      Decimal
	BidWholeLotVolume Decimal

	LastPrice  Decimal
	LastVolume Decimal

	Volume      VolumeSummary
	TotalTrades NumberSummary

	Weighted PriceSummary
	Low      PriceSummary
	High     PriceSummary

	TodayOpeningPrice Decimal
}

func (*Ticker) UnmarshalJSON

func (t *Ticker) UnmarshalJSON(data []byte) (err error)

type Trade

type Trade struct {
	ID string `json:"id"`

	Pair      string  `json:"pair"`
	Price     Decimal `json:"price"`
	Volume    Decimal `json:"volume"`
	Timestamp int64   `json:"time"`
	Side      Side    `json:"side"` // buy/sell
	OrderType string  `json:"ordertype"`

	Cost      Decimal `json:"cost,omitempty"`
	Fee       Decimal `json:"fee,omitempty"`
	Margin    Decimal `json:"margin,omitempty"`
	OrderTxID string  `json:"ordertxid,omitempty"`
	PosTxID   string  `json:"postxid,omitempty"`

	Miscellaneous string `json:"miscellaneous,omitempty"`
}

func (*Trade) UnmarshalJSON

func (t *Trade) UnmarshalJSON(data []byte) (err error)

type TradeBalance

type TradeBalance struct {
	Equivalent  Decimal `json:"equivalent"`
	Trade       Decimal `json:"trade"`
	Margin      Decimal `json:"margin"`
	Unrealized  Decimal `json:"unrealized"`
	Cost        Decimal `json:"cost"`
	Valuation   Decimal `json:"valuation"`
	Equity      Decimal `json:"equity"`
	MarginFree  Decimal `json:"margin_free"`
	MarginLevel Decimal `json:"margin_level"`
}

func (*TradeBalance) UnmarshalJSON

func (b *TradeBalance) UnmarshalJSON(data []byte) (err error)

type VolumeSummary

type VolumeSummary struct {
	Today       Decimal
	Last24Hours Decimal
}

type Websocket

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

func (*Websocket) AddOrder

func (s *Websocket) AddOrder(ctx context.Context, o Order) (txid string, err error)

func (*Websocket) C

func (s *Websocket) C() <-chan Event

func (*Websocket) CancelOrder

func (s *Websocket) CancelOrder(ctx context.Context, txid ...string) (err error)

func (*Websocket) Err

func (s *Websocket) Err() <-chan error

func (*Websocket) Subscribe

func (s *Websocket) Subscribe(ctx context.Context, topic string, pairs []string, args ...Option) (err error)

func (*Websocket) Sys

func (s *Websocket) Sys() <-chan interface{}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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