Skip to content

iowar/poloniex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Poloniex API GO

GoDoc

Poloniex Push, Public and Trading APIs.

Install

$ go get -u github.com/iowar/poloniex

APIs

import polo "github.com/iowar/poloniex"

Push Api

Create websocket client.

NewWSClient()

ws, err := polo.NewWSClient()
if err != nil {
    return
}
  • Push Api Methods
    • SubscribeTicker()
    • SubscribeMarket()
    • UnsubscribeTicker()
    • UnsubscribeMarket()

Ticker

SubscribeTicker()

err = ws.SubscribeTicker()
if err != nil {
    return
}
for {
    fmt.Println(<-ws.Subs["TICKER"])
}

UnsubscribeTicker()

err = ws.SubscribeTicker()
go func() {
    time.Sleep(time.Second * 10)
    ws.UnsubscribeTicker()
}()
for {
    fmt.Println(<-ws.Subs["TICKER"])
}

OrderDepth, OrderBook and Trades

SubscribeMarket()

err = ws.SubscribeMarket("USDT_BTC")
if err != nil {
    return
}
for {
    fmt.Println(<-ws.Subs["USDT_BTC"])
}

UnsubscribeMarket()

err = ws.SubscribeMarket("USDT_BTC")
if err != nil {
    return
}
go func() {
    time.Sleep(time.Second * 10)
    ws.UnsubscribeMarket("USDT_BTC")
}()
for {
    fmt.Println(<-ws.Subs["USDT_BTC"])
}

Examples

Public Api

poloniex, err := polo.NewClient(api_key, api_secret)
  • Public Api Methods
    • GetTickers()
    • Get24hVolumes()
    • GetOrderBook()
    • GetPublicTradeHistory()
    • GetChartData()
    • GetCurrencies()
    • GetLoanOrders()

Example

resp, err := poloniex.GetTickers()
if err != nil{
    panic(err)
}
fmt.Println(resp)

Trading Api

const (
        api_key    = ""
        api_secret = ""
)
poloniex, err := polo.NewClient(api_key, api_secret)
  • Trading Api Methods
    • GetBalances()
    • GetCompleteBalances()
    • GetAccountBalances()
    • GetDepositAddresses()
    • GenerateNewAddress()
    • GetOpenOrders()
    • GetAllOpenOrders()
    • CancelOrder()
    • GetTradeHistory()
    • GetTradesByOrderID()
    • GetOrderStat()
    • Buy()
    • Sell()

Example

resp, err := poloniex.Buy("btc_dgb", 0.00000099, 10000)
if err != nil{
    panic(err)
}
fmt.Println(resp)

License

MIT