v5

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

v5 (https://bybit-exchange.github.io/docs/v5/intro)

Enums Definitions (https://bybit-exchange.github.io/docs/v5/enum)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T any](c *Client, path string, param any) (T, error)

func GetPub

func GetPub[T any](c *Client, path string, param any) (T, error)

func Post

func Post[T any](c *Client, path string, param any) (T, error)

Types

type AccountType

type AccountType string

accountType (https://bybit-exchange.github.io/docs/v5/enum#accounttype)

const (
	AccountContract   AccountType = "CONTRACT"
	AccountSpot       AccountType = "SPOT"
	AccountInvestment AccountType = "INVESTMENT"
	AccountOption     AccountType = "OPTION"
	AccountUnified    AccountType = "UNIFIED"
	AccountFund       AccountType = "FUND"
)

type Category

type Category string

category (https://bybit-exchange.github.io/docs/v5/enum#category)

const (
	Spot    Category = "spot"
	Linear  Category = "linear"
	Inverse Category = "inverse"
	Option  Category = "option"
)

type Client

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

v5 HTTP client

func NewClient

func NewClient(client *transport.Client) *Client

func (*Client) Get

func (o *Client) Get(path string, param any, ret any) error

func (*Client) GetAccountCoinsBalance

func (o *Client) GetAccountCoinsBalance(accountType AccountType) (CoinsBalance, error)

func (*Client) GetCoinsBalance

func (o *Client) GetCoinsBalance(v GetCoinsBalance) (CoinsBalance, error)

func (*Client) GetDeliveryPrice

func (o *Client) GetDeliveryPrice(v GetDeliveryPrice) ([]DeliveryPrice, error)

func (*Client) GetFundingRateHistory

func (o *Client) GetFundingRateHistory(v GetFundingRateHistory) ([]FundingRateHistory, error)

func (*Client) GetHistoricalVolatility

func (o *Client) GetHistoricalVolatility(v GetHistoricalVolatility) ([]HistoricalVolatility, error)

func (*Client) GetIndexPriceKline

func (o *Client) GetIndexPriceKline(v GetKline) ([]Kline, error)

func (*Client) GetInstruments

func (o *Client) GetInstruments(v GetInstruments) ([]Instrument, error)

func (*Client) GetInsurance

func (o *Client) GetInsurance(v GetInsurance) ([]Insurance, error)

func (*Client) GetKeyInfo

func (o *Client) GetKeyInfo() (KeyInfo, error)

func (*Client) GetKline

func (o *Client) GetKline(v GetKline) ([]KlineExt, error)

func (*Client) GetMarkPriceKline

func (o *Client) GetMarkPriceKline(v GetKline) ([]Kline, error)

func (*Client) GetOpenInterest

func (o *Client) GetOpenInterest(v GetOpenInterest) ([]OpenInterest, error)

func (*Client) GetOrderbook

func (o *Client) GetOrderbook(v GetOrderbook) (Orderbook, error)

func (*Client) GetPremiumIndexPriceKline

func (o *Client) GetPremiumIndexPriceKline(v GetKline) ([]Kline, error)

func (*Client) GetPub

func (o *Client) GetPub(path string, param any, ret any) error

func (*Client) GetPublicTradingHistory

func (o *Client) GetPublicTradingHistory(v GetPublicTradingHistory) ([]PublicTradingHistory, error)

func (*Client) GetRiskLimit

func (o *Client) GetRiskLimit(v GetRiskLimit) ([]RiskLimit, error)

func (*Client) GetTickers

func (o *Client) GetTickers(v GetTickers) ([]Ticker, error)

func (*Client) Post

func (o *Client) Post(path string, param any, ret any) error

func (*Client) Transport

func (o *Client) Transport() *transport.Client

type CoinBalance

type CoinBalance struct {
	Coin            string
	TransferBalance transport.Float64
	WalletBalance   transport.Float64
	Bonus           string
}

type CoinsBalance

type CoinsBalance struct {
	AccountType AccountType
	MemberId    string
	Balances    []CoinBalance
}

(Get All Coins Balance) https://bybit-exchange.github.io/docs/v5/asset/all-balance

type ContractType

type ContractType string

contractType (https://bybit-exchange.github.io/docs/v5/enum#contracttype)

const (
	InversePerpetual ContractType = "InversePerpetual"
	LinearPerpetual  ContractType = "LinearPerpetual"
	LinearFutures    ContractType = "LinearFutures"
	InverseFutures   ContractType = "InverseFutures"
)

type DeliveryPrice

type DeliveryPrice struct {
	Symbol        string
	DeliveryPrice string
	DeliveryTime  string
}

type Error

type Error struct {
	transport.Err
}

https://bybit-exchange.github.io/docs/v5/error

func (*Error) ApiKeyExpired

func (o *Error) ApiKeyExpired() bool

func (*Error) ApiKeyInvalid

func (o *Error) ApiKeyInvalid() bool

func (*Error) InsufficientBalance

func (o *Error) InsufficientBalance() bool

func (*Error) KycNeeded

func (o *Error) KycNeeded() bool

func (*Error) TooManyVisits

func (o *Error) TooManyVisits() bool

func (*Error) UnmatchedIp

func (o *Error) UnmatchedIp() bool

type FundingRateHistory

type FundingRateHistory struct {
	Symbol               string
	FundingRate          string
	FundingRateTimestamp string
}

type GetCoinsBalance

type GetCoinsBalance struct {
	AccountType AccountType `param:"accountType"`
	MemberId    *string     `param:"memberId"`
	Coin        *string     `param:"coin"`
	WithBonus   *bool       `param:"withBonus"`
}

func (GetCoinsBalance) Do

func (o GetCoinsBalance) Do(client *Client) (CoinsBalance, error)

type GetDeliveryPrice

type GetDeliveryPrice struct {
	Category Category `param:"category"`
	Symbol   *string  `param:"symbol"`
	BaseCoin *string  `param:"baseCoin"`
	Limit    *int     `param:"limit"`
	Cursor   *string  `param:"cursor"`
}

Get Delivery Price (https://bybit-exchange.github.io/docs/v5/market/delivery-price)

category Required string Product type. spot,linear,inverse symbol string Symbol name baseCoin string Base coin. Default: BTC. valid for option only limit integer Limit for data size per page. [1, 200]. Default: 50 cursor string Cursor. Used for pagination

func (GetDeliveryPrice) Do

type GetFundingRateHistory

type GetFundingRateHistory struct {
	Category  Category `param:"category"`
	Symbol    string   `param:"symbol"`
	StartTime *int     `param:"startTime"`
	EndTime   *int     `param:"endTime"`
	Limit     *int     `param:"limit"`
}

Get Funding Rate History (https://bybit-exchange.github.io/docs/v5/market/history-fund-rate)

category Required string Product type. linear,inverse symbol Required string Symbol name startTime integer The start timestamp (ms) endTime integer The end timestamp (ms) limit integer Limit for data size per page. [1, 200]. Default: 200

func (GetFundingRateHistory) Do

type GetHistoricalVolatility

type GetHistoricalVolatility struct {
	Category  Category `param:"category"`
	BaseCoin  *string  `param:"baseCoin"`
	Period    *Period  `param:"period"`
	StartTime *int     `param:"startTime"`
	EndTime   *int     `param:"endTime"`
}

Get Historical Volatility (https://bybit-exchange.github.io/docs/v5/market/iv)

category Required string Product type. option baseCoin string Base coin. Default: return BTC data period integer Period startTime integer The start timestamp (ms) endTime integer The end timestamp (ms)

func (GetHistoricalVolatility) Do

type GetInstruments

type GetInstruments struct {
	Category Category `param:"category"`
	Symbol   *string  `param:"symbol"`
	Status   *Status  `param:"status"`
	BaseCoin *string  `param:"baseCoin"`
	Limit    *int     `param:"limit"`
	Cursor   *string  `param:"cursor"`
}

Get Instruments Info (https://bybit-exchange.github.io/docs/v5/market/instrument)

category Required string Product type. spot,linear,inverse symbol string Symbol name status string Symbol status filter, spot/linear/inverse has Trading only baseCoin string Base coin. linear,inverse,option only limit integer Limit for data size per page. [1, 1000]. Default: 500 cursor string Cursor. Used for pagination

func (GetInstruments) Do

func (o GetInstruments) Do(c *Client) ([]Instrument, error)

type GetInsurance

type GetInsurance struct {
	Coin *string `param:"coin"`
}

Get Insurance (https://bybit-exchange.github.io/docs/v5/market/insurance)

coin string coin. Default: return all insurance coins

func (GetInsurance) Do

func (o GetInsurance) Do(c *Client) ([]Insurance, error)

type GetKeyInfo

type GetKeyInfo struct {
}

func (GetKeyInfo) Do

func (o GetKeyInfo) Do(client *Client) (KeyInfo, error)

type GetKline

type GetKline struct {
	Category Category `param:"category"`
	Symbol   string   `param:"symbol"`
	Interval Interval `param:"interval"`
	Start    *int     `param:"start"`
	End      *int     `param:"end"`
	Limit    *int     `param:"limit"`
}

Get Kline (https://bybit-exchange.github.io/docs/v5/market/kline)

category Required string Product type. spot,linear,inverse symbol Required string Symbol name interval Required string Kline interval. 1,3,5,15,30,60,120,240,360,720,D,M,W start integer The start timestamp (ms) end integer The end timestamp (ms) limit integer Limit for data size per page. [1, 200]. Default: 200

func (GetKline) Do

func (o GetKline) Do(c *Client) ([]KlineExt, error)

func (GetKline) DoIndexPrice

func (o GetKline) DoIndexPrice(c *Client) ([]Kline, error)

Get Index Price Kline (https://bybit-exchange.github.io/docs/v5/market/index-kline)

func (GetKline) DoMarkPrice

func (o GetKline) DoMarkPrice(c *Client) ([]Kline, error)

Get Mark Price Kline (https://bybit-exchange.github.io/docs/v5/market/mark-kline)

func (GetKline) DoPremiumIndexPrice

func (o GetKline) DoPremiumIndexPrice(c *Client) ([]Kline, error)

Get Premium Index Price Kline (https://bybit-exchange.github.io/docs/v5/market/preimum-index-kline)

type GetOpenInterest

type GetOpenInterest struct {
	Category     Category     `param:"category"`
	Symbol       string       `param:"symbol"`
	IntervalTime IntervalTime `param:"intervalTime"`
	StartTime    *int         `param:"startTime"`
	EndTime      *int         `param:"endTime"`
	Limit        *int         `param:"limit"`
	Cursor       *string      `param:"cursor"`
}

Get Open Interest (https://bybit-exchange.github.io/docs/v5/market/open-interest)

category Required string Product type. linear,inverse symbol Required string Symbol name intervalTime Required string Interval. 5min,15min,30min,1h,4h,1d startTime integer The start timestamp (ms) endTime integer The end timestamp (ms) limit integer Limit for data size per page. [1, 200]. Default: 50 cursor string Cursor. Used for pagination

func (GetOpenInterest) Do

func (o GetOpenInterest) Do(c *Client) ([]OpenInterest, error)

type GetOrderbook

type GetOrderbook struct {
	Category Category `param:"category"`
	Symbol   string   `param:"symbol"`
	Limit    *int     `param:"limit"`
}

Get Orderbook (https://bybit-exchange.github.io/docs/v5/market/orderbook)

category Required string Product type. spot,linear,inverse,option symbol Required string Symbol name limit integer Limit size for each bid and ask

spot: [1, 50]. Default: 1.
linear&inverse: [1, 200]. Default: 25.
option: [1, 25]. Default: 1.

func (GetOrderbook) Do

func (o GetOrderbook) Do(c *Client) (Orderbook, error)

type GetPublicTradingHistory

type GetPublicTradingHistory struct {
	Category   Category `param:"category"`
	Symbol     *string  `param:"symbol"`
	BaseCoin   *string  `param:"baseCoin"`
	OptionType *string  `param:"optionType"`
	Limit      *int     `param:"limit"`
}

Get Public Trading History (https://bybit-exchange.github.io/docs/v5/market/recent-trade)

category Required string Product type. spot,linear,inverse,option symbol string Symbol name baseCoin string Base coin. For option only. If not passed, return BTC data by default optionType string Option type. Call or Put. For option only limit integer

func (GetPublicTradingHistory) Do

type GetRiskLimit

type GetRiskLimit struct {
	Category Category `param:"category"`
	Symbol   *string  `param:"symbol"`
}

Get Risk Limit (https://bybit-exchange.github.io/docs/v5/market/risk-limit)

category Required string Product type. linear,inverse symbol string Symbol name

func (GetRiskLimit) Do

func (o GetRiskLimit) Do(c *Client) ([]RiskLimit, error)

type GetTickers

type GetTickers struct {
	Category Category `param:"category"`
	Symbol   *string  `param:"symbol"`
	BaseCoin *string  `param:"baseCoin"`
	ExpDate  *string  `param:"expDate"`
}

Get Tickers (https://bybit-exchange.github.io/docs/v5/market/tickers)

category Required string Product type. spot,linear,inverse,option symbol string Symbol name baseCoin string Base coin. For option only expDate string Expiry date. e.g., 25DEC22. For option only

func (GetTickers) Do

func (o GetTickers) Do(c *Client) ([]Ticker, error)

type HistoricalVolatility

type HistoricalVolatility struct {
	Period int
	Value  string
	Time   string
}

type Instrument

type Instrument struct {
	Symbol             string
	ContractType       ContractType
	Status             Status
	BaseCoin           string
	QuoteCoin          string
	LaunchTime         string
	DeliveryTime       string
	DeliveryFeeRate    string
	PriceScale         string
	LeverageFilter     LeverageFilter
	PriceFilter        PriceFilter
	UnifiedMarginTrade bool
	FundingInterval    int
	SettleCoin         string
}

type Insurance

type Insurance struct {
	Coin    string
	Balance string
	Value   string
}

type Interval

type Interval string

interval (https://bybit-exchange.github.io/docs/v5/enum#interval)

1   - 1 minute
3   - 3 minutes
5   - 5 minutes
15  - 15 minutes
30  - 30 minutes
60  - 1 hour
120 - 2 hours
240 - 4 hours
360 - 6 hours
720 - 12 hours
D   - 1 day
W   - 1 week
M   - 1 month
const (
	Interval1m  Interval = "1"
	Interval3m  Interval = "3"
	Interval5m  Interval = "5"
	Interval15m Interval = "15"
	Interval30m Interval = "30"
	Interval1h  Interval = "60"
	Interval2h  Interval = "120"
	Interval4h  Interval = "240"
	Interval6h  Interval = "360"
	Interval12h Interval = "720"
	Interval1d  Interval = "D"
	Interval1w  Interval = "W"
	Interval1M  Interval = "M"
)

type IntervalTime

type IntervalTime string
const (
	IntervalTime5min  IntervalTime = "5min"
	IntervalTime15min IntervalTime = "15min"
	IntervalTime30min IntervalTime = "30min"
	IntervalTime1h    IntervalTime = "1h"
	IntervalTime4h    IntervalTime = "4h"
	IntervalTime1d    IntervalTime = "1d"
)

type KeyInfo

type KeyInfo struct {
	Id            transport.Float64
	Note          string
	ApiKey        string
	ReadOnly      int
	Secret        string
	Permissions   Permissions
	Ips           []string
	Type          int
	DeadlineDay   int
	CreatedAt     time.Time
	ExpiredAt     time.Time
	Unified       int
	Uta           int
	UserID        int
	InviterID     int
	VipLevel      string
	MktMakerLevel string
	AffiliateID   int
	RsaPublicKey  string
}

type Kline

type Kline struct {
	StartTime  string
	OpenPrice  string
	HighPrice  string
	LowPrice   string
	ClosePrice string
}

func UnmarshalKline

func UnmarshalKline(s []string) (r Kline, err error)

type KlineExt

type KlineExt struct {
	Kline
	Volume   string
	Turnover string
}

func UnmarshalKlineExt

func UnmarshalKlineExt(s []string) (r KlineExt, err error)

type LeverageFilter

type LeverageFilter struct {
	MinLeverage  string
	MaxLeverage  string
	LeverageStep string
}

type LotSizeFilter

type LotSizeFilter struct {
	MaxOrderQty         string
	MinOrderQty         string
	QtyStep             string
	PostOnlyMaxOrderQty string
}

type OpenInterest

type OpenInterest struct {
	OpenInterest string
	Timestamp    string
}

type Orderbook

type Orderbook struct {
	Symbol    string     `json:"s"`
	Bid       [][]string `json:"b"`
	Ask       [][]string `json:"a"`
	Timestamp int        `json:"ts"`
	UpdateID  int        `json:"u"`
}

type Period

type Period int

period (https://bybit-exchange.github.io/docs/v5/enum#period)

const (
	Period7days   Period = 7
	Period14days  Period = 14
	Period21days  Period = 21
	Period30days  Period = 30
	Period60days  Period = 60
	Period90days  Period = 90
	Period180days Period = 180
	Period270days Period = 270
)

type Permissions

type Permissions struct {
	ContractTrade []string
	Spot          []string
	Wallet        []string
	Options       []string
	Derivatives   []string
	CopyTrading   []string
	BlockTrade    []string
	Exchange      []string
	NFT           []string
}

type PositionIdx

type PositionIdx int

positionIdx (https://bybit-exchange.github.io/docs/v5/enum#positionidx)

const (
	OneWayMode          PositionIdx = 0
	BuySideOfHedgeMode  PositionIdx = 1
	SellSideOfHedgeMode PositionIdx = 2
)

type PriceFilter

type PriceFilter struct {
	MaxPrice string
	MinPrice string
	TickSize string
}

type PublicTradingHistory

type PublicTradingHistory struct {
	ExecId       string
	Symbol       string
	Price        string
	Size         string
	Side         string
	Time         string
	IsBlockTrade bool
}

type Response

type Response[T any] struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
	Time    uint64 `json:"time"`
	Result  T      `json:"result"`
}

type RiskLimit

type RiskLimit struct {
	Id                int
	Symbol            string
	RiskLimitValue    string
	MaintenanceMargin string
	InitialMargin     string
	IsLowestRisk      int
	MaxLeverage       string
}

type SmpType

type SmpType string

smpType (https://bybit-exchange.github.io/docs/v5/enum#smptype)

const (
	SmpTypeNone SmpType = "None"
	CancelMaker SmpType = "CancelMaker"
	CancelTaker SmpType = "CancelTaker"
	CancelBoth  SmpType = "CancelBoth"
)

type Status

type Status string

status (https://bybit-exchange.github.io/docs/v5/enum#status)

const (
	StatusPreLaunch  Status = "PreLaunch"
	StatusTrading    Status = "Trading"
	StatusSettling   Status = "Settling"
	StatusDelivering Status = "Delivering"
	StatusClosed     Status = "Closed"
)

type Ticker

type Ticker struct {
	Symol                  string
	LastPrice              string
	IndexPrice             string
	MarkPrice              string
	PrevPrice24h           string
	Price24hPcnt           string
	HighPrice24h           string
	LowPrice24h            string
	PrevPrice1h            string
	OpenInterest           string
	OpenInterestValue      string
	Turnover24h            string
	Volume24h              string
	FundingRate            string
	NextFundingTime        string
	PredictedDeliveryPrice string
	BasisRate              string
	DeliveryFeeRate        string
	DeliveryTime           string
	Ask1Size               string
	Bid1Price              string
	Ask1Price              string
	Bid1Size               string
	Basis                  string
}

type TimeInForce

type TimeInForce string

timeInForce (https://bybit-exchange.github.io/docs/v5/enum#timeinforce)

const (
	GoodTillCancel    TimeInForce = "GTC"
	ImmediateOrCancel TimeInForce = "IOC"
	FillOrKill        TimeInForce = "FOK"
)

type TriggerBy

type TriggerBy string

triggerBy (https://bybit-exchange.github.io/docs/v5/enum#triggerby)

const (
	TriggerByLastPrice  TriggerBy = "LastPrice"
	TriggerByIndexPrice TriggerBy = "IndexPrice"
	TriggerByMarkPrice  TriggerBy = "MarkPrice"
)

Jump to

Keyboard shortcuts

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