Documentation ¶
Overview ¶
Package Poloniex is an implementation of the Poloniex API in Golang.
Index ¶
- Constants
- func NewClient(apiKey, apiSecret string) (c *client)
- func NewClientWithCustomTimeout(apiKey, apiSecret string, timeout time.Duration) (c *client)
- type Balance
- type CandleStick
- type Currencies
- type Currency
- type Deposit
- type MarketUpd
- type OpType
- type OpenOrder
- type OrderBook
- type OrderBookUpd
- type Poloniex
- func (b *Poloniex) Buy(pair string, rate float64, amount float64, tradeType string) (TradeOrder, error)
- func (b *Poloniex) ChartData(currencyPair string, period int, start, end time.Time) (candles []*CandleStick, err error)
- func (b *Poloniex) GetBalances() (balances map[string]Balance, err error)
- func (b *Poloniex) GetCurrencies() (currencies Currencies, err error)
- func (b *Poloniex) GetDepositsWithdrawals(start uint32, end uint32) (deposits []Deposit, withdrawals []Withdrawal, err error)
- func (b *Poloniex) GetOpenOrders(pair string) (openOrders map[string][]OpenOrder, err error)
- func (b *Poloniex) GetOrderBook(market, cat string, depth int) (orderBook OrderBook, err error)
- func (b *Poloniex) GetTickers() (tickers map[string]Ticker, err error)
- func (b *Poloniex) GetTradeHistory(pair string, start uint32) (trades map[string][]Trade, err error)
- func (b *Poloniex) GetVolumes() (vc VolumeCollection, err error)
- func (b *Poloniex) Sell(pair string, rate float64, amount float64, tradeType string) (TradeOrder, error)
- func (c *Poloniex) SetDebug(enable bool)
- func (b *Poloniex) Shutdown() error
- func (b *Poloniex) SubscribeOrderBook(symbolID int, updatesCh chan<- MarketUpd, stopCh <-chan struct{}) error
- func (b *Poloniex) UnsubscribeAll() error
- type PoloniexDate
- type ResultingTrade
- type Ticker
- type TickerUpd
- type Tickers
- type Trade
- type TradeOrder
- type TradeUpd
- type Volume
- type VolumeCollection
- type Withdrawal
Constants ¶
const ( Sell = OpType(0) Buy = OpType(1) )
const ( API_BASE = "https://poloniex.com" // Poloniex API endpoint API_WS = "wss://api2.poloniex.com" // Poloniex WS endpoint )
const ( TRADE_FILL_OR_KILL = "fillOrKill" TRADE_IMMEDIATE_OR_CANCEL = "immediateOrCancel" TRADE_POST_ONLY = "postOnly" )
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
func NewClient(apiKey, apiSecret string) (c *client)
NewClient return a new Poloniex HTTP client
func NewClientWithCustomTimeout ¶
NewClientWithCustomTimeout returns a new Poloniex HTTP client with custom timeout
Types ¶
type CandleStick ¶
type Currencies ¶
type Currency ¶
type Currency struct { ID int `json:"id"` Name string `json:"name"` MaxDailyWithdrawal decimal.Decimal `json:"maxDailyWithdrawal"` TxFee decimal.Decimal `json:"txFee"` MinConf int `json:"minConf"` DepositAddress *string `json:"depositAddress"` Disabled int `json:"disabled"` Delisted int `json:"delisted"` Frozen int `json:"frozen"` }
type Deposit ¶
type Deposit struct { Currency string `json:"currency"` Address string `json:"address"` Amount float64 `json:"amount,string"` Confirmations uint64 `json:"confirmations"` TxId string `json:"txid"` Date time.Time `json:"timestamp"` Status string `json:"status"` }
func (*Deposit) UnmarshalJSON ¶
type MarketUpd ¶
type MarketUpd struct { // Seq is constantly increasing number. Seq int64 // Initial indicates, that it's the entire obook snapshot. Initial bool // Obooks - updates of an order book. Obooks []OrderBookUpd // Trades - new trades. Trades []TradeUpd }
MarketUpd is a message from Poloniex exchange.
type OrderBookUpd ¶
type OrderBookUpd struct { // Type is either bid or ask. Type OpType // Price of an asset. Price decimal.Decimal // Size can be zero, if the order was removed. Size decimal.Decimal }
OrderBookUpd is a single order book update.
type Poloniex ¶
type Poloniex struct {
// contains filtered or unexported fields
}
poloniex represent a poloniex client
func NewWithCustomTimeout ¶
New returns an instantiated poloniex struct with custom timeout
func (*Poloniex) ChartData ¶
func (b *Poloniex) ChartData(currencyPair string, period int, start, end time.Time) (candles []*CandleStick, err error)
Returns candlestick chart data. Required GET parameters are "currencyPair", "period" (candlestick period in seconds; valid values are 300, 900, 1800, 7200, 14400, and 86400), "start", and "end". "Start" and "end" are given in UNIX timestamp format and used to specify the date range for the data returned.
func (*Poloniex) GetBalances ¶
func (*Poloniex) GetCurrencies ¶
func (b *Poloniex) GetCurrencies() (currencies Currencies, err error)
func (*Poloniex) GetDepositsWithdrawals ¶
func (*Poloniex) GetOpenOrders ¶
func (*Poloniex) GetOrderBook ¶
GetOrderBook is used to get retrieve the orderbook for a given market market: a string literal for the market (ex: BTC_NXT). 'all' not implemented. cat: bid, ask or both to identify the type of orderbook to return. depth: how deep of an order book to retrieve
func (*Poloniex) GetTickers ¶
GetTickers is used to get the ticker for all markets
func (*Poloniex) GetTradeHistory ¶
func (*Poloniex) GetVolumes ¶
func (b *Poloniex) GetVolumes() (vc VolumeCollection, err error)
GetVolumes is used to get the volume for all markets
func (*Poloniex) SubscribeOrderBook ¶
func (b *Poloniex) SubscribeOrderBook(symbolID int, updatesCh chan<- MarketUpd, stopCh <-chan struct{}) error
SubscribeOrderBook subscribes for trades and order book updates via WAMP.
symbol - a symbol id you are interested in. updatesCh - a channel for market updates. stopCh - a channel to stop ws subscribtion. send to, or close it.
func (*Poloniex) UnsubscribeAll ¶
UnsubscribeAll cancels all active subscriptions.
type PoloniexDate ¶
func (*PoloniexDate) UnmarshalJSON ¶
func (pd *PoloniexDate) UnmarshalJSON(data []byte) error
type ResultingTrade ¶
type Ticker ¶
type Ticker struct { ID int `json:"id"` Last decimal.Decimal `json:"last,string"` LowestAsk decimal.Decimal `json:"lowestAsk,string"` HighestBid decimal.Decimal `json:"highestBid,string"` PercentChange decimal.Decimal `json:"percentChange,string"` BaseVolume decimal.Decimal `json:"baseVolume,string"` QuoteVolume decimal.Decimal `json:"quoteVolume,string"` IsFrozen int `json:"isFrozen,string"` High24Hr decimal.Decimal `json:"high24hr,string"` Low24Hr decimal.Decimal `json:"low24hr,string"` }
type Trade ¶
type Trade struct { GlobalTradeID uint64 `json:"globalTradeID"` TradeID uint64 `json:"tradeID,string"` Date time.Time `json:"date,string"` Type string `json:"type"` Category string `json:"category"` Rate float64 `json:"rate,string"` Amount float64 `json:"amount,string"` Total float64 `json:"total,string"` Fee float64 `json:"fee,string"` }
func (*Trade) UnmarshalJSON ¶
type TradeOrder ¶
type TradeOrder struct { OrderNumber string `json:"orderNumber"` ResultingTrades []ResultingTrade `json:"resultingTrades"` }
type TradeUpd ¶
type TradeUpd struct { // TradeID - unique trade ID. TradeID string // Type is either buy or sell Type OpType // Price is an asset price. Price decimal.Decimal // Size is a trade amount. Size decimal.Decimal // Date is a trade's unix timestamp. Date int64 }
TradeUpd contains single trade information.
type Volume ¶
func (*Volume) UnmarshalJSON ¶
type VolumeCollection ¶
type VolumeCollection struct { TotalBTC float64 `json:"totalBTC,string"` TotalETH float64 `json:"totalETH,string"` TotalUSDT float64 `json:"totalUSDT,string"` TotalXMR float64 `json:"totalXMR,string"` TotalXUSD float64 `json:"totalXUSD,string"` Volumes map[string]Volume }
func (*VolumeCollection) UnmarshalJSON ¶
func (tc *VolumeCollection) UnmarshalJSON(b []byte) error
type Withdrawal ¶
type Withdrawal struct { WithdrawalNumber uint64 `json:"withdrawalNumber"` Currency string `json:"currency"` Address string `json:"address"` Amount float64 `json:"amount,string"` Date time.Time `json:"timestamp"` Status string `json:"status"` TxId string `json:"txid"` IpAddress string `json:"ipAddress"` }
func (*Withdrawal) UnmarshalJSON ¶
func (t *Withdrawal) UnmarshalJSON(data []byte) error