bybit

package module
v0.0.0-...-2c764a3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: MIT Imports: 15 Imported by: 0

README

Bybit-Go
Static Badge Static Badge

bybit-go

Go API V5 connector for Bybit's HTTP and WebSockets APIs.

bybit docs

//not finished yet still working on this... //TODO description and how it work

Markets

Endpoint Description Status
Get Bybit Server Time GET /v5/market/time
Get Kline GET /v5/market/kline
Get Mark Price Kline GET /v5/market/mark-price-kline
Get Index Price Kline GET /v5/market/index-price-kline
Get Premium Index Price Kline GET /v5/market/premium-index-price-kline
Get Instruments Info GET /v5/market/instruments-info
Get Orderbook GET /v5/market/orderbook
Get Tickers GET /v5/market/tickers
Get Funding Rate History GET /v5/market/funding/history
Get Public Recent Trading History GET /v5/market/recent-trade
Get Open Interest GET /v5/market/open-interest
Get Historical Volatility GET /v5/market/historical-volatility
Get Insurance GET /v5/market/insurance
Get Risk Limit GET /v5/market/risk-limit
Get Delivery Price GET /v5/market/delivery-price
Get Long Short Ratio GET /v5/market/account-ratio

Trade

Endpoint Description Status
Place Order POST /v5/order/create
Amend Order POST /v5/order/amend
Cancel Order POST /v5/order/cancel
Get Open & Closed Orders GET /v5/order/realtime
Cancel All Orders POST /v5/order/cancel-all
Get Order History GET /v5/order/history
Get Trade History GET /v5/execution/list
Batch Place Order POST /v5/order/create-batch
Batch Amend Order POST /v5/order/amend-batch
Batch Cancel Order POST /v5/order/cancel-batch
Get Borrow Quota (Spot) GET /v5/order/spot-borrow-check
Set Disconnect Cancel All POST /v5/order/disconnected-cancel-all

Position

Endpoint Description Status
Get Position Info GET /v5/position/list
Set Leverage POST /v5/position/set-leverage
Switch Cross/Isolated Margin POST /v5/position/switch-isolated
Set TP/SL Mode POST /v5/position/set-tpsl-mode
Switch Position Mode POST /v5/position/switch-mode
Set Risk Limit POST /v5/position/set-risk-limit
Set Trading Stop POST /v5/position/trading-stop
Set Auto Add Margin POST /v5/position/set-auto-add-margin
Add Or Reduce Margin POST /v5/position/add-margin
Get Closed PnL GET /v5/position/closed-pnl
Move Position POST /v5/position/move-positions
Get Move Position History GET /v5/position/move-history
Confirm New Risk Limit POST /v5/position/confirm-pending-mmr

Account

Endpoint Description Status
GET /v5/account/

WebSocket

Endpoint Description Status
GET /v5/

Documentation

Index

Constants

View Source
const (
	TESTNET_URL = "https://api-testnet.bybit.com"
	MAINNET_URL = "https://api.bybit.com"
)

Variables

This section is empty.

Functions

func Call

func Call(c *CallParams, a any)

func DeSerialize

func DeSerialize(data []byte) any

func GetEnv

func GetEnv(key string) string

func Recast

func Recast(a, b any) error

recast a to b

func Serialize

func Serialize(s any) []byte

func StringToBool

func StringToBool(value string) bool

func StringToFloat64

func StringToFloat64(value string) float64

func StringToInt32

func StringToInt32(value string) int32

func StringToInt64

func StringToInt64(value string) int64

Types

type CallParams

type CallParams struct {
	Method   string
	EndPoint string
	Params   interface{}
	Fields   []string
}

type Connector

type Connector struct {
	Params     interface{} //request params
	Required   []string    //required fields
	Url        string      //main, or test api url
	EndPoint   string      //api endpoint method
	ApiKey     string      //user api key
	ApiSecret  string      //user api secret
	RecvWindow string      //recvwindow= 5000 default
	Signature  string      //user signature
	// contains filtered or unexported fields
}

func NewConnector

func NewConnector() *Connector

func (*Connector) GetRequest

func (c *Connector) GetRequest() ([]byte, int)

func (*Connector) PostRequest

func (c *Connector) PostRequest() ([]byte, int)

func (*Connector) SetEndPoint

func (c *Connector) SetEndPoint(value string) *Connector

func (*Connector) SetKeys

func (c *Connector) SetKeys(key, secret string) *Connector

func (*Connector) SetParams

func (c *Connector) SetParams(p interface{}, required []string) *Connector

func (*Connector) SetUrl

func (c *Connector) SetUrl(mode string) *Connector

type Response

type Response struct {
	RetCode    int         `json:"retCode"`
	RetMsg     string      `json:"retMsg"`
	Result     interface{} `json:"result"`
	RetExtInfo interface{} `json:"retExtInfo"`
	Time       int         `json:"time"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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