bitstamp

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: MIT Imports: 10 Imported by: 0

README

bitstamp-go

Fork of http://godoc.org/github.com/Narsil/bitstamp-go. Includes apiv2 and websocket support. Library api have been changed and it is not compatible with the original one.

An api written in go (golang) for http://www.bitstamp.net/

Documentation

http://godoc.org/github.com/avdva/bitstamp-go

Documentation

Index

Constants

View Source
const (
	// API_URL is a url of the api v2 endpoint
	API_URL = "https://www.bitstamp.net/api/v2"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

type Api struct {
	User     string
	Password string
}

Api is a Bitstamp client.

func New

func New(user, password string) *Api

New creates a new api object given a user and a password.

func NewFromConfig

func NewFromConfig(cfgfile string) (api *Api, err error)

NewFromConfig creates a new api object given a config file. The config file must be json formated to inlude User and Password

func (*Api) GetOrderBook

func (api *Api) GetOrderBook(symbol string) (orderbook *OrderBook, err error)

GetOrderBook returns order book for the given symbol.

func (*Api) GetTicker

func (api *Api) GetTicker(symbol string) (ticker *Ticker, err error)

GetTicker returns a ticker for the goven symbol.

func (*Api) GetTrades

func (api *Api) GetTrades(symbol string) (trades []Trade, err error)

GetTrades returns the list of last trades with default parameters.

func (*Api) GetTradesParams

func (api *Api) GetTradesParams(symbol string, interval string) (trades []Trade, err error)

GetTradesParams returns the list of last trades.

interval - The time interval from which we want the transactions to be returned.
	Possible values are minute, hour (default) or day.

func (*Api) SubscribeOrderBook

func (api *Api) SubscribeOrderBook(symb string, dataChan chan<- OrderBook, stopChan <-chan struct{}) error

SubscribeOrderBook subscribes for websocket events and sends order book updates into dataChan. To stop processing, sent to, or close stopChan.

type Order

type Order struct {
	Price  float64
	Amount float64
}

Order is a (price, amount) pair

type OrderBook

type OrderBook struct {
	Time time.Time
	Asks []Order
	Bids []Order
}

OrderBook is a standart order book.

type Ticker

type Ticker struct {
	Last float64 `json:",string"`
	High float64 `json:",string"`
	Low  float64 `json:",string"`
	Ask  float64 `json:",string"`
	Bid  float64 `json:",string"`
}

Ticker is a tick representation.

type Trade

type Trade struct {
	Time   time.Time
	ID     string
	Price  float64
	Amount float64
}

Trade is a trade representation.

type WsClient added in v0.3.0

type WsClient struct {
	Stream chan *WsEvent
	Errors chan error
	// contains filtered or unexported fields
}

func NewWsClient added in v0.3.0

func NewWsClient() (*WsClient, error)

func (*WsClient) Close added in v0.3.0

func (c *WsClient) Close()

func (*WsClient) Subscribe added in v0.3.0

func (c *WsClient) Subscribe(channels ...string) error

func (*WsClient) Unsubscribe added in v0.3.0

func (c *WsClient) Unsubscribe(channels ...string) error

type WsEvent added in v0.3.0

type WsEvent struct {
	Event   string          `json:"event"`
	Channel string          `json:"channel"`
	Data    json.RawMessage `json:"data"`
}

Jump to

Keyboard shortcuts

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