poloniex

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

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

Go to latest
Published: Apr 10, 2017 License: MIT Imports: 12 Imported by: 0

README

go-poloniex

go-poloniex is an implementation of the Poloniex API (public and private) in Golang.

Based off of https://github.com/toorop/go-bittrex/

This library is more of a framework for some bots I use so it is expected that a lot of things don't work but pull requests are excepted.

Import

import "github.com/jyap808/go-poloniex"

Usage

package main

import (
	"fmt"
	"github.com/jyap808/go-poloniex"
)

const (
	API_KEY    = "YOUR_API_KEY"
	API_SECRET = "YOUR_API_SECRET"
)

func main() {
	// Poloniex client
	poloniex := poloniex.New(API_KEY, API_SECRET)

	// Get tickers
    tickers, err := poloniex.GetTickers()
	fmt.Println(err, tickers)
}

See "Examples" folder for more... examples

Stay tuned

Follow me on Twitter

Documentation

Overview

Package Poloniex is an implementation of the Poloniex API in Golang.

Index

Constants

View Source
const (
	API_BASE                   = "https://poloniex.com/" // Poloniex API endpoint
	DEFAULT_HTTPCLIENT_TIMEOUT = 30                      // HTTP client timeout
)

Variables

This section is empty.

Functions

func NewClient

func NewClient(apiKey, apiSecret string) (c *client)

NewClient return a new Poloniex HTTP client

Types

type CandleStick

type CandleStick struct {
	Date            PoloniexDate    `json:"date"`
	High            decimal.Decimal `json:"high"`
	Low             decimal.Decimal `json:"low"`
	Open            decimal.Decimal `json:"open"`
	Close           decimal.Decimal `json:"close"`
	Volume          decimal.Decimal `json:"volume"`
	QuoteVolume     decimal.Decimal `json:"quoteVolume"`
	WeightedAverage decimal.Decimal `json:"weightedAverage"`
}

type Currencies

type Currencies struct {
	Pair map[string]Currency
}

type Currency

type Currency struct {
	Name               string          `json:"name"`
	MaxDailyWithdrawal string          `json:"maxDailyWithdrawal"`
	TxFee              decimal.Decimal `json:"txFee,string"`
	MinConf            int             `json:"minConf"`
	Disabled           int             `json:"disabled"`
	Frozen             int             `json:"frozen"`
	Delisted           int             `json:"delisted"`
}

type OrderBook

type OrderBook struct {
	Asks     [][]interface{} `json:"asks"`
	Bids     [][]interface{} `json:"bids"`
	IsFrozen int             `json:"isFrozen,string"`
	Error    string          `json:"error"`
}

type Poloniex

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

poloniex represent a poloniex client

func New

func New(apiKey, apiSecret string) *Poloniex

New return a instantiate poloniex struct

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) GetCurrencies

func (b *Poloniex) GetCurrencies() (currencies Currencies, err error)

func (*Poloniex) GetOrderBook

func (b *Poloniex) GetOrderBook(market, cat string, depth int) (orderBook OrderBook, err error)

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

func (b *Poloniex) GetTickers() (tickers map[string]Ticker, err error)

GetTickers is used to get the ticker for all markets

func (*Poloniex) GetVolumes

func (b *Poloniex) GetVolumes() (vc VolumeCollection, err error)

GetVolumes is used to get the volume for all markets

type PoloniexDate

type PoloniexDate struct {
	time.Time
}

func (*PoloniexDate) UnmarshalJSON

func (pd *PoloniexDate) UnmarshalJSON(data []byte) error

type Ticker

type Ticker struct {
	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 Tickers

type Tickers struct {
	Pair map[string]Ticker
}

type Volume

type Volume map[string]decimal.Decimal

type VolumeCollection

type VolumeCollection struct {
	TotalBTC  decimal.Decimal `json:"totalBTC,string"`
	TotalUSDT decimal.Decimal `json:"totalUSDT,string"`
	TotalXMR  decimal.Decimal `json:"totalXMR,string"`
	TotalXUSD decimal.Decimal `json:"totalXUSD,string"`
	Volumes   map[string]Volume
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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