trade

package
v0.1.39 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAmendOrderRequestToParams

func ConvertAmendOrderRequestToParams(req *AmendOrderRequest) client.Params

ConvertAmendOrderRequestToParams converts an AmendOrderRequest to a client.Params map.

func ConvertBatchAmendOrderRequestToParams

func ConvertBatchAmendOrderRequestToParams(req *BatchAmendOrderRequest) client.Params

func ConvertBatchCancelOrderRequestToParams

func ConvertBatchCancelOrderRequestToParams(req *BatchCancelOrderRequest) client.Params

ConvertBatchCancelOrderRequestToParams creates a Params representation for logging/debugging.

func ConvertBatchPlaceOrderRequestToParams

func ConvertBatchPlaceOrderRequestToParams(req *BatchPlaceOrderRequest) client.Params

func ConvertCancelAllOrdersRequestToParams

func ConvertCancelAllOrdersRequestToParams(req *CancelAllOrdersRequest) client.Params

func ConvertCancelOrderRequestToParams

func ConvertCancelOrderRequestToParams(req *CancelOrderRequest) client.Params

func ConvertGetOpenOrdersRequestToParams

func ConvertGetOpenOrdersRequestToParams(req *GetOpenOrdersRequest) client.Params

func ConvertGetOrderHistoryRequestToParams

func ConvertGetOrderHistoryRequestToParams(req *GetOrderHistoryRequest) client.Params

func ConvertGetTradeHistoryRequestToParams

func ConvertGetTradeHistoryRequestToParams(req *GetTradeHistoryRequest) client.Params

func ConvertPlaceOrderRequestToParams

func ConvertPlaceOrderRequestToParams(req *PlaceOrderRequest) client.Params

func NewDCPParams

func NewDCPParams(timeWindow int) client.Params

NewDCPParams creates a new Params map for setting the DCP time window.

Types

type APIResponse

type APIResponse struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
}

APIResponse represents a generic response from the Bybit API.

type AmendOrderRequest

type AmendOrderRequest struct {
	Category     string  `json:"category"`
	Symbol       string  `json:"symbol"`
	OrderId      *string `json:"orderId,omitempty"`
	OrderLinkId  *string `json:"orderLinkId,omitempty"`
	OrderIv      *string `json:"orderIv,omitempty"`
	TriggerPrice *string `json:"triggerPrice,omitempty"`
	Qty          *string `json:"qty,omitempty"`
	Price        *string `json:"price,omitempty"`
	TpslMode     *string `json:"tpslMode,omitempty"`
	TakeProfit   *string `json:"takeProfit,omitempty"`
	StopLoss     *string `json:"stopLoss,omitempty"`
	TpTriggerBy  *string `json:"tpTriggerBy,omitempty"`
	SlTriggerBy  *string `json:"slTriggerBy,omitempty"`
	TriggerBy    *string `json:"triggerBy,omitempty"`
	TpLimitPrice *string `json:"tpLimitPrice,omitempty"`
	SlLimitPrice *string `json:"slLimitPrice,omitempty"`
}

type AmendOrderResponse

type AmendOrderResponse struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
	Result  struct {
		OrderId     string `json:"orderId"`
		OrderLinkId string `json:"orderLinkId"`
	} `json:"result"`
	RetExtInfo struct{} `json:"retExtInfo"`
	Time       int64    `json:"time"`
}

type BatchAmendOrderRequest

type BatchAmendOrderRequest struct {
	Category string              `json:"category"`
	Request  []AmendOrderRequest `json:"request"`
}

type BatchAmendOrderResponse

type BatchAmendOrderResponse struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
	Result  struct {
		List []struct {
			Category    string `json:"category"`
			Symbol      string `json:"symbol"`
			OrderId     string `json:"orderId"`
			OrderLinkId string `json:"orderLinkId"`
		} `json:"list"`
	} `json:"result"`
	RetExtInfo struct {
		List []struct {
			Code int    `json:"code"`
			Msg  string `json:"msg"`
		} `json:"list"`
	} `json:"retExtInfo"`
	Time int64 `json:"time"`
}

type BatchCancelOrderRequest

type BatchCancelOrderRequest struct {
	Category string               `json:"category"`
	Request  []CancelOrderRequest `json:"request"`
}

type BatchCancelOrderResponse

type BatchCancelOrderResponse struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
	Result  struct {
		List []struct {
			Category    string `json:"category"`
			Symbol      string `json:"symbol"`
			OrderId     string `json:"orderId"`
			OrderLinkId string `json:"orderLinkId"`
		} `json:"list"`
	} `json:"result"`
	RetExtInfo struct {
		List []struct {
			Code int    `json:"code"`
			Msg  string `json:"msg"`
		} `json:"list"`
	} `json:"retExtInfo"`
	Time int64 `json:"time"`
}

type BatchPlaceOrderRequest

type BatchPlaceOrderRequest struct {
	Category string         `json:"category"`
	Request  []OrderRequest `json:"request"`
}

type BatchPlaceOrderResponse

type BatchPlaceOrderResponse struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
	Result  struct {
		List []struct {
			Category    string `json:"category"`
			Symbol      string `json:"symbol"`
			OrderId     string `json:"orderId"`
			OrderLinkId string `json:"orderLinkId"`
			CreateAt    string `json:"createAt"`
		} `json:"list"`
	} `json:"result"`
	RetExtInfo struct {
		List []struct {
			Code int    `json:"code"`
			Msg  string `json:"msg"`
		} `json:"list"`
	} `json:"retExtInfo"`
	Time int64 `json:"time"`
}

type BorrowQuotaResponse

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

Response struct for parsing the API response

type BorrowQuotaResult

type BorrowQuotaResult struct {
	Symbol             string `json:"symbol"`
	Side               string `json:"side"`
	MaxTradeQty        string `json:"maxTradeQty"`
	MaxTradeAmount     string `json:"maxTradeAmount"`
	SpotMaxTradeQty    string `json:"spotMaxTradeQty"`
	SpotMaxTradeAmount string `json:"spotMaxTradeAmount"`
	BorrowCoin         string `json:"borrowCoin"`
}

BorrowQuotaResult holds the specific data of interest from the response

type CancelAllOrdersRequest

type CancelAllOrdersRequest struct {
	Category      string  `json:"category"`
	Symbol        *string `json:"symbol,omitempty"`
	BaseCoin      *string `json:"baseCoin,omitempty"`
	SettleCoin    *string `json:"settleCoin,omitempty"`
	OrderFilter   *string `json:"orderFilter,omitempty"`
	StopOrderType *string `json:"stopOrderType,omitempty"`
}

type CancelAllOrdersResponse

type CancelAllOrdersResponse struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
	Result  struct {
		List []struct {
			OrderId     string `json:"orderId"`
			OrderLinkId string `json:"orderLinkId"`
		} `json:"list"`
		Success string `json:"success"`
	} `json:"result"`
	RetExtInfo struct{} `json:"retExtInfo"`
	Time       int64    `json:"time"`
}

type CancelOrderRequest

type CancelOrderRequest struct {
	Category    string  `json:"category"`
	Symbol      string  `json:"symbol"`
	OrderId     *string `json:"orderId,omitempty"`
	OrderLinkId *string `json:"orderLinkId,omitempty"`
	OrderFilter *string `json:"orderFilter,omitempty"` // Valid for spot only
}

type CancelOrderResponse

type CancelOrderResponse struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
	Result  struct {
		OrderId     string `json:"orderId"`
		OrderLinkId string `json:"orderLinkId"`
	} `json:"result"`
	RetExtInfo struct{} `json:"retExtInfo"`
	Time       int64    `json:"time"`
}

type GetOpenOrdersRequest

type GetOpenOrdersRequest struct {
	Category    string
	Symbol      *string
	BaseCoin    *string
	SettleCoin  *string
	OrderId     *string
	OrderLinkId *string
	OpenOnly    *int
	OrderFilter *string
	Limit       *int
	Cursor      *string
}

type GetOpenOrdersResponse

type GetOpenOrdersResponse struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
	Result  struct {
		List           []OrderDetails `json:"list"`
		NextPageCursor string         `json:"nextPageCursor"`
		Category       string         `json:"category"`
	} `json:"result"`
	RetExtInfo struct{} `json:"retExtInfo"`
	Time       int64    `json:"time"`
}

type GetOrderHistoryRequest

type GetOrderHistoryRequest struct {
	Category    string
	Symbol      *string
	BaseCoin    *string
	SettleCoin  *string
	OrderId     *string
	OrderLinkId *string
	OrderFilter *string
	OrderStatus *string
	StartTime   *int64
	EndTime     *int64
	Limit       *int
	Cursor      *string
}

type GetOrderHistoryResponse

type GetOrderHistoryResponse struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
	Result  struct {
		List           []OrderDetails `json:"list"`
		NextPageCursor string         `json:"nextPageCursor"`
		Category       string         `json:"category"`
	} `json:"result"`
	RetExtInfo struct{} `json:"retExtInfo"`
	Time       int64    `json:"time"`
}

type GetTradeHistoryRequest

type GetTradeHistoryRequest struct {
	Category    string
	Symbol      *string
	OrderId     *string
	OrderLinkId *string
	BaseCoin    *string
	StartTime   *int64
	EndTime     *int64
	ExecType    *string
	Limit       *int
	Cursor      *string
}

type GetTradeHistoryResponse

type GetTradeHistoryResponse struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
	Result  struct {
		List           []TradeDetails `json:"list"`
		NextPageCursor string         `json:"nextPageCursor"`
		Category       string         `json:"category"`
	} `json:"result"`
	RetExtInfo struct{} `json:"retExtInfo"`
	Time       int64    `json:"time"`
}

type OrderDetails

type OrderDetails struct {
	OrderId            string `json:"orderId"`
	OrderLinkId        string `json:"orderLinkId"`
	BlockTradeId       string `json:"blockTradeId"`
	Symbol             string `json:"symbol"`
	Price              string `json:"price"`
	Qty                string `json:"qty"`
	Side               string `json:"side"`
	IsLeverage         string `json:"isLeverage"`
	PositionIdx        int    `json:"positionIdx"`
	OrderStatus        string `json:"orderStatus"`
	CreateType         string `json:"createType"`
	CancelType         string `json:"cancelType"`
	RejectReason       string `json:"rejectReason"`
	AvgPrice           string `json:"avgPrice"`
	LeavesQty          string `json:"leavesQty"`
	LeavesValue        string `json:"leavesValue"`
	CumExecQty         string `json:"cumExecQty"`
	CumExecValue       string `json:"cumExecValue"`
	CumExecFee         string `json:"cumExecFee"`
	TimeInForce        string `json:"timeInForce"`
	OrderType          string `json:"orderType"`
	StopOrderType      string `json:"stopOrderType"`
	OrderIv            string `json:"orderIv"`
	MarketUnit         string `json:"marketUnit"`
	TriggerPrice       string `json:"triggerPrice"`
	TakeProfit         string `json:"takeProfit"`
	StopLoss           string `json:"stopLoss"`
	TpslMode           string `json:"tpslMode"`
	OcoTriggerType     string `json:"ocoTriggerType"`
	TpLimitPrice       string `json:"tpLimitPrice"`
	SlLimitPrice       string `json:"slLimitPrice"`
	TpTriggerBy        string `json:"tpTriggerBy"`
	SlTriggerBy        string `json:"slTriggerBy"`
	TriggerDirection   int    `json:"triggerDirection"`
	TriggerBy          string `json:"triggerBy"`
	LastPriceOnCreated string `json:"lastPriceOnCreated"`
	ReduceOnly         bool   `json:"reduceOnly"`
	CloseOnTrigger     bool   `json:"closeOnTrigger"`
	PlaceType          string `json:"placeType"`
	SmpType            string `json:"smpType"`
	SmpGroup           int    `json:"smpGroup"`
	SmpOrderId         string `json:"smpOrderId"`
	CreatedTime        string `json:"createdTime"`
	UpdatedTime        string `json:"updatedTime"`
}

type OrderRequest

type OrderRequest struct {
	Symbol           string  `json:"symbol"`
	Side             string  `json:"side"`
	OrderType        string  `json:"orderType"`
	Qty              string  `json:"qty"`
	Price            *string `json:"price,omitempty"`
	TriggerDirection *int    `json:"triggerDirection,omitempty"`
	TriggerPrice     *string `json:"triggerPrice,omitempty"`
	TriggerBy        *string `json:"triggerBy,omitempty"`
	OrderIv          *string `json:"orderIv,omitempty"`
	TimeInForce      *string `json:"timeInForce,omitempty"`
	PositionIdx      *int    `json:"positionIdx,omitempty"`
	OrderLinkId      *string `json:"orderLinkId,omitempty"`
	TakeProfit       *string `json:"takeProfit,omitempty"`
	StopLoss         *string `json:"stopLoss,omitempty"`
	TpTriggerBy      *string `json:"tpTriggerBy,omitempty"`
	SlTriggerBy      *string `json:"slTriggerBy,omitempty"`
	ReduceOnly       *bool   `json:"reduceOnly,omitempty"`
	CloseOnTrigger   *bool   `json:"closeOnTrigger,omitempty"`
	SmpType          *string `json:"smpType,omitempty"`
	Mmp              *bool   `json:"mmp,omitempty"`
	TpslMode         *string `json:"tpslMode,omitempty"`
	TpLimitPrice     *string `json:"tpLimitPrice,omitempty"`
	SlLimitPrice     *string `json:"slLimitPrice,omitempty"`
	TpOrderType      *string `json:"tpOrderType,omitempty"`
	SlOrderType      *string `json:"slOrderType,omitempty"`
}

type PlaceOrderRequest

type PlaceOrderRequest struct {
	Category         string  `json:"category"`
	Symbol           string  `json:"symbol"`
	IsLeverage       *int    `json:"isLeverage,omitempty"`
	Side             string  `json:"side"`
	OrderType        string  `json:"orderType"`
	Qty              string  `json:"qty"`
	Price            *string `json:"price,omitempty"`
	TriggerPrice     *string `json:"triggerPrice,omitempty"`
	TriggerDirection *int    `json:"triggerDirection,omitempty"`
	TriggerBy        *string `json:"triggerBy,omitempty"`
	OrderFilter      *string `json:"orderFilter,omitempty"`
	OrderIv          *string `json:"orderIv,omitempty"`
	TimeInForce      string  `json:"timeInForce"`
	PositionIdx      *int    `json:"positionIdx,omitempty"`
	OrderLinkId      string  `json:"orderLinkId"`
	TakeProfit       *string `json:"takeProfit,omitempty"`
	StopLoss         *string `json:"stopLoss,omitempty"`
	TpTriggerBy      *string `json:"tpTriggerBy,omitempty"`
	SlTriggerBy      *string `json:"slTriggerBy,omitempty"`
	ReduceOnly       *bool   `json:"reduceOnly,omitempty"`
	CloseOnTrigger   *bool   `json:"closeOnTrigger,omitempty"`
	SmpType          *string `json:"smpType,omitempty"`
	Mmp              *bool   `json:"mmp,omitempty"`
	TpslMode         *string `json:"tpslMode,omitempty"`
	TpLimitPrice     *string `json:"tpLimitPrice,omitempty"`
	SlLimitPrice     *string `json:"slLimitPrice,omitempty"`
	TpOrderType      *string `json:"tpOrderType,omitempty"`
	SlOrderType      *string `json:"slOrderType,omitempty"`
}

type PlaceOrderResponse

type PlaceOrderResponse struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
	Result  struct {
		OrderID     string `json:"orderId"`
		OrderLinkID string `json:"orderLinkId"`
	} `json:"result"`
	RetExtInfo struct {
	} `json:"retExtInfo"`
	Time int64 `json:"time"`
}

type SetDisconnectCancelAllRequest

type SetDisconnectCancelAllRequest struct {
	TimeWindow int `json:"timeWindow"`
}

SetDisconnectCancelAllRequest represents the request payload for setting DCP.

type Trade

type Trade interface {
	PlaceOrder(req *PlaceOrderRequest) (*PlaceOrderResponse, error)
	AmendOrder(req *AmendOrderRequest) (*AmendOrderResponse, error)
	CancelOrder(req *CancelOrderRequest) (*CancelOrderResponse, error)
	GetOpenOrders(req *GetOpenOrdersRequest) (*GetOpenOrdersResponse, error)
	CancelAllOrders(req *CancelAllOrdersRequest) (*CancelAllOrdersResponse, error)
	GetOrderHistory(req *GetOrderHistoryRequest) (*GetOrderHistoryResponse, error)
	GetTradeHistory(req *GetTradeHistoryRequest) (*GetTradeHistoryResponse, error)
	BatchPlaceOrder(req *BatchPlaceOrderRequest) (*BatchPlaceOrderResponse, error)
	GetBorrowQuotaSpot(symbol, side string) (*BorrowQuotaResponse, error)
}

func New

func New(c *client.Client) Trade

type TradeDetails

type TradeDetails struct {
	Symbol          string `json:"symbol"`
	OrderId         string `json:"orderId"`
	OrderLinkId     string `json:"orderLinkId"`
	Side            string `json:"side"`
	OrderPrice      string `json:"orderPrice"`
	OrderQty        string `json:"orderQty"`
	LeavesQty       string `json:"leavesQty"`
	CreateType      string `json:"createType"`
	OrderType       string `json:"orderType"`
	StopOrderType   string `json:"stopOrderType"`
	ExecFee         string `json:"execFee"`
	ExecId          string `json:"execId"`
	ExecPrice       string `json:"execPrice"`
	ExecQty         string `json:"execQty"`
	ExecType        string `json:"execType"`
	ExecValue       string `json:"execValue"`
	ExecTime        string `json:"execTime"`
	FeeCurrency     string `json:"feeCurrency"`
	IsMaker         bool   `json:"isMaker"`
	FeeRate         string `json:"feeRate"`
	TradeIv         string `json:"tradeIv"`
	MarkIv          string `json:"markIv"`
	MarkPrice       string `json:"markPrice"`
	IndexPrice      string `json:"indexPrice"`
	UnderlyingPrice string `json:"underlyingPrice"`
	BlockTradeId    string `json:"blockTradeId"`
	ClosedSize      string `json:"closedSize"`
	Seq             int64  `json:"seq"`
}

Jump to

Keyboard shortcuts

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