poloniex

package
v0.0.0-...-e2245cf Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2017 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Examples

Constants

View Source
const (
	// WebsocketAddress - Poloniex Websocket address.
	WebsocketAddress = "wss://api.poloniex.com"

	// WebsocketRealm - Poloniex Websocket realm name.
	WebsocketRealm = "realm1"
)

Variables

This section is empty.

Functions

func History

func History(ctx context.Context, req HistoryRequest, results chan<- []*order.Trade) (err error)

History - Reads trades history from start to end. Results channel will be closed by this function.

Example
ctx, cancel := context.WithTimeout(context.Background(), time.Hour)
defer cancel()

req := HistoryRequest{
	Pair:  currency.NewPair("BTC", "XRP"),
	Start: time.Now().Add(-time.Hour * 24),
	End:   time.Now(),
}

// Create results channel
results := make(chan []*order.Trade, 10)

// Get all trades in goroutine
go func() {
	if err := History(ctx, req, results); err != nil {
		glog.Fatal(err)
	}
}()

for {
	select {
	case <-ctx.Done():
		if err := ctx.Err(); err != nil {
			glog.Fatal(err)
		}
		break
	case trades := <-results:
		pp.Println(trades[:10])
		return
	}
}
Output:

Types

type HistoryRequest

type HistoryRequest struct {
	Pair  *currency.Pair
	Start time.Time
	End   time.Time
}

HistoryRequest - Trades history request.

type Stream

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

Stream - Poloniex stream.

func NewStream

func NewStream() (stream *Stream, err error)

NewStream - Creates a new connected poloniex stream.

func (*Stream) Close

func (stream *Stream) Close() (err error)

Close - Closes a stream.

func (*Stream) Errors

func (stream *Stream) Errors() <-chan error

Errors - Channel of errors.

func (*Stream) Events

func (stream *Stream) Events() <-chan *orderbook.Event

Events - Channel of orderbook.

func (*Stream) Subscribe

func (stream *Stream) Subscribe(pair *currency.Pair) error

Subscribe - Sends subscription to the server. Stores subscription pair in local memory, in case of disconnection it will re-subscribe.

Jump to

Keyboard shortcuts

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