trade

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/order/amend-order
	EndpointAmendOrder = "/v5/order/amend"
)
View Source
const (
	// https://bybit-exchange.github.io/docs/v5/order/cancel-order
	EndpointCancelOrder = "/v5/order/cancel"
)
View Source
const (
	// https://bybit-exchange.github.io/docs/v5/order/open-order
	EndpointOpenOrders = "/v5/order/realtime"
)
View Source
const (
	// https://bybit-exchange.github.io/docs/v5/order/create-order
	EndpointPlaceOrder = "/v5/order/create"
)

Variables

This section is empty.

Functions

func AmendOrderData

func AmendOrderData(connRest ConnectorRest, parm AmendOrderParam) ([]byte, error)

func CancelOrderData

func CancelOrderData(connRest ConnectorRest, parm CancelOrderParam) ([]byte, error)

func OpenOrdersData

func OpenOrdersData(connRest ConnectorRest, parm OpenOrdersParam) ([]byte, error)

func PlaceOrderData

func PlaceOrderData(connRest ConnectorRest, parm PlaceOrderParam) ([]byte, error)

Types

type AmendOrderParam

type AmendOrderParam struct {
	Category            CategoryType  `json:"category"`
	Symbol              string        `json:"symbol"`
	OrderId             string        `json:"orderId,omitempty"`      // optional
	OrderLinkId         string        `json:"orderLinkId,omitempty"`  // optional
	OrderIv             string        `json:"orderIv,omitempty"`      // optional
	TriggerPrice        string        `json:"triggerPrice,omitempty"` // optional
	Quantity            string        `json:"qty,omitempty"`          // optional
	Price               string        `json:"price,omitempty"`        // optional
	TakeProfit          string        `json:"takeProfit,omitempty"`   // optional
	StopLoss            string        `json:"stopLoss,omitempty"`     // optional
	TakeProfitTriggerBy TriggerByType `json:"tpTriggerBy,omitempty"`  // optional
	StopLossTriggerBy   TriggerByType `json:"slTriggerBy,omitempty"`  // optional
	TriggerBy           TriggerByType `json:"triggerBy,omitempty"`    // optional
	RecvWindow          int           `json:"-"`                      // optional
}

type AmendOrderResp

type AmendOrderResp struct {
	RetCode int    `json:"retCode"` // Success/Error code
	RetMsg  string `json:"retMsg"`  // Success/Error msg. OK, success, SUCCESS indicate a successful response
	Result  struct {
		OrderId     string `json:"orderId"`     // Order ID
		OrderLinkId string `json:"orderLinkId"` // User customised order 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 AmendOrder

func AmendOrder(connRest ConnectorRest, parm AmendOrderParam) (AmendOrderResp, error)

type CancelOrderParam

type CancelOrderParam struct {
	Category    CategoryType `json:"category"`              // Product type | Unified account: spot, linear, inverse, option | Normal account: spot, linear, inverse
	Symbol      string       `json:"symbol"`                // Symbol name
	OrderId     string       `json:"orderId,omitempty"`     // optional	Order ID. Either orderId or orderLinkId is required
	OrderLinkId string       `json:"orderLinkId,omitempty"` // optional	User customised order ID. Either orderId or orderLinkId is required
	OrderFilter string       `json:"orderFilter,omitempty"` // optional	Valid for spot only. Order,tpslOrder. If not passed, Order by default
	RecvWindow  int          `json:"-"`                     // optional
}

type CancelOrderResp

type CancelOrderResp struct {
	RetCode int    `json:"retCode"` // Success/Error code
	RetMsg  string `json:"retMsg"`  // Success/Error msg. OK, success, SUCCESS indicate a successful response
	Result  struct {
		OrderId     string `json:"orderId"`     // Order ID
		OrderLinkId string `json:"orderLinkId"` // User customised order 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 CancelOrder

func CancelOrder(connRest ConnectorRest, parm CancelOrderParam) (CancelOrderResp, error)

type OpenOrdersParam

type OpenOrdersParam struct {
	Category    CategoryType `structs:"category"`
	Symbol      string       `structs:"symbol,omitempty"`      // optional
	OrderId     string       `structs:"orderId,omitempty"`     // optional
	OrderLinkId string       `structs:"orderLinkId,omitempty"` // optional
	OpenOnly    int          `structs:"openOnly,omitempty"`    // optional
	OrderFilter string       `structs:"orderFilter,omitempty"` // optional
	Limit       int          `structs:"limit,omitempty"`       // optional
	Cursor      int          `structs:"cursor,omitempty"`      // optional
	RecvWindow  int          `structs:"-"`                     // optional
}

type OpenOrdersResp

type OpenOrdersResp struct {
	RetCode int    `json:"retCode"` // Success/Error code
	RetMsg  string `json:"retMsg"`  // Success/Error msg. OK, success, SUCCESS indicate a successful response
	Result  struct {
		NextPageCursor string `json:"nextPageCursor"` // Cursor. Used for pagination
		Category       string `json:"category"`       // Product type
		List           []struct {
			Symbol             string           `json:"symbol"`             // Symbol name
			OrderType          string           `json:"orderType"`          // Order type. Market,Limit
			OrderLinkID        string           `json:"orderLinkId"`        // User customised order ID
			BlockTradeId       string           `json:"blockTradeId"`       // Paradigm block trade ID. Normal spot is not supported
			OrderID            string           `json:"orderId"`            // Order ID
			CancelType         CancelType       `json:"cancelType"`         // Cancel type
			AvgPrice           string           `json:"avgPrice"`           // Average filled price. If unfilled, it is "0"
			StopOrderType      StopOrderType    `json:"stopOrderType"`      // Stop order type
			LastPriceOnCreated string           `json:"lastPriceOnCreated"` // Last price when place the order
			OrderStatus        OrderStatusType  `json:"orderStatus"`        // Order status
			TakeProfit         string           `json:"takeProfit"`         // Take profit price
			CumExecValue       string           `json:"cumExecValue"`       // Cumulative executed order value. Normal spot is not supported
			TriggerDirection   int              `json:"triggerDirection"`   // Trigger direction. 1: rise, 2: fall
			IsLeverage         string           `json:"isLeverage"`         // Whether to borrow. Unified spot only. 0: false, 1: true. . Normal spot is not supported, always 0
			RejectReason       RejectReasonType `json:"rejectReason"`       // Reject reason. Normal spot is not supported
			Price              string           `json:"price"`              // Order price
			OrderIv            string           `json:"orderIv"`            // Implied volatility
			TpTriggerBy        TriggerByType    `json:"tpTriggerBy"`        // The price type to trigger take profit
			PositionIdx        PositionIdxType  `json:"positionIdx"`        // Position index. Used to identify positions in different position modes.
			TimeInForce        TimeInForceType  `json:"timeInForce"`        // Time in force
			LeavesValue        string           `json:"leavesValue"`        // The estimated value not executed. Normal spot is not supported
			Side               string           `json:"side"`               // Side. Buy,Sell
			TriggerPrice       string           `json:"triggerPrice"`       // Trigger price. If stopOrderType=TrailingStop, it is activate price. Otherwise, it is trigger price
			CumExecFee         string           `json:"cumExecFee"`         // Cumulative executed trading fee. Normal spot is not supported
			LeavesQty          string           `json:"leavesQty"`          // The remaining qty not executed. Normal spot is not supported
			SlTriggerBy        TriggerByType    `json:"slTriggerBy"`        // The price type to trigger stop loss
			CloseOnTrigger     bool             `json:"closeOnTrigger"`     // Close on trigger
			CumExecQty         string           `json:"cumExecQty"`         // Cumulative executed order qty
			ReduceOnly         bool             `json:"reduceOnly"`         // Reduce only. true means reduce position size
			Qty                string           `json:"qty"`                // Order qty
			StopLoss           string           `json:"stopLoss"`           // Stop loss price
			TriggerBy          TriggerByType    `json:"triggerBy"`          // The price type of trigger price
			PlaceType          string           `json:"placeType"`          // Place type, option used. iv, price
			SmpType            SmpType          `json:"smpType"`            // SMP execution type
			SmpGroup           int              `json:"smpGroup"`           // Smp group ID. If the uid has no group, it is 0 by default
			SmpOrderID         string           `json:"smpOrderId"`         // The counterparty's orderID which triggers this SMP execution
			CreatedTime        string           `json:"createdTime"`        // Order created timestamp (ms)
			UpdatedTime        string           `json:"updatedTime"`        // Order updated 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 OpenOrders

func OpenOrders(connRest ConnectorRest, parm OpenOrdersParam) (OpenOrdersResp, error)

type PlaceOrderParam

type PlaceOrderParam struct {
	Category         CategoryType    `json:"category"`
	Symbol           string          `json:"symbol"`
	IsLeverage       int             `json:"isLeverage,omitempty"`       // optional
	Side             SideType        `json:"side"`                       // Buy, Sell
	OrderType        OrderType       `json:"orderType"`                  // Market, Limit
	Quantity         string          `json:"qty"`                        // Order quantity
	Price            string          `json:"price,omitempty"`            // optional
	TriggerDirection int             `json:"triggerDirection,omitempty"` // optional
	OrderFilter      string          `json:"orderFilter,omitempty"`      // optional
	TriggerPrice     string          `json:"triggerPrice,omitempty"`     // optional
	TriggerBy        TriggerByType   `json:"triggerBy,omitempty"`        // optional
	OrderIv          string          `json:"orderIv,omitempty"`          // optional
	TimeInForce      TimeInForceType `json:"timeInForce,omitempty"`      // optional
	PositionIdx      PositionIdxType `json:"positionIdx,omitempty"`      // optional
	OrderLinkId      string          `json:"orderLinkId,omitempty"`      // optional
	TakeProfit       string          `json:"takeProfit,omitempty"`       // optional
	StopLoss         string          `json:"stopLoss,omitempty"`         // optional
	TpTriggerBy      TriggerByType   `json:"tpTriggerBy,omitempty"`      // optional
	SlTriggerBy      TriggerByType   `json:"slTriggerBy,omitempty"`      // optional
	ReduceOnly       bool            `json:"reduce_only,omitempty"`      // optional
	CloseOnTrigger   bool            `json:"closeOnTrigger,omitempty"`   // optional
	SmpType          SmpType         `json:"smpType,omitempty"`          // SMP execution type
	MMP              bool            `json:"mmp,omitempty"`              // optional	Market maker protection. option only
	RecvWindow       int             `json:"-"`                          // optional
}

type PlaceOrderResp

type PlaceOrderResp struct {
	RetCode int    `json:"retCode"` // Success/Error code
	RetMsg  string `json:"retMsg"`  // Success/Error msg. OK, success, SUCCESS indicate a successful response
	Result  struct {
		OrderId     string `json:"orderId"`     // Order ID
		OrderLinkId string `json:"orderLinkId"` // User customised order 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 PlaceOrder

func PlaceOrder(connRest ConnectorRest, parm PlaceOrderParam) (PlaceOrderResp, error)

Jump to

Keyboard shortcuts

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