market

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// https://bybit-exchange.github.io/docs/v5/market/history-fund-rate
	EndpointFundingRateHistory = "/v5/market/funding/history"
)
View Source
const (
	// https://bybit-exchange.github.io/docs/v5/market/orderbook
	EndpointOrderBook = "/v5/market/orderbook"
)
View Source
const (
	// https://bybit-exchange.github.io/docs/v5/market/tickers
	EndpointTickers = "/v5/market/tickers"
)

Variables

This section is empty.

Functions

func FundingRateHistoryData

func FundingRateHistoryData(connRest ConnectorRest, parm FundingRateHistoryParam) ([]byte, error)

func OrderBookData

func OrderBookData(connRest ConnectorRest, parm OrderBookParam) ([]byte, error)

func TickersData

func TickersData(connRest ConnectorRest, parm TickersParam) ([]byte, error)

Types

type FundingRateHistoryParam

type FundingRateHistoryParam struct {
	Category   CategoryType `structs:"category"`
	Symbol     string       `structs:"symbol,omitempty"`    // optional Symbol name
	StartTime  int          `structs:"startTime,omitempty"` // optional The start timestamp (ms)
	EndTime    int          `structs:"endTime,omitempty"`   // optional The end timestamp (ms)
	Limit      int          `structs:"limit,omitempty"`     // optional Limit for data size per page. [1, 200]. Default: 200
	RecvWindow int          `structs:"-"`                   // optional
}

type FundingRateHistoryResp

type FundingRateHistoryResp struct {
	RetCode int    `json:"retCode"` // Success/Error code
	RetMsg  string `json:"retMsg"`  // Success/Error msg. OK, success, SUCCESS indicate a successful response
	Result  struct {
		Category string `json:"category"` // Product type
		List     []struct {
			Symbol               string `json:"symbol"`               // Symbol name
			FundingRate          string `json:"fundingRate"`          // Funding rate
			FundingRateTimestamp string `json:"fundingRateTimestamp"` // Funding rate timestamp (ms)
		} `json:"list"` // Object
	} `json:"result"` // Business data result
	RetExtInfo struct{} `json:"retExtInfo"` // Extend info. Most of the time, it is {}
	Time       int64    `json:"time"`       // Current timestamp (ms)
}

func FundingRateHistory

func FundingRateHistory(connRest ConnectorRest, parm FundingRateHistoryParam) (FundingRateHistoryResp, error)

type OrderBookParam

type OrderBookParam struct {
	Category   CategoryType `structs:"category"`
	Symbol     string       `structs:"symbol"`          // Symbol name
	Limit      int          `structs:"limit,omitempty"` // optional Limit for data size per page. [1, 200]. Default: 200
	RecvWindow int          `structs:"-"`               // optional
}

type OrderBookResp

type OrderBookResp struct {
	RetCode int    `json:"retCode"` // Success/Error code
	RetMsg  string `json:"retMsg"`  // Success/Error msg. OK, success, SUCCESS indicate a successful response
	Result  struct {
		Symbol    string     `json:"s"`  // Symbol name
		Ask       [][]string `json:"a"`  // Ask, seller. Order by price asc	Ask[0] - Ask price	Ask[1] - Ask size
		Bid       [][]string `json:"b"`  // Bid, buyer. Sort by price desc	Bid[0] - Bid price	Bid[1] - Bid size
		Timestamp int64      `json:"ts"` // The timestamp (ms) that the system generates the data
		UpdateID  int        `json:"u"`  // Update ID
	} `json:"result"` // Business data result
	RetExtInfo struct{} `json:"retExtInfo"` // Extend info. Most of the time, it is {}
	Time       int64    `json:"time"`       // Current timestamp (ms)
}

func OrderBook

func OrderBook(connRest ConnectorRest, parm OrderBookParam) (OrderBookResp, error)

type TickersLinear_InverseResp

type TickersLinear_InverseResp struct {
	RetCode int    `json:"retCode"` // Success/Error code
	RetMsg  string `json:"retMsg"`  // Success/Error msg. OK, success, SUCCESS indicate a successful response
	Result  struct {
		Category string `json:"category"` // Product type
		List     []struct {
			Symbol                 string `json:"symbol"`                 // Symbol name
			LastPrice              string `json:"lastPrice"`              // Last price
			IndexPrice             string `json:"indexPrice"`             // Index price
			MarkPrice              string `json:"markPrice"`              // Mark price
			PrevPrice24H           string `json:"prevPrice24h"`           // Market price 24 hours ago
			Price24HPcnt           string `json:"price24hPcnt"`           // Percentage change of market price relative to 24h
			HighPrice24H           string `json:"highPrice24h"`           // The highest price in the last 24 hours
			LowPrice24H            string `json:"lowPrice24h"`            // The lowest price in the last 24 hours
			PrevPrice1H            string `json:"prevPrice1h"`            // Market price an hour ago
			OpenInterest           string `json:"openInterest"`           // Open interest size
			OpenInterestValue      string `json:"openInterestValue"`      // Open interest value
			Turnover24H            string `json:"turnover24h"`            // Turnover for 24h
			Volume24H              string `json:"volume24h"`              // Volume for 24h
			FundingRate            string `json:"fundingRate"`            // Funding rate
			NextFundingTime        string `json:"nextFundingTime"`        // Next funding time (ms)
			PredictedDeliveryPrice string `json:"predictedDeliveryPrice"` // Predicated delivery price. It has value when 30 min before delivery
			BasisRate              string `json:"basisRate"`              // Basis rate
			DeliveryFeeRate        string `json:"deliveryFeeRate"`        // Delivery fee rate
			DeliveryTime           string `json:"deliveryTime"`           // Delivery timestamp (ms)
			AskSize                string `json:"ask1Size"`               // Best ask size
			BidPrice               string `json:"bid1Price"`              // Best bid price
			AskPrice               string `json:"ask1Price"`              // Best ask price
			BidSize                string `json:"bid1Size"`               // Best bid size
			Basis                  string `json:"basis"`                  // Basis
		} `json:"list"` // Object
	} `json:"result"` // Business data result
	RetExtInfo struct{} `json:"retExtInfo"` // Extend info. Most of the time, it is {}
	Time       int64    `json:"time"`       // Current timestamp (ms)
}

func TickersInverse

func TickersInverse(connRest ConnectorRest, parm TickersParam) (TickersLinear_InverseResp, error)

func TickersLinear

func TickersLinear(connRest ConnectorRest, parm TickersParam) (TickersLinear_InverseResp, error)

type TickersOptionResp

type TickersOptionResp struct {
	RetCode int    `json:"retCode"` // Success/Error code
	RetMsg  string `json:"retMsg"`  // Success/Error msg. OK, success, SUCCESS indicate a successful response
	Result  struct {
		Category string `json:"category"` // Product type
		List     []struct {
			Symbol                 string `json:"symbol"`                 // Symbol name
			BidPrice               string `json:"bid1Price"`              // Best bid price
			BidSize                string `json:"bid1Size"`               // Best bid size
			BidIv                  string `json:"bid1Iv"`                 // Best bid iv
			AskPrice               string `json:"ask1Price"`              // Best ask price
			AskSize                string `json:"ask1Size"`               // Best ask size
			AskIv                  string `json:"ask1Iv"`                 // Best ask iv
			LastPrice              string `json:"lastPrice"`              // Last price
			HighPrice24H           string `json:"highPrice24h"`           // The highest price in the last 24 hours
			LowPrice24H            string `json:"lowPrice24h"`            // The lowest price in the last 24 hours
			MarkPrice              string `json:"markPrice"`              // Mark price
			IndexPrice             string `json:"indexPrice"`             // Index price
			MarkIv                 string `json:"markIv"`                 // Mark price iv
			UnderlyingPrice        string `json:"underlyingPrice"`        // Underlying price
			OpenInterest           string `json:"openInterest"`           // Open interest size
			Turnover24H            string `json:"turnover24h"`            // Turnover for 24h
			Volume24H              string `json:"volume24h"`              // Volume for 24h
			TotalVolume            string `json:"totalVolume"`            // Total volume
			TotalTurnover          string `json:"totalTurnover"`          // Total turnover
			Delta                  string `json:"delta"`                  // Delta
			Gamma                  string `json:"gamma"`                  // Gamma
			Vega                   string `json:"vega"`                   // Vega
			Theta                  string `json:"theta"`                  // Theta
			PredictedDeliveryPrice string `json:"predictedDeliveryPrice"` // Predicated delivery price. It has value when 30 min before delivery
			Change24H              string `json:"change24h"`              // The change in the last 24 hous
		} `json:"list"` // Object
	} `json:"result"` // Business data result
	RetExtInfo struct{} `json:"retExtInfo"` // Extend info. Most of the time, it is {}
	Time       int64    `json:"time"`       // Current timestamp (ms)
}

func TickersOption

func TickersOption(connRest ConnectorRest, parm TickersParam) (TickersOptionResp, error)

type TickersParam

type TickersParam struct {
	Category   CategoryType `structs:"category"`           // Product type. spot,linear,inverse,option
	Symbol     string       `structs:"symbol,omitempty"`   // optional Symbol name
	BaseCoin   string       `structs:"baseCoin,omitempty"` // optional Base coin. For option only
	ExpDate    string       `structs:"expDate,omitempty"`  // optional Expiry date. e.g., 25DEC22. For option only
	RecvWindow int          `structs:"-"`
}

type TickersSpotResp

type TickersSpotResp struct {
	RetCode int    `json:"retCode"` // Success/Error code
	RetMsg  string `json:"retMsg"`  // Success/Error msg. OK, success, SUCCESS indicate a successful response
	Result  struct {
		Category string `json:"category"` // Product type
		List     []struct {
			Symbol        string `json:"symbol"`        // Symbol name
			BidPrice      string `json:"bid1Price"`     // Best bid price
			BidSize       string `json:"bid1Size"`      // Best bid size
			AskPrice      string `json:"ask1Price"`     // Best ask price
			AskSize       string `json:"ask1Size"`      // Best ask size
			LastPrice     string `json:"lastPrice"`     // Last price
			PrevPrice24H  string `json:"prevPrice24h"`  // Market price 24 hours ago
			Price24HPcnt  string `json:"price24hPcnt"`  // Percentage change of market price relative to 24h
			HighPrice24H  string `json:"highPrice24h"`  // The highest price in the last 24 hours
			LowPrice24H   string `json:"lowPrice24h"`   // The lowest price in the last 24 hours
			Turnover24H   string `json:"turnover24h"`   // Turnover for 24h
			Volume24H     string `json:"volume24h"`     // Volume for 24h
			UsdIndexPrice string `json:"usdIndexPrice"` // USD index price. It can be empty
		} `json:"list"` // Object
	} `json:"result"` // Business data result
	RetExtInfo struct{} `json:"retExtInfo"` // Extend info. Most of the time, it is {}
	Time       int64    `json:"time"`       // Current timestamp (ms)
}

func TickersSpot

func TickersSpot(connRest ConnectorRest, parm TickersParam) (TickersSpotResp, error)

из-за того, что для каждого вида торговли возвращаются разные значения и в Go нет перегрузки, то пришлось сделать отдельные функции для каждого вида торговли применил патерн адаптера

Jump to

Keyboard shortcuts

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