deribit

package
v0.0.0-...-5439e55 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DEFAULT_ID           = 44
	DEFAULT_TAKER_FEE    = 0.00075
	DEFAULT_MAKER_FEE    = -0.00025
	DEFAULT_LOT_SIZE     = 0.00000001
	DEFAULT_PRICE_FILTER = 0.00000001 //PRICE FILTER
	DEFAULT_TXFEE        = 0.005
	DEFAULT_WITHDRAW     = false
	DEFAULT_DEPOSIT      = false
	DEFAULT_CONFIRMATION = 2
)
View Source
const (
	API_URL = "https://test.deribit.com/api/v2"
)

The Base Endpoint URL

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountBalances

type AccountBalances []struct {
	Asset     string  `json:"asset"`
	Total     float64 `json:"total"`
	Available float64 `json:"available"`
	Locked    float64 `json:"locked"`
}

********* Private API Structure*********

type ContractsData

type ContractsData []struct {
	TickSize            float64 `json:"tick_size"`
	Strike              float64 `json:"strike,omitempty"`
	SettlementPeriod    string  `json:"settlement_period"`
	QuoteCurrency       string  `json:"quote_currency"`
	OptionType          string  `json:"option_type,omitempty"`
	MinTradeAmount      float64 `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        float64 `json:"contract_size"`
	BaseCurrency        string  `json:"base_currency"`
}

********* Public API Structure*********

type Deribit

type Deribit struct {
	ID      int
	Name    string `bson:"name"`
	Website string `bson:"website"`

	API_KEY    string
	API_SECRET string

	Source    exchange.DataSource // / exchange API / microservicve api 1 / PSQL
	SourceURI string
}

func CreateDeribit

func CreateDeribit(config *exchange.Config) *Deribit

*************************************************

func (*Deribit) ApiKeyGet

func (e *Deribit) ApiKeyGet(strRequestPath string, mapParams map[string]string) string

************** Signature Http Request ************** Method: API Get Request and Signature is required Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Create mapParams Depend on API Signature request Step 3: Add HttpGetRequest below strUrl if API has different requests

func (*Deribit) ApiKeyRequest

func (e *Deribit) ApiKeyRequest(strMethod, strRequestPath string, mapParams map[string]string) string

Method: API Request and Signature is required Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Create mapParams Depend on API Signature request

func (*Deribit) CanDeposit

func (e *Deribit) CanDeposit(coin *coin.Coin) bool

func (*Deribit) CanWithdraw

func (e *Deribit) CanWithdraw(coin *coin.Coin) bool

func (*Deribit) CancelAllOrder

func (e *Deribit) CancelAllOrder() error

func (*Deribit) CancelOrder

func (e *Deribit) CancelOrder(order *exchange.Order) error

func (*Deribit) DeleteCoin

func (e *Deribit) DeleteCoin(coin *coin.Coin)

func (*Deribit) DeletePair

func (e *Deribit) DeletePair(pair *pair.Pair)

func (*Deribit) DoAccountOperation

func (e *Deribit) DoAccountOperation(operation *exchange.AccountOperation) error

************** Private API **************

func (*Deribit) GetBalance

func (e *Deribit) GetBalance(coin *coin.Coin) float64

func (*Deribit) GetCoinBySymbol

func (e *Deribit) GetCoinBySymbol(symbol string) *coin.Coin

func (*Deribit) GetCoinConstraint

func (e *Deribit) GetCoinConstraint(coin *coin.Coin) *exchange.CoinConstraint

************** Coins on the Exchanges **************

func (*Deribit) GetCoins

func (e *Deribit) GetCoins() []*coin.Coin

func (*Deribit) GetCoinsData

func (e *Deribit) GetCoinsData() error

************** Public API ************** Get Coins Information (If API provide) Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Modify API Path(strRequestPath)

func (*Deribit) GetConfirmation

func (e *Deribit) GetConfirmation(coin *coin.Coin) int

func (*Deribit) GetConstraintFetchMethod

func (e *Deribit) GetConstraintFetchMethod(pair *pair.Pair) *exchange.ConstrainFetchMethod

*************** Exchange Constraint ***************

func (*Deribit) GetFee

func (e *Deribit) GetFee(pair *pair.Pair) float64

*************** Pair Constraint ***************

func (*Deribit) GetID

func (e *Deribit) GetID() int

*************** Exchange Information ***************

func (*Deribit) GetLotSize

func (e *Deribit) GetLotSize(pair *pair.Pair) float64

func (*Deribit) GetName

func (e *Deribit) GetName() exchange.ExchangeName

func (*Deribit) GetPairBySymbol

func (e *Deribit) GetPairBySymbol(symbol string) *pair.Pair

func (*Deribit) GetPairConstraint

func (e *Deribit) GetPairConstraint(pair *pair.Pair) *exchange.PairConstraint

************** Pairs on the Exchanges **************

func (*Deribit) GetPairs

func (e *Deribit) GetPairs() []*pair.Pair

func (*Deribit) GetPairsData

func (e *Deribit) GetPairsData() error
GetPairsData - Get Pairs Information (If API provide)

Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Modify API Path(strRequestUrl)

func (*Deribit) GetPriceFilter

func (e *Deribit) GetPriceFilter(pair *pair.Pair) float64

func (*Deribit) GetSymbolByCoin

func (e *Deribit) GetSymbolByCoin(coin *coin.Coin) string

func (*Deribit) GetSymbolByPair

func (e *Deribit) GetSymbolByPair(pair *pair.Pair) string

func (*Deribit) GetTradingWebURL

func (e *Deribit) GetTradingWebURL(pair *pair.Pair) string

func (*Deribit) GetTxFee

func (e *Deribit) GetTxFee(coin *coin.Coin) float64

*************** Coin Constraint ***************

func (*Deribit) HasPair

func (e *Deribit) HasPair(pair *pair.Pair) bool

func (*Deribit) InitData

func (e *Deribit) InitData() error

func (*Deribit) LimitBuy

func (e *Deribit) LimitBuy(pair *pair.Pair, quantity, rate float64) (*exchange.Order, error)

func (*Deribit) LimitSell

func (e *Deribit) LimitSell(pair *pair.Pair, quantity, rate float64) (*exchange.Order, error)

func (*Deribit) ListOrders

func (e *Deribit) ListOrders() ([]*exchange.Order, error)

func (*Deribit) LoadPublicData

func (e *Deribit) LoadPublicData(operation *exchange.PublicOperation) error

func (*Deribit) OrderBook

func (e *Deribit) OrderBook(p *pair.Pair) (*exchange.Maker, error)

Get Pair Market Depth Step 1: Change Instance Name (e *<exchange Instance Name>) Step 2: Add Model of API Response Step 3: Get Exchange Pair Code ex. symbol := e.GetSymbolByPair(p) Step 4: Modify API Path(strRequestUrl) Step 5: Add Params - Depend on API request Step 6: Convert the response to Standard Maker struct

func (*Deribit) OrderStatus

func (e *Deribit) OrderStatus(order *exchange.Order) error

func (*Deribit) SetCoinConstraint

func (e *Deribit) SetCoinConstraint(coinConstraint *exchange.CoinConstraint)

func (*Deribit) SetPairConstraint

func (e *Deribit) SetPairConstraint(pairConstraint *exchange.PairConstraint)

func (*Deribit) UpdateAllBalances

func (e *Deribit) UpdateAllBalances()

func (*Deribit) UpdateConstraint

func (e *Deribit) UpdateConstraint()

func (*Deribit) Withdraw

func (e *Deribit) Withdraw(coin *coin.Coin, quantity float64, addr, tag string) bool

Withdraw(coin *coin.Coin, quantity float64, addr, tag string)

type JsonResponse

type JsonResponse struct {
	Jsonrpc string          `json:"jsonrpc"`
	Data    json.RawMessage `json:"result"`
	UsIn    int64           `json:"usIn"`
	UsOut   int64           `json:"usOut"`
	UsDiff  int             `json:"usDiff"`
	Testnet bool            `json:"testnet"`
}

type OrderBook

type OrderBook struct {
	Timestamp int64 `json:"timestamp"`
	Stats     struct {
		Volume float64 `json:"volume"`
		Low    float64 `json:"low"`
		High   float64 `json:"high"`
	} `json:"stats"`
	State           string      `json:"state"`
	SettlementPrice float64     `json:"settlement_price"`
	OpenInterest    int         `json:"open_interest"`
	MinPrice        float64     `json:"min_price"`
	MaxPrice        float64     `json:"max_price"`
	MarkPrice       float64     `json:"mark_price"`
	LastPrice       float64     `json:"last_price"`
	InstrumentName  string      `json:"instrument_name"`
	IndexPrice      float64     `json:"index_price"`
	Funding8H       float64     `json:"funding_8h"`
	CurrentFunding  float64     `json:"current_funding"`
	ChangeID        int64       `json:"change_id"`
	Bids            [][]float64 `json:"bids"`
	BestBidPrice    float64     `json:"best_bid_price"`
	BestBidAmount   float64     `json:"best_bid_amount"`
	BestAskPrice    float64     `json:"best_ask_price"`
	BestAskAmount   float64     `json:"best_ask_amount"`
	Asks            [][]float64 `json:"asks"`
}

type PlaceOrder

type PlaceOrder struct {
	Symbol       string `json:"symbol"`
	OrderID      string `json:"orderId"`
	Side         string `json:"side"`
	Type         string `json:"type"`
	Price        string `json:"price"`
	AveragePrice string `json:"executedQty"`
	OrigQty      string `json:"origQty"`
	ExecutedQty  string `json:"executedQty"`
	Status       string `json:"status"`
	TimeInForce  string `json:"timeInForce"`
}

type WithdrawResponse

type WithdrawResponse struct {
	Msg     string `json:"msg"`
	Success bool   `json:"success"`
	ID      string `json:"id"`
}

Jump to

Keyboard shortcuts

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