Documentation ¶
Index ¶
- Constants
- Variables
- func Init(ctx context.Context, testNet bool) error
- func NewError(code int, msg string) error
- func NewIndexChannel(index string) exchange.Channel
- func NewOptionSymbol(currency string, st time.Time, strike float64, typ exchange.OptionType) (exchange.OptionSymbol, error)
- func NewOrderBookChannel(sym exchange.Symbol) exchange.Channel
- func NewOrderBookSnapChannel(sym exchange.Symbol, group string, depth int) exchange.Channel
- func OptionSymbolsWithIndex(index string) []exchange.OptionSymbol
- func ParseFutureSymbol(sym string) (exchange.FuturesSymbol, error)
- func ParseOptionSymbol(sym string) (exchange.OptionSymbol, error)
- func ParseSymbol(sym string) (exchange.Symbol, error)
- func SymbolLoop(ctx context.Context)
- func Symbols() []exchange.Symbol
- func UpdateSymbolMap(ctx context.Context) error
- type AccountSummaryRequest
- type AccountSummaryResp
- type AuthParam
- type AuthResult
- type AuthToken
- type BookData
- type BookGreeks
- type BookSnapData
- type BookStats
- type ChIndex
- type ChOrderBook
- type ChOrderBookSnap
- type ChTicker
- type Client
- func (c *Client) Auth(ctx context.Context) error
- func (c *Client) Call(ctx context.Context, method string, params interface{}, dest interface{}, ...) error
- func (c *Client) CancelOrder(ctx context.Context, order *exchange.Order) (*exchange.Order, error)
- func (c *Client) CreateOrder(ctx context.Context, req *exchange.OrderRequest, ...) (*exchange.Order, error)
- func (c *Client) Exchange() string
- func (c *Client) FetchOrder(ctx context.Context, order *exchange.Order) (*exchange.Order, error)
- func (client *Client) FetchOrderBook(ctx context.Context, symbol exchange.Symbol, maxDepth int) (*exchange.OrderBook, error)
- func (c *Client) Handle(ctx context.Context, notify *rpc.Notify)
- func (c *Client) OpenOrdersByCurrency(ctx context.Context, req *OpenOrdersByCurrencyRequest) ([]Order, error)
- func (c *Client) Subscribe(ctx context.Context, chs ...exchange.Channel) error
- func (c *Client) UnSubscribe(ctx context.Context, chs ...exchange.Channel) error
- type Codec
- type Error
- type FuturesSymbol
- type GetUserTradesByCurrencyReq
- func (gr *GetUserTradesByCurrencyReq) Count(ct int) *GetUserTradesByCurrencyReq
- func (gr *GetUserTradesByCurrencyReq) EndID(id string) *GetUserTradesByCurrencyReq
- func (gr *GetUserTradesByCurrencyReq) IncludeOld(io bool) *GetUserTradesByCurrencyReq
- func (gr *GetUserTradesByCurrencyReq) Kind(k string) *GetUserTradesByCurrencyReq
- func (gr *GetUserTradesByCurrencyReq) MarshalJSON() ([]byte, error)
- func (gr *GetUserTradesByCurrencyReq) Sorting(sr string) *GetUserTradesByCurrencyReq
- func (gr *GetUserTradesByCurrencyReq) StartID(id string) *GetUserTradesByCurrencyReq
- type IndexResult
- type InstrumentResult
- type InstrumentsRequest
- type JRPCError
- type Notify
- type OpenOrdersByCurrencyRequest
- type OptionSymbol
- type Order
- type OrderID
- type PositionRequest
- type PositionResult
- type PositionsRequest
- type PublicSettlementByInstrumentReq
- type Request
- type Response
- type RestBookData
- type RestBookReq
- type RestClient
- func (c *RestClient) Instruments(ctx context.Context, ir *InstrumentsRequest) ([]InstrumentResult, error)
- func (c *RestClient) OptionSymbols(ctx context.Context, currency string) ([]exchange.OptionSymbol, error)
- func (rc *RestClient) Request(ctx context.Context, method string, endPoint string, params url.Values, ...) error
- func (c *RestClient) Symbols(ctx context.Context, currency string) ([]exchange.Symbol, error)
- type Settlement
- type SettlementReq
- type SettlementResp
- type SettlementType
- type SpotSymbol
- type SwapSymbol
- type TickerGreeks
- type TickerResult
- type TickerStats
- type Token
- type TradeResp
- type TradeResult
Constants ¶
View Source
const ( WSAddr = "wss://www.deribit.com/ws/api/v2/" WSTestAddr = "wss://test.deribit.com/ws/api/v2/" )
View Source
const ( InstrumentsKindOption = "option" InstrumentsKindFuture = "future" InstrumentsEndPoint = "/public/get_instruments" )
View Source
const ( PrivateGetPosition = "private/get_position" PrivateGetPositions = "private/get_positions" )
View Source
const ( OptionTypeCall = "call" OptionTypePut = "put" KindOption = "option" KindFuture = "future" KindOptionCombo = "option_combo" KindFutureCombo = "future_combo" SettlePeriodPerpetual = "perpetual" SettlePeriodDay = "day" SettlePeriodWeek = "week" SettlePeriodMonth = "month" )
View Source
const (
GetUserTradesByCurrency = "private/get_user_trades_by_currency"
)
View Source
const (
JsonRPCVersion = "2.0"
)
View Source
const (
PrivateGetAccountSummary = "private/get_account_summary"
)
View Source
const (
PrivateGetOpenOrdersByCurrency = "/private/get_open_orders_by_currency"
)
View Source
const (
PublicTickerMethod = "public/ticker"
)
View Source
const (
RestOrderBookMethod = "public/get_order_book"
)
Variables ¶
View Source
var (
Currencies = []string{"BTC", "ETH"}
)
Functions ¶
func NewIndexChannel ¶ added in v0.3.0
func NewOptionSymbol ¶ added in v0.5.4
func NewOptionSymbol(currency string, st time.Time, strike float64, typ exchange.OptionType) (exchange.OptionSymbol, error)
NewOptionSymbol create a option symbol string with curreny, st, strike, typ. and parse it with ParseOptionSymbol
func NewOrderBookChannel ¶ added in v0.3.0
NewOrderBookChannel return channel for change of order book
func NewOrderBookSnapChannel ¶ added in v0.5.4
NewOrderBookSnap return channel for snapshot of orderbook
func OptionSymbolsWithIndex ¶ added in v0.5.4
func OptionSymbolsWithIndex(index string) []exchange.OptionSymbol
OptionSymbolWithIndex get all option symbol with specific index from symbol map
func ParseFutureSymbol ¶ added in v0.3.0
func ParseFutureSymbol(sym string) (exchange.FuturesSymbol, error)
func ParseOptionSymbol ¶ added in v0.3.0
func ParseOptionSymbol(sym string) (exchange.OptionSymbol, error)
func SymbolLoop ¶ added in v0.5.4
SymbolLoop start loop update symbol map periodly
func UpdateSymbolMap ¶ added in v0.5.4
UpdateSymbolMap rebuild symbol map. the symbol map update is leave to user
Types ¶
type AccountSummaryRequest ¶ added in v0.5.3
type AccountSummaryRequest struct { AuthToken Currency string `json:"currency"` Extended bool `json:"extended"` }
func NewAccountSummaryRequest ¶ added in v0.5.3
func NewAccountSummaryRequest(currency string) *AccountSummaryRequest
type AccountSummaryResp ¶ added in v0.3.0
type AccountSummaryResp struct { Balance decimal.Decimal `json:"balance"` OptionsSessionUPL decimal.Decimal `json:"options_session_upl"` DepositAddress string `json:"deposit_address"` OptionGamma decimal.Decimal `json:"option_gamma"` OptionTheta decimal.Decimal `json:"option_theta"` UserName string `json:"user"` Equity decimal.Decimal `json:"equity"` Type string `json:"type"` Currency string `json:"currency"` DeltaTotal decimal.Decimal `json:"delta_total"` FuturesSessionRPL decimal.Decimal `json:"futures_session_rpl"` PortfolioMarginingEnabled bool `json:"portfolio_margining_enabled"` TotalPL decimal.Decimal `json:"total_pl"` MarginBalance decimal.Decimal `json:"margin_balance"` TfaEnabled bool `json:"tfa_enabled"` OptionsSessionRPL decimal.Decimal `json:"options_session_rpl"` OptionsDelta decimal.Decimal `json:"options_delta"` FuturesPL decimal.Decimal `json:"futures_pl"` ID int `json:"id"` SessionUPL decimal.Decimal `json:"session_upl"` AvailableWithdrawalFunds decimal.Decimal `json:"available_withdrawal_funds"` CreationTimestmap int64 `json:"creation_timestamp"` OptionsPL decimal.Decimal `json:"options_pl"` SystemName string `json:"system_name"` InitialMargin decimal.Decimal `json:"initial_margin"` ProjectedInitialMargin decimal.Decimal `json:"projected_initial_margin"` MaintenanceMargin decimal.Decimal `json:"maintenance_margin"` ProjectedMaintenanceMargin decimal.Decimal `json:"projected_maintenance_margin"` SessinRPL decimal.Decimal `json:"session_rpl"` InteruserTransfersEnabled bool `json:"interuser_transfers_enabled"` OptionsVega decimal.Decimal `json:"options_vega"` ProjectedDeltaTotal decimal.Decimal `json:"projectd_delta_total"` Email string `json:"email"` FuturesSessionUPL decimal.Decimal `json:"futures_session_upl"` AvailableFunds decimal.Decimal `json:"available_funds"` OptionsValue decimal.Decimal `json:"options_value"` }
type AuthResult ¶
type BookGreeks ¶ added in v0.3.0
type BookSnapData ¶ added in v0.5.4
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 ChOrderBookSnap ¶ added in v0.5.4
type ChOrderBookSnap struct {
// contains filtered or unexported fields
}
func (*ChOrderBookSnap) String ¶ added in v0.5.4
func (cos *ChOrderBookSnap) String() string
type ChTicker ¶ added in v0.3.0
type ChTicker struct {
// contains filtered or unexported fields
}
func NewTickerChannel ¶ added in v0.3.0
type Client ¶
func NewTestWSClient ¶ added in v0.3.0
func NewWSClient ¶ added in v0.3.0
func (*Client) Call ¶ added in v0.3.0
func (c *Client) Call(ctx context.Context, method string, params interface{}, dest interface{}, private bool) error
Call genetic method
func (*Client) CancelOrder ¶ added in v0.3.0
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) FetchOrder ¶ added in v0.3.0
func (*Client) FetchOrderBook ¶ added in v0.3.0
func (*Client) OpenOrdersByCurrency ¶ added in v0.5.3
type FuturesSymbol ¶ added in v0.3.0
type FuturesSymbol struct {
*exchange.BaseFutureSymbol
}
func (*FuturesSymbol) String ¶ added in v0.3.0
func (fs *FuturesSymbol) String() string
type GetUserTradesByCurrencyReq ¶ added in v0.5.3
type GetUserTradesByCurrencyReq struct { AuthToken // contains filtered or unexported fields }
func NewGetUserTradesByCurrencyReq ¶ added in v0.5.3
func NewGetUserTradesByCurrencyReq(currency string) *GetUserTradesByCurrencyReq
func (*GetUserTradesByCurrencyReq) Count ¶ added in v0.5.3
func (gr *GetUserTradesByCurrencyReq) Count(ct int) *GetUserTradesByCurrencyReq
func (*GetUserTradesByCurrencyReq) EndID ¶ added in v0.5.3
func (gr *GetUserTradesByCurrencyReq) EndID(id string) *GetUserTradesByCurrencyReq
func (*GetUserTradesByCurrencyReq) IncludeOld ¶ added in v0.5.3
func (gr *GetUserTradesByCurrencyReq) IncludeOld(io bool) *GetUserTradesByCurrencyReq
func (*GetUserTradesByCurrencyReq) Kind ¶ added in v0.5.3
func (gr *GetUserTradesByCurrencyReq) Kind(k string) *GetUserTradesByCurrencyReq
func (*GetUserTradesByCurrencyReq) MarshalJSON ¶ added in v0.5.3
func (gr *GetUserTradesByCurrencyReq) MarshalJSON() ([]byte, error)
func (*GetUserTradesByCurrencyReq) Sorting ¶ added in v0.5.3
func (gr *GetUserTradesByCurrencyReq) Sorting(sr string) *GetUserTradesByCurrencyReq
func (*GetUserTradesByCurrencyReq) StartID ¶ added in v0.5.3
func (gr *GetUserTradesByCurrencyReq) StartID(id string) *GetUserTradesByCurrencyReq
type IndexResult ¶
type InstrumentResult ¶
type InstrumentResult struct { TickSize decimal.Decimal `json:"tick_size"` TakerCommision decimal.Decimal `json:"taker_commision"` MakerCommision decimal.Decimal `json:"maker_commision"` Strike decimal.Decimal `json:"strike"` SettlementPeriod string `json:"settlement_period"` QuoteCurrency string `json:"quote_currency"` BaseCurreny string `json:"base_currency"` MinTradeAmount decimal.Decimal `json:"min_trade_amount"` Kind string `json:"kind"` IsActive bool `json:"is_active"` InstrumentName string `json:"instrument_name"` ExpirationTimestamp int64 `json:"expiration_timestamp"` CreationTimestamp int64 `json:"creation_timestamp"` ContractSize decimal.Decimal `json:"contract_size"` OptionType string `json:"option_type"` }
type InstrumentsRequest ¶ added in v0.5.1
type InstrumentsRequest struct {
// contains filtered or unexported fields
}
func NewInstrumentsRequest ¶ added in v0.5.1
func NewInstrumentsRequest(currency string) *InstrumentsRequest
func (*InstrumentsRequest) Expired ¶ added in v0.5.1
func (ir *InstrumentsRequest) Expired() *InstrumentsRequest
func (*InstrumentsRequest) Kind ¶ added in v0.5.1
func (ir *InstrumentsRequest) Kind(kind string) *InstrumentsRequest
type Notify ¶
type Notify struct { Data json.RawMessage `json:"data"` Channel string `json:"channel"` }
type OpenOrdersByCurrencyRequest ¶ added in v0.5.3
type OpenOrdersByCurrencyRequest struct { AuthToken // contains filtered or unexported fields }
func NewOpenOrdersByCurrencyRequest ¶ added in v0.5.3
func NewOpenOrdersByCurrencyRequest(currency string) *OpenOrdersByCurrencyRequest
func (*OpenOrdersByCurrencyRequest) Kind ¶ added in v0.5.3
func (obr *OpenOrdersByCurrencyRequest) Kind(kind string) *OpenOrdersByCurrencyRequest
func (*OpenOrdersByCurrencyRequest) MarshalJSON ¶ added in v0.5.3
func (obr *OpenOrdersByCurrencyRequest) MarshalJSON() ([]byte, error)
func (*OpenOrdersByCurrencyRequest) Type ¶ added in v0.5.3
func (obr *OpenOrdersByCurrencyRequest) Type(typ string) *OpenOrdersByCurrencyRequest
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 PositionRequest ¶ added in v0.3.0
func NewPositionRequest ¶ added in v0.5.3
func NewPositionRequest(instrument string) *PositionRequest
type PositionResult ¶ added in v0.3.0
type PositionResult struct { AveragePrice decimal.Decimal `json:"average_price"` AveragePriceUSD decimal.Decimal `json:"average_price_usd"` Delta decimal.Decimal `json:"delta"` Direction string `json:"direction"` EstimatedLiquidationPrice decimal.Decimal `json:"estimated_liquidation_price"` FloatingProfitLoss decimal.Decimal `json:"floating_profit_loss"` FloatingProfitLossUSD decimal.Decimal `json:"floating_profit_loss_usd"` Gamma decimal.Decimal `json:"gamma"` IndexPrice decimal.Decimal `json:"index_price"` InitialMargin decimal.Decimal `json:"initial_margin"` InstrumentName string `json:"instrument_name"` Kind string `json:"kind"` Leverage int `json:"leverage"` MaintenanceMargin decimal.Decimal `json:"maintenance_margin"` MarkPrice decimal.Decimal `json:"mark_price"` OpenOrdersMargin decimal.Decimal `json:"open_orders_margin"` RealizedFunding decimal.Decimal `json:"realized_funding"` RealizedProfitLoss decimal.Decimal `json:"realized_profit_loss"` SettlementPrice decimal.Decimal `json:"settlement_price"` Size decimal.Decimal `json:"size"` SizeCurrency decimal.Decimal `json:"size_currency"` Theta decimal.Decimal `json:"theta"` TotalProfitLoss decimal.Decimal `json:"total_profit_loss"` Vega decimal.Decimal `json:"vega"` }
type PositionsRequest ¶ added in v0.3.0
type PositionsRequest struct { AuthToken Currency string `json:"currency"` Kind string `json:"kind"` }
func NewPositionsRequest ¶ added in v0.5.3
func NewPositionsRequest(currency string, kind string) *PositionsRequest
type PublicSettlementByInstrumentReq ¶ added in v0.3.0
type PublicSettlementByInstrumentReq struct { InstrumentName string `json:"instrument_name"` Type SettlementType `json:"type"` }
type RestBookData ¶ added in v0.3.0
type RestBookData struct { Timestamp int64 `json:"timestamp"` Stats BookStats `json:"stats"` State string `json:"state"` SettlementPrice decimal.Decimal `json:"settlement_price"` OpenInterest decimal.Decimal `json:"open_interest"` MinPrice decimal.Decimal `json:"min_price"` MaxPrice decimal.Decimal `json:"max_price"` MarkPrice decimal.Decimal `json:"mark_price"` MarkIV decimal.Decimal `json:"mark_iv"` LastPrice decimal.Decimal `json:"last_price"` InstrumentName string `json:"instrument_name"` IndexPrice decimal.Decimal `json:"index_price"` ChangeID int `json:"change_id'` Bids [][2]interface{} `json:"bids"` Asks [][2]interface{} `json:"asks"` BestBidPrice decimal.Decimal `json:"best_bid_price"` BestBidAmount decimal.Decimal `json:"best_bid_amount"` BestAskPrice decimal.Decimal `json:"best_ask_price"` BestAskAmount decimal.Decimal `json:"best_ask_amount"` Funding8H decimal.Decimal `json:"funding_8h"` CurrentFunding decimal.Decimal `json:"current_funding"` Greeks BookGreeks `json:"greeks"` }
type RestBookReq ¶ added in v0.3.0
type RestClient ¶ added in v0.5.1
type RestClient struct {
// contains filtered or unexported fields
}
func NewRestClient ¶ added in v0.5.1
func NewRestClient(key, secret string) *RestClient
func NewTestRestClient ¶ added in v0.5.1
func NewTestRestClient(key, secret string) *RestClient
func (*RestClient) Instruments ¶ added in v0.5.1
func (c *RestClient) Instruments(ctx context.Context, ir *InstrumentsRequest) ([]InstrumentResult, error)
func (*RestClient) OptionSymbols ¶ added in v0.5.1
func (c *RestClient) OptionSymbols(ctx context.Context, currency string) ([]exchange.OptionSymbol, error)
type Settlement ¶ added in v0.3.0
type Settlement struct { Type string `json:"type"` Timestamp int64 `json:"timestamp"` SessionProfitLoss decimal.Decimal `json:"session_profit_loss"` ProfitLoss decimal.Decimal `json:"profit_loss"` Position decimal.Decimal `json:"position"` MarkPrice decimal.Decimal `json:"mark_price"` InstrumentName string `json:"instrument_name"` IndexPrice decimal.Decimal `json:"index_price"` }
type SettlementReq ¶ added in v0.3.0
type SettlementReq struct { AuthToken InstrumentName string `json:"instrument_name"` Type SettlementType `json:"type"` }
type SettlementResp ¶ added in v0.3.0
type SettlementResp struct { Settlements []Settlement `json:"settlements"` Continuation string `json:"continuation"` }
type SettlementType ¶ added in v0.3.0
type SettlementType string
const ( SettlementMethodByInstrument = "private/get_settlement_history_by_instrument" PublicSettlementMethodByInstrument = "public/get_last_settlements_by_instrument" SettlementTypeSettlement SettlementType = "settlement" SettlementTypeDelivery SettlementType = "delivery" SettlementTypeBankrupcty SettlementType = "bankruptcy" )
type SpotSymbol ¶
type SpotSymbol struct {
*exchange.BaseSpotSymbol
}
func ParseIndexSymbol ¶ added in v0.3.0
func ParseIndexSymbol(symbol string) (*SpotSymbol, error)
func (*SpotSymbol) String ¶
func (ss *SpotSymbol) String() string
type SwapSymbol ¶ added in v0.3.0
type SwapSymbol struct {
*exchange.BaseSwapSymbol
}
func (*SwapSymbol) String ¶ added in v0.3.0
func (ss *SwapSymbol) String() string
type TickerGreeks ¶ added in v0.3.0
type TickerResult ¶ added in v0.3.0
type TickerResult struct { UnderlyingPrice decimal.Decimal `json:"underlying_price"` UnderlyingIndex string `json:"underlying_index"` Timestamp int64 `json:"timestamp"` State string `json:"state"` Stats TickerStats `json:"stats"` SettlementPrice decimal.Decimal `json:"settlement_price"` OpenInterest decimal.Decimal `json:"open_interest"` MinPrice decimal.Decimal `json:"min_price"` MaxPrice decimal.Decimal `json:"max_price"` MarkPrice decimal.Decimal `json:"mark_price"` MarkIV decimal.Decimal `json:"mark_iv"` LastPrice decimal.Decimal `json:"last_price"` InterestRate decimal.Decimal `json:"interest_rate"` InstrumentName string `json:"instrument_name"` IndexPrice decimal.Decimal `json:"index_price"` Greeks TickerGreeks `json:"greeks"` EstimatedDeliveryPrice decimal.Decimal `json:"estimated_delivery_price"` BidIV decimal.Decimal `json:"bid_iv"` BestBidPrice decimal.Decimal `json:"best_bid_price"` BestBidAmount decimal.Decimal `json:"best_bid_amount"` BestAskPrice decimal.Decimal `json:"best_ask_price"` BestAskAmount decimal.Decimal `json:"best_ask_amount"` AskIV decimal.Decimal `json:"ask_iv"` }
type TickerStats ¶ added in v0.3.0
type TradeResp ¶ added in v0.5.3
type TradeResp struct { HasMore bool `json:"has_more"` Trades []TradeResult `json:"trades"` }
type TradeResult ¶ added in v0.5.3
type TradeResult struct { Amount decimal.Decimal `json:"amount"` BlockTradeID string `json:"block_trade_id"` Direction string `json:"direction"` Fee decimal.Decimal `json:"fee"` FeeCurrency string `json:"fee_currency"` IndexPrice decimal.Decimal `json:"index_price"` InstrumentName string `json:"instrument_name"` IV decimal.Decimal `json:"iv"` Label string `json:"label"` Liquidation string `json:"liquidation"` Liquidity string `json:"liquidity"` MarkPrice decimal.Decimal `json:"mark_price"` MatchingID string `json:"matching_id"` OrderID string `json:"order_id"` OrderType string `json:"order_type"` PostOnly bool `json:"post_only"` Price decimal.Decimal `json:"price"` ProfitLoss decimal.Decimal `json:"profit_loss"` ReduceOnly bool `json:"reduce_only"` SelfTrade bool `json:"self_trade"` State string `json:"state"` TickDirection int `json:"tick_direction"` Timestamp int64 `json:"timestamp"` TradeID string `json:"trade_id"` TradeSeq int64 `json:"trade_seq"` UnderlyingPrice decimal.Decimal `json:"underlying_price"` }
Click to show internal directories.
Click to hide internal directories.