deribit

package
v0.3.0-pre2 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WSAddr     = "wss://www.deribit.com/ws/api/v2/"
	WSTestAddr = "wss://test.deribit.com/ws/api/v2/"
)
View Source
const (
	OptionTypeCall = "call"
	OptionTypePut  = "put"
)
View Source
const (
	JsonRPCVersion = "2.0"
)

Variables

This section is empty.

Functions

func NewError

func NewError(code int, msg string) error

func NewIndexChannel added in v0.3.0

func NewIndexChannel(sym exchange.Symbol) exchange.Channel

func NewOrderBookChannel added in v0.3.0

func NewOrderBookChannel(sym exchange.Symbol) exchange.Channel

Types

type AuthParam

type AuthParam struct {
	GrantType    string `json:"grant_type"`
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
}

type AuthResult

type AuthResult struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
	TokenType    string `json:"token_type"`
}

type AuthToken

type AuthToken struct {
	AccessToken string `json:"access_token"`
}

func (*AuthToken) SetToken

func (ap *AuthToken) SetToken(token string)

type BookData

type BookData struct {
	Timestamp      int              `json:"timestamp"`
	InstrumentName string           `json:"instrument_name"`
	ChangeID       int              `json:"charge_id"`
	Bids           [][3]interface{} `json:"bids"`
	Asks           [][3]interface{} `json:"asks"`
}

type ChIndex added in v0.3.0

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

func (*ChIndex) String added in v0.3.0

func (ci *ChIndex) String() string

type ChOrderBook added in v0.3.0

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

func (*ChOrderBook) String added in v0.3.0

func (co *ChOrderBook) String() string

type Client

type Client struct {
	*exchange.WSClient
	// contains filtered or unexported fields
}

func NewTestWSClient added in v0.3.0

func NewTestWSClient(key, secret string, data chan interface{}) *Client

func NewWSClient added in v0.3.0

func NewWSClient(key, secret string, data chan interface{}) *Client

func (*Client) Auth added in v0.3.0

func (c *Client) Auth(ctx context.Context) error

Auth is done by client.call

func (*Client) CancelOrder added in v0.3.0

func (c *Client) CancelOrder(ctx context.Context, order *exchange.Order) (*exchange.Order, error)

func (*Client) CreateOrder added in v0.3.0

func (c *Client) CreateOrder(ctx context.Context, req *exchange.OrderRequest, opts ...exchange.OrderReqOption) (*exchange.Order, error)

func (*Client) Exchange

func (c *Client) Exchange() string

func (*Client) FetchOrder added in v0.3.0

func (c *Client) FetchOrder(ctx context.Context, order *exchange.Order) (*exchange.Order, error)

func (*Client) Handle added in v0.3.0

func (c *Client) Handle(ctx context.Context, notify *rpc.Notify)

func (*Client) NewOptionSymbol

func (c *Client) NewOptionSymbol(index string, st time.Time, strike float64, typ exchange.OptionType) exchange.OptionSymbol

func (*Client) NewSpotSymbol

func (c *Client) NewSpotSymbol(base, quote string) exchange.SpotSymbol

func (*Client) OptionFetchInstruments

func (c *Client) OptionFetchInstruments(ctx context.Context, currency string) ([]InstrumentResult, error)

func (*Client) OptionSymbols added in v0.3.0

func (c *Client) OptionSymbols(ctx context.Context, currency string) ([]exchange.OptionSymbol, error)

func (*Client) ParseOptionSymbol

func (c *Client) ParseOptionSymbol(val string) (exchange.OptionSymbol, error)

func (*Client) ParseSpotSymbol

func (c *Client) ParseSpotSymbol(sym string) (exchange.SpotSymbol, error)

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, chs ...exchange.Channel) error

func (*Client) UnSubscribe

func (c *Client) UnSubscribe(ctx context.Context, chs ...exchange.Channel) error

type Codec

type Codec struct {
}

func (*Codec) Decode

func (cc *Codec) Decode(raw []byte) (rpc.Response, error)

func (*Codec) Encode

func (cc *Codec) Encode(req rpc.Request) ([]byte, error)

type Error

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

type IndexResult

type IndexResult struct {
	IndexName string  `json:"index_name"`
	Price     float64 `json:"price"`
	Timestamp int64   `json:"timestamp"`
}

type InstrumentResult

type InstrumentResult struct {
	TickSize            float64 `json:"tick_size"`
	TakerCommision      float64 `json:"taker_commision"`
	MakerCommision      float64 `json:"maker_commision"`
	Strike              float64 `json:"strike"`
	SettlementPeriod    string  `json:"settlement_period"`
	QuoteCurrency       string  `json:"quote_currency"`
	BaseCurreny         string  `json:"base_currency"`
	MinTradeAmount      float64 `json:"min_trade_amount"`
	Kind                string  `json:"kind"`
	IsActive            bool    `json:"is_active"`
	InstrumentName      string  `json:"instrument_name"`
	ExpirationTimestamp int64   `json:"expeiration_timestamp"`
	CreationTimestamp   int64   `json:"creation_timestamp"`
	ContractSize        float64 `json:"contract_size"`
	OptionType          string  `json:"option_type"`
}

type JRPCError

type JRPCError struct {
	Code int
	Msg  string
}

JRPCError json rpc error data

func (*JRPCError) Error

func (je *JRPCError) Error() string

func (*JRPCError) Is

func (js *JRPCError) Is(target error) bool

type Notify

type Notify struct {
	Data    json.RawMessage `json:"data"`
	Channel string          `json:"channel"`
}

type OptionSymbol

type OptionSymbol struct {
	*exchange.BaseOptionSymbol
}

func (*OptionSymbol) String

func (sym *OptionSymbol) String() string

type Order

type Order struct {
	Price                decimal.Decimal `json:"price"`
	Amount               decimal.Decimal `json:"amount"`
	AveragePrice         decimal.Decimal `json:"average_price"`
	OrderState           string          `json:"order_state"`
	OrderID              string          `json:"order_id"`
	LastUpdatedTimestamp int64           `json:"last_update_timestamp"`
	CreationTimestamp    int64           `json:"creation_timestamp"`
	Commision            decimal.Decimal `json:"commision"`
	Direction            string          `json:"direction"`
	FilledAmont          decimal.Decimal `json:"filled_amount"`
	InstrumentName       string          `json:"instrument_name"`
}

type OrderID

type OrderID string

func NewOrderID

func NewOrderID(id string) OrderID

func (OrderID) String

func (id OrderID) String() string

type Request

type Request struct {
	ID      int64       `json:"id"`
	Method  string      `json:"method"`
	JsonRPC string      `json:"jsonrpc"`
	Params  interface{} `json:"params"`
}

type Response

type Response struct {
	JsonRPC string          `json:"jsonrpc"`
	ID      int64           `json:"id"`
	Error   Error           `json:"error"`
	Result  json.RawMessage `json:"result"`
	Method  string          `json:"method"`
	Params  Notify          `json:"params"`
}

type SpotSymbol

type SpotSymbol struct {
	*exchange.BaseSpotSymbol
}

func (*SpotSymbol) String

func (sym *SpotSymbol) String() string

type Token

type Token interface {
	SetToken(string)
}

Jump to

Keyboard shortcuts

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