Poloniex Push, Public and Trading APIs.
$ go get -u github.com/iowar/poloniex
import polo "github.com/iowar/poloniex"
Create websocket client.
ws, err := polo.NewWSClient()
if err != nil {
return
}
- Push Api Methods
- SubscribeTicker()
- SubscribeMarket()
- UnsubscribeTicker()
- UnsubscribeMarket()
err = ws.SubscribeTicker()
if err != nil {
return
}
for {
fmt.Println(<-ws.Subs["TICKER"])
}
err = ws.SubscribeTicker()
go func() {
time.Sleep(time.Second * 10)
ws.UnsubscribeTicker()
}()
for {
fmt.Println(<-ws.Subs["TICKER"])
}
err = ws.SubscribeMarket("USDT_BTC")
if err != nil {
return
}
for {
fmt.Println(<-ws.Subs["USDT_BTC"])
}
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"])
}
poloniex, err := polo.NewClient(api_key, api_secret)
- Public Api Methods
- GetTickers()
- Get24hVolumes()
- GetOrderBook()
- GetPublicTradeHistory()
- GetChartData()
- GetCurrencies()
- GetLoanOrders()
resp, err := poloniex.GetTickers()
if err != nil{
panic(err)
}
fmt.Println(resp)
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()
resp, err := poloniex.Buy("btc_dgb", 0.00000099, 10000)
if err != nil{
panic(err)
}
fmt.Println(resp)