deribit

package module
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2020 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeout = errors.New("timed out waiting for a response")

ErrTimeout - request timed out

Functions

This section is empty.

Types

type Exchange

type Exchange struct {
	RPCCore
	// contains filtered or unexported fields
}

Exchange is an API wrapper with the exchange

func NewExchange

func NewExchange(test bool, errs chan error, stop chan bool) (*Exchange, error)

NewExchange creates a new API wrapper key and secret can be ignored if you are only calling public endpoints

func NewExchangeFromCore added in v3.1.0

func NewExchangeFromCore(test bool, core RPCCore) *Exchange

NewExchangeFromCore creates a new exchange from an existing RPCCore

func (*Exchange) Authenticate

func (e *Exchange) Authenticate(keys ...string) error

Authenticate : 1st param: API Key, 2nd param: API Secret

func (*Exchange) Client

func (e *Exchange) Client() *client.Deribit

Client returns an initialised API client

func (*Exchange) Close

func (e *Exchange) Close() error

Close the websocket connection

func (*Exchange) Connect

func (e *Exchange) Connect() error

Connect to the websocket API

func (*Exchange) Reconnect added in v3.1.0

func (e *Exchange) Reconnect(core *RPCCore)

Reconnect reconnect is already built-in on OnDisconnect. Use this method only within OnDisconnect to override it

func (*Exchange) SetDisconnectHandler added in v3.1.0

func (e *Exchange) SetDisconnectHandler(f func(*RPCCore))

SetDisconnectHandler overrides the default disconnect handler

func (*Exchange) SetLogOutput added in v3.1.0

func (e *Exchange) SetLogOutput(w io.Writer)

SetLogOutput set log output

func (*Exchange) SubscribeAnnouncements

func (e *Exchange) SubscribeAnnouncements() (chan *models.AnnouncementNotification, error)

SubscribeAnnouncements subscribes to the announcements channel

func (*Exchange) SubscribeBookGroup

func (e *Exchange) SubscribeBookGroup(instrument_name, group, depth, interval string) (chan *models.BookNotification, error)

SubscribeBookGroup subscribes to the book.{instrument_name}.{group}.{depth}.{interval} channel

func (*Exchange) SubscribeBookInterval

func (e *Exchange) SubscribeBookInterval(instrument_name, interval string) (chan *models.BookNotificationRaw, error)

SubscribeBookInterval subscribes to the book.{instrument_name}.{interval} channel

func (*Exchange) SubscribeDeribitPriceIndex

func (e *Exchange) SubscribeDeribitPriceIndex(index_name string) (chan *models.DeribitPriceIndexNotification, error)

SubscribeDeribitPriceIndex subscribes to the deribit_price_index.{index_name} channel

func (*Exchange) SubscribeDeribitPriceRanking

func (e *Exchange) SubscribeDeribitPriceRanking(index_name string) (chan *models.DeribitPriceRankingNotification, error)

SubscribeDeribitPriceRanking subscribes to the deribit_price_ranking.{index_name} channel

func (*Exchange) SubscribeEstimatedExpirationPrice

func (e *Exchange) SubscribeEstimatedExpirationPrice(index_name string) (chan *models.EstimatedExpirationPriceNotification, error)

SubscribeEstimatedExpirationPrice subscribes to the estimated_expiration_price.{index_name} channel

func (*Exchange) SubscribeMarkPriceOptions

func (e *Exchange) SubscribeMarkPriceOptions(index_name string) (chan *models.MarkpriceOptionsNotification, error)

SubscribeMarkPriceOptions subscribes to the markprice.options.{index_name} channel

func (*Exchange) SubscribePerpetual

func (e *Exchange) SubscribePerpetual(instrument_name, interval string) (chan *models.PerpetualNotification, error)

SubscribePerpetual subscribes to the perpetual.{instrument_name}.{interval} channel

func (*Exchange) SubscribeQuote

func (e *Exchange) SubscribeQuote(instrument_name string) (chan *models.QuoteNotification, error)

SubscribeQuote subscribes to the quote.{instrument_name} channel

func (*Exchange) SubscribeTicker

func (e *Exchange) SubscribeTicker(instrument_name, interval string) (chan *models.TickerNotification, error)

SubscribeTicker subscribes to the ticker.{instrument_name}.{interval} channel

func (*Exchange) SubscribeTrades

func (e *Exchange) SubscribeTrades(instrument_name, interval string) (chan *models.PublicTrade, error)

SubscribeTrades subscribes to the trades.{instrument_name}.{interval} channel

func (*Exchange) SubscribeUserOrdersInstrumentName

func (e *Exchange) SubscribeUserOrdersInstrumentName(instrument_name, interval string) (chan *models.Order, error)

SubscribeUserOrdersInstrumentName subscribes to the user.orders.{instrument_name}.{interval} channel

func (*Exchange) SubscribeUserOrdersKind

func (e *Exchange) SubscribeUserOrdersKind(kind, currency, interval string) (chan *models.Order, error)

SubscribeUserOrdersKind subscribes to the user.orders.{kind}.{currency}.{interval} channel

func (*Exchange) SubscribeUserPortfolio

func (e *Exchange) SubscribeUserPortfolio(currency string) (chan *models.UserPortfolioNotification, error)

SubscribeUserPortfolio subscribes to the user.portfolio.{currency} channel

func (*Exchange) SubscribeUserTradesInstrument

func (e *Exchange) SubscribeUserTradesInstrument(instrument_name, interval string) (chan *models.UserTrade, error)

SubscribeUserTradesInstrument subscribes to the user.trades.{instrument_name}.{interval} channel

func (*Exchange) SubscribeUserTradesKind

func (e *Exchange) SubscribeUserTradesKind(kind, currency, interval string) (chan *models.UserTrade, error)

SubscribeUserTradesKind subscribes to the user.trades.{kind}.{currency}.{interval} channel

type RPCCall

type RPCCall struct {
	Req   *RPCRequest
	Res   *RPCResponse
	Error error
	Done  chan bool
}

RPCCall represents the entire call from request to response

func NewRPCCall

func NewRPCCall(req *RPCRequest) *RPCCall

NewRPCCall returns a new RPCCall initialised with a done channel and request

func (*RPCCall) CloseError added in v3.1.0

func (r *RPCCall) CloseError(err error)

func (*RPCCall) CloseOK added in v3.1.0

func (r *RPCCall) CloseOK()

type RPCCore added in v3.1.0

type RPCCore struct {
	OnConnect func()
	// contains filtered or unexported fields
}

RPCCore actually sends and receives messages

func (*RPCCore) Submit added in v3.1.0

func (r *RPCCore) Submit(operation *runtime.ClientOperation) (interface{}, error)

Submit satisfies the runtime.ClientTransport interface

type RPCError

type RPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

RPCError error object

type RPCNotification

type RPCNotification struct {
	JsonRpc string
	Method  string `json:"method"`
	Params  struct {
		Data    json.RawMessage `json:"data"`
		Channel string          `json:"channel"`
	} `json:"params,omitempty"`
}

RPCNotification is a notification which we have subscribed to

type RPCRequest

type RPCRequest struct {
	JsonRpc string                 `json:"jsonrpc"`
	Method  string                 `json:"method"`
	ID      uint64                 `json:"id"`
	Params  map[string]interface{} `json:"params,omitempty"`
}

RPCRequest is what we send to the remote Implements runtime.ClientRequest

func NewRPCRequest

func NewRPCRequest(method string) *RPCRequest

func (*RPCRequest) AddAuth added in v3.1.0

func (r *RPCRequest) AddAuth(auth *models.PublicAuthResponse)

func (RPCRequest) GetBody

func (RPCRequest) GetBody() []byte

func (RPCRequest) GetBodyParam

func (RPCRequest) GetBodyParam() interface{}

func (RPCRequest) GetFileParam

func (RPCRequest) GetFileParam() map[string][]runtime.NamedReadCloser

func (RPCRequest) GetHeaderParams

func (RPCRequest) GetHeaderParams() http.Header

func (RPCRequest) GetMethod

func (RPCRequest) GetMethod() string

func (*RPCRequest) GetPath

func (r *RPCRequest) GetPath() string

func (RPCRequest) GetQueryParams

func (RPCRequest) GetQueryParams() url.Values

func (RPCRequest) SetBodyParam

func (RPCRequest) SetBodyParam(interface{}) error

func (RPCRequest) SetFileParam

func (RPCRequest) SetFileParam(string, ...runtime.NamedReadCloser) error

func (RPCRequest) SetFormParam

func (RPCRequest) SetFormParam(string, ...string) error

func (RPCRequest) SetHeaderParam

func (RPCRequest) SetHeaderParam(string, ...string) error

func (RPCRequest) SetPathParam

func (RPCRequest) SetPathParam(string, string) error

func (*RPCRequest) SetQueryParam

func (r *RPCRequest) SetQueryParam(key string, vals ...string) error

func (RPCRequest) SetTimeout

func (RPCRequest) SetTimeout(time.Duration) error

type RPCResponse

type RPCResponse struct {
	JsonRpc string          `json:"jsonrpc"`
	ID      uint64          `json:"id,omitempty"`
	Result  json.RawMessage `json:"result"`
	Error   *RPCError       `json:"error,omitempty"`
}

RPCResponse is what we receive from the remote Implements runtime.ClientResponse

func (*RPCResponse) Body

func (r *RPCResponse) Body() io.ReadCloser

func (*RPCResponse) Code

func (r *RPCResponse) Code() int

func (RPCResponse) GetHeader

func (RPCResponse) GetHeader(string) string

func (*RPCResponse) Message

func (r *RPCResponse) Message() string

type RPCSubscription

type RPCSubscription struct {
	Data    chan *RPCNotification
	Channel string
}

RPCSubscription is a subscription to an event type to receive notifications about

Jump to

Keyboard shortcuts

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