rest

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	Equity           float64 `json:"equity"`
	AvailableBalance float64 `json:"available_balance"`
	UsedMargin       float64 `json:"used_margin"`
	OrderMargin      float64 `json:"order_margin"`
	PositionMargin   float64 `json:"position_margin"`
	OccClosingFee    float64 `json:"occ_closing_fee"`
	OccFundingFee    float64 `json:"occ_funding_fee"`
	WalletBalance    float64 `json:"wallet_balance"`
	RealisedPnl      float64 `json:"realised_pnl"`
	UnrealisedPnl    float64 `json:"unrealised_pnl"`
	CumRealisedPnl   float64 `json:"cum_realised_pnl"`
	GivenCash        float64 `json:"given_cash"`
	ServiceCash      float64 `json:"service_cash"`
}

type BaseResult

type BaseResult struct {
	RetCode         int         `json:"ret_code"`
	RetMsg          string      `json:"ret_msg"`
	ExtCode         string      `json:"ext_code"`
	Result          interface{} `json:"result"`
	TimeNow         string      `json:"time_now"`
	RateLimitStatus int         `json:"rate_limit_status"`
}

type ByBit

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

func New

func New(httpClient *http.Client, baseURL string, apiKey string, secretKey string, debugMode bool) *ByBit

func (*ByBit) CancelAllOrder

func (b *ByBit) CancelAllOrder(symbol string) (result []string, err error)

CancelAllOrder Cancel All Active Orders on Linear API return list of cancelled order ids

func (*ByBit) CancelAllOrderV2 added in v0.4.0

func (b *ByBit) CancelAllOrderV2(symbol string) (result []OrderV2, err error)

CancelAllOrderV2 Cancel All Active Orders

func (*ByBit) CancelAllStopOrders

func (b *ByBit) CancelAllStopOrders(symbol string) (result []StopOrderV2, err error)

CancelAllStopOrders 撤消全部条件委托单 symbol:

func (*ByBit) CancelOrder

func (b *ByBit) CancelOrder(orderID string, symbol string) (result Order, err error)

CancelOrder 撤销活动委托单 orderID: 活动委托单ID, 数据来自创建活动委托单返回的订单唯一ID symbol:

func (*ByBit) CancelOrderV2

func (b *ByBit) CancelOrderV2(orderID string, orderLinkID string, symbol string) (result OrderV2, err error)

CancelOrder 撤销活动委托单 orderID: 活动委托单ID, 数据来自创建活动委托单返回的订单唯一ID symbol:

func (*ByBit) CancelStopOrder

func (b *ByBit) CancelStopOrder(orderID string, symbol string) (result Order, err error)

CancelStopOrder 撤销活动条件委托单 orderID: 活动条件委托单ID, 数据来自创建活动委托单返回的订单唯一ID symbol:

func (*ByBit) CreateOrder

func (b *ByBit) CreateOrder(side string, orderType string, price float64, qty int, timeInForce string, reduceOnly bool, symbol string) (result Order, err error)

CreateOrder 创建委托单 symbol: 产品类型, 有效选项:BTCUSD,ETHUSD (BTCUSD ETHUSD) side: 方向, 有效选项:Buy, Sell (Buy Sell) orderType: Limit/Market price: 委托价格, 在没有仓位时,做多的委托价格需高于市价的10%、低于1百万。如有仓位时则需优于强平价。单笔价格增减最小单位为0.5。 qty: 委托数量, 单笔最大1百万 timeInForce: 执行策略, 有效选项:GoodTillCancel,ImmediateOrCancel,FillOrKill,PostOnly reduceOnly: 只减仓 symbol: 产品类型, 有效选项:BTCUSD,ETHUSD (BTCUSD ETHUSD)

func (*ByBit) CreateOrderLinear

func (b *ByBit) CreateOrderLinear(side string, orderType string, price float64,
	qty float64, timeInForce string, takeProfit float64, stopLoss float64, reduceOnly bool,
	closeOnTrigger bool, orderLinkID string, symbol string) (result OrderV2, err error)

func (*ByBit) CreateOrderV2

func (b *ByBit) CreateOrderV2(side string, orderType string, price float64,
	qty float64, timeInForce string, takeProfit float64, stopLoss float64, reduceOnly bool,
	closeOnTrigger bool, orderLinkID string, symbol string) (result OrderV2, err error)

func (*ByBit) CreateStopOrder

func (b *ByBit) CreateStopOrder(side string, orderType string, price float64, basePrice float64, stopPx float64,
	qty int, triggerBy string, timeInForce string, reduceOnly bool, symbol string) (result Order, err error)

CreateStopOrder 创建条件委托单 https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/zh_cn/rest_api.md#open-apistop-ordercreatepost symbol: 产品类型, 有效选项:BTCUSD,ETHUSD (BTCUSD ETHUSD) side: 方向, 有效选项:Buy, Sell (Buy Sell) orderType: Limit/Market price: 委托价格, 在没有仓位时,做多的委托价格需高于市价的10%、低于1百万。如有仓位时则需优于强平价。单笔价格增减最小单位为0.5。 qty: 委托数量, 单笔最大1百万 basePrice: 当前市价。用于和stop_px值进行比较,确定当前条件委托是看空到stop_px时触发还是看多到stop_px触发。主要是用来标识当前条件单预期的方向 stopPx: 条件委托下单时市价 triggerBy: 触发价格类型. 默认为上一笔成交价格 timeInForce: 执行策略, 有效选项:GoodTillCancel,ImmediateOrCancel,FillOrKill,PostOnly reduceOnly: 只减仓 symbol: 产品类型, 有效选项:BTCUSD,ETHUSD (BTCUSD ETHUSD)

func (*ByBit) GetKLine

func (b *ByBit) GetKLine(symbol string, interval string, from int64, limit int) (result []OHLC, err error)

GetKLine https://bybit-exchange.github.io/docs/inverse/#t-httprequest-2 interval: 1 3 5 15 30 60 120 240 360 720 "D" "M" "W" "Y" from: From timestamp in seconds limit: Limit for data size per page, max size is 200. Default as showing 200 pieces of data per page

func (*ByBit) GetKLine2

func (b *ByBit) GetKLine2(symbol string, interval string, from int64, limit int) (result []OHLC2, err error)

GetKLine2 (USDT永续) https://bybit-exchange.github.io/docs/zh-cn/linear/#t-querykline interval: 1 3 5 15 30 60 120 240 360 720 "D" "M" "W" "Y" from: From timestamp in seconds limit: Limit for data size per page, max size is 200. Default as showing 200 pieces of data per page

func (*ByBit) GetLeverages

func (b *ByBit) GetLeverages() (result map[string]LeverageItem, err error)

GetLeverages 获取用户杠杆

func (*ByBit) GetLinearPosition

func (b *ByBit) GetLinearPosition(symbol string) (longPosition Position, shortPosition Position, err error)

GetLinearPosition get the buy and sell positions for a linear asset (eg: BTCUSDT)

func (*ByBit) GetLinearPositions

func (b *ByBit) GetLinearPositions() (result []Position, err error)

GetLinearPositions get linear positions (eg: BTCUSDT)

func (*ByBit) GetOrderBook

func (b *ByBit) GetOrderBook(symbol string) (result OrderBook, err error)

GetOrderBook Get the orderbook 正反向合约通用

func (*ByBit) GetOrderLinear added in v0.5.0

func (b *ByBit) GetOrderLinear(orderID string, orderLinkID string, symbol string) (result Order, err error)

func (*ByBit) GetOrderV2 added in v0.3.0

func (b *ByBit) GetOrderV2(orderID string, orderLinkID string, symbol string) (*OrderV2, error)

GetOrderV2 returns a specific order

func (*ByBit) GetOrdersLinear added in v0.6.0

func (b *ByBit) GetOrdersLinear(symbol string) (result []Order, err error)

func (*ByBit) GetOrdersV2

func (b *ByBit) GetOrdersV2(symbol string) (result []OrderV2, err error)

GetOrdersV2 returns up to 500 active limit orders, without lag (real-time)

func (*ByBit) GetPosition

func (b *ByBit) GetPosition(symbol string) (result Position, err error)

GetPosition get an inverse perpetual swap position (eg: BTCUSD)

func (*ByBit) GetPositions

func (b *ByBit) GetPositions() (result []Position, err error)

GetPositions get inverse perpetual swap positions (eg: BTCUSD)

func (*ByBit) GetServerTime

func (b *ByBit) GetServerTime() (timeNow int64, err error)

GetServerTime Get server time.

func (*ByBit) GetStopOrders

func (b *ByBit) GetStopOrders(orderID string, orderLinkID string, stopOrderStatus string, order string,
	page int, limit int, symbol string) (result GetStopOrdersResult, err error)

GetStopOrders 查询条件委托单 orderID: 条件委托单ID orderLinkID: 机构自定义订单ID order: 排序字段为created_at,升序降序,默认降序 (desc asc ) page: 页码,默认取第一页数据 stopOrderStatus 条件单状态: Untriggered: 等待市价触发条件单; Triggered: 市价已触发条件单; Cancelled: 取消; Active: 条件单触发成功且下单成功; Rejected: 条件触发成功但下单失败 limit: 一页数量,默认一页展示20条数据;最大支持50条每页

func (*ByBit) GetStopOrdersV2

func (b *ByBit) GetStopOrdersV2(orderID string, orderLinkID string, symbol string) (result []StopOrderV2, err error)

GetOrdersV2 returns up to 50 active conditional orders, without lag (real-time)

func (*ByBit) GetSymbols

func (b *ByBit) GetSymbols() (result []SymbolInfo, err error)

func (*ByBit) GetTicker added in v0.1.1

func (b *ByBit) GetTicker(symbol string) (result []Ticker, err error)

GetTickers retrieves a single inverse or linear swap ticker

func (*ByBit) GetTickers

func (b *ByBit) GetTickers() (result []Ticker, err error)

GetTickers retrieves both inverse and linear swap tickers

func (*ByBit) GetTradingRecords

func (b *ByBit) GetTradingRecords(symbol string, from int64, limit int) (result []TradingRecord, err error)

from: From ID. Default: return latest data limit: Number of results. Default 500; max 1000

func (*ByBit) GetWalletBalance

func (b *ByBit) GetWalletBalance(coin string) (result Balance, err error)

GetBalance Get Wallet Balance coin: BTC,EOS,XRP,ETH,USDT

func (*ByBit) PublicRequest

func (b *ByBit) PublicRequest(method string, apiURL string, params map[string]interface{}, result interface{}) (resp []byte, err error)

func (*ByBit) ReplaceOrder

func (b *ByBit) ReplaceOrder(symbol string, orderID string, orderLinkId string, qty float64, takeProfit float64, stopLoss float64, price float64) (result Order, err error)

func (*ByBit) ReplaceOrderV2 added in v0.4.0

func (b *ByBit) ReplaceOrderV2(symbol string, orderID string, qty float64, price float64) (result Order, err error)

func (*ByBit) SetCorrectServerTime

func (b *ByBit) SetCorrectServerTime() (err error)

SetCorrectServerTime 校正服务器时间

func (*ByBit) SetLeverage

func (b *ByBit) SetLeverage(leverage int, symbol string) (err error)

SetLeverage 设置杠杆

func (*ByBit) SignedRequest

func (b *ByBit) SignedRequest(method string, apiURL string, params map[string]interface{}, result interface{}) (resp []byte, err error)

type CancelAllOrderResult added in v0.4.0

type CancelAllOrderResult struct {
	RetCode          int      `json:"ret_code"`
	RetMsg           string   `json:"ret_msg"`
	ExtCode          string   `json:"ext_code"`
	ExtInfo          string   `json:"ext_info"`
	Result           []string `json:"result"`
	TimeNow          string   `json:"time_now"`
	RateLimitStatus  int      `json:"rate_limit_status"`
	RateLimitResetMs int64    `json:"rate_limit_reset_ms"`
	RateLimit        int      `json:"rate_limit"`
}

type CancelAllOrderV2Result

type CancelAllOrderV2Result struct {
	RetCode          int       `json:"ret_code"`
	RetMsg           string    `json:"ret_msg"`
	ExtCode          string    `json:"ext_code"`
	ExtInfo          string    `json:"ext_info"`
	Result           []OrderV2 `json:"result"`
	TimeNow          string    `json:"time_now"`
	RateLimitStatus  int       `json:"rate_limit_status"`
	RateLimitResetMs int64     `json:"rate_limit_reset_ms"`
	RateLimit        int       `json:"rate_limit"`
}

type CancelOrderResult

type CancelOrderResult struct {
	RetCode         int    `json:"ret_code"`
	RetMsg          string `json:"ret_msg"`
	ExtCode         string `json:"ext_code"`
	Result          Order  `json:"result"`
	TimeNow         string `json:"time_now"`
	RateLimitStatus int    `json:"rate_limit_status"`
}

type CancelOrderV2Result

type CancelOrderV2Result struct {
	RetCode          int     `json:"ret_code"`
	RetMsg           string  `json:"ret_msg"`
	ExtCode          string  `json:"ext_code"`
	ExtInfo          string  `json:"ext_info"`
	Result           OrderV2 `json:"result"`
	TimeNow          string  `json:"time_now"`
	RateLimitStatus  int     `json:"rate_limit_status"`
	RateLimitResetMs int64   `json:"rate_limit_reset_ms"`
	RateLimit        int     `json:"rate_limit"`
}

type CancelStopOrdersV2Result

type CancelStopOrdersV2Result struct {
	RetCode          int           `json:"ret_code"`
	RetMsg           string        `json:"ret_msg"`
	ExtCode          string        `json:"ext_code"`
	ExtInfo          string        `json:"ext_info"`
	Result           []StopOrderV2 `json:"result"`
	TimeNow          string        `json:"time_now"`
	RateLimitStatus  int           `json:"rate_limit_status"`
	RateLimitResetMs int64         `json:"rate_limit_reset_ms"`
	RateLimit        int           `json:"rate_limit"`
}

type CreateOrderResult

type CreateOrderResult struct {
	RetCode         int    `json:"ret_code"`
	RetMsg          string `json:"ret_msg"`
	ExtCode         string `json:"ext_code"`
	Result          Order  `json:"result"`
	TimeNow         string `json:"time_now"`
	RateLimitStatus int    `json:"rate_limit_status"`
}

type CreateOrderV2Result

type CreateOrderV2Result struct {
	RetCode          int     `json:"ret_code"`
	RetMsg           string  `json:"ret_msg"`
	ExtCode          string  `json:"ext_code"`
	ExtInfo          string  `json:"ext_info"`
	Result           OrderV2 `json:"result"`
	TimeNow          string  `json:"time_now"`
	RateLimitStatus  int     `json:"rate_limit_status"`
	RateLimitResetMs int64   `json:"rate_limit_reset_ms"`
	RateLimit        int     `json:"rate_limit"`
}

type ExtFields

type ExtFields struct {
	ReduceOnly  bool   `json:"reduce_only"`
	OpFrom      string `json:"op_from"`
	Remark      string `json:"remark"`
	OReqNum     int64  `json:"o_req_num"`
	XreqType    string `json:"xreq_type"`
	CrossStatus string `json:"cross_status,omitempty"`
}

func (*ExtFields) MarshalJSON

func (e *ExtFields) MarshalJSON() ([]byte, error)

func (*ExtFields) UnmarshalJSON

func (e *ExtFields) UnmarshalJSON(b []byte) error

type GetBalanceResult

type GetBalanceResult struct {
	RetCode          int                  `json:"ret_code"`
	RetMsg           string               `json:"ret_msg"`
	ExtCode          string               `json:"ext_code"`
	ExtInfo          string               `json:"ext_info"`
	Result           GetBalanceResultData `json:"result"`
	TimeNow          string               `json:"time_now"`
	RateLimitStatus  int                  `json:"rate_limit_status"`
	RateLimitResetMs int64                `json:"rate_limit_reset_ms"`
	RateLimit        int                  `json:"rate_limit"`
}

type GetBalanceResultData

type GetBalanceResultData struct {
	BTC  Balance `json:"BTC"`
	ETH  Balance `json:"ETH"`
	EOS  Balance `json:"EOS"`
	XRP  Balance `json:"XRP"`
	USDT Balance `json:"USDT"`
}

type GetKlineResult

type GetKlineResult struct {
	RetCode int    `json:"ret_code"`
	RetMsg  string `json:"ret_msg"`
	ExtCode string `json:"ext_code"`
	ExtInfo string `json:"ext_info"`
	Result  []OHLC `json:"result"`
	TimeNow string `json:"time_now"`
}

type GetKlineResult2

type GetKlineResult2 struct {
	RetCode int     `json:"ret_code"`
	RetMsg  string  `json:"ret_msg"`
	ExtCode string  `json:"ext_code"`
	ExtInfo string  `json:"ext_info"`
	Result  []OHLC2 `json:"result"`
	TimeNow string  `json:"time_now"`
}

type GetLeverageResult

type GetLeverageResult struct {
	RetCode         int                     `json:"ret_code"`
	RetMsg          string                  `json:"ret_msg"`
	ExtCode         string                  `json:"ext_code"`
	Result          map[string]LeverageItem `json:"result"`
	TimeNow         string                  `json:"time_now"`
	RateLimitStatus int                     `json:"rate_limit_status"`
}

type GetOrderBookResult

type GetOrderBookResult struct {
	RetCode int       `json:"ret_code"`
	RetMsg  string    `json:"ret_msg"`
	ExtCode string    `json:"ext_code"`
	ExtInfo string    `json:"ext_info"`
	Result  []RawItem `json:"result"`
	TimeNow string    `json:"time_now"`
}

type GetPositionResult

type GetPositionResult struct {
	BaseResult
	ExtInfo interface{} `json:"ext_info"`
	Result  Position    `json:"result"`
}

type GetStopOrdersResult

type GetStopOrdersResult struct {
	RetCode          int                     `json:"ret_code"`
	RetMsg           string                  `json:"ret_msg"`
	ExtCode          string                  `json:"ext_code"`
	Result           GetStopOrdersResultData `json:"result"`
	ExtInfo          interface{}             `json:"ext_info"`
	TimeNow          string                  `json:"time_now"`
	RateLimitStatus  int                     `json:"rate_limit_status"`
	RateLimitResetMs int64                   `json:"rate_limit_reset_ms"`
	RateLimit        int                     `json:"rate_limit"`
}

type GetStopOrdersResultData

type GetStopOrdersResultData struct {
	CurrentPage int         `json:"current_page"`
	LastPage    int         `json:"last_page"`
	Data        []StopOrder `json:"data"`
}

type GetSymbolsResult

type GetSymbolsResult struct {
	RetCode int          `json:"ret_code"`
	RetMsg  string       `json:"ret_msg"`
	ExtCode string       `json:"ext_code"`
	ExtInfo string       `json:"ext_info"`
	Result  []SymbolInfo `json:"result"`
	TimeNow string       `json:"time_now"`
}

type GetTickersResult

type GetTickersResult struct {
	RetCode int      `json:"ret_code"`
	RetMsg  string   `json:"ret_msg"`
	ExtCode string   `json:"ext_code"`
	ExtInfo string   `json:"ext_info"`
	Result  []Ticker `json:"result"`
	TimeNow string   `json:"time_now"`
}

type GetTradingRecordsResult

type GetTradingRecordsResult struct {
	RetCode int             `json:"ret_code"`
	RetMsg  string          `json:"ret_msg"`
	ExtCode string          `json:"ext_code"`
	ExtInfo string          `json:"ext_info"`
	Result  []TradingRecord `json:"result"`
	TimeNow string          `json:"time_now"`
}

type InExtFields

type InExtFields struct {
	ReduceOnly  bool   `json:"reduce_only"`
	OpFrom      string `json:"op_from"`
	Remark      string `json:"remark"`
	OReqNum     int64  `json:"o_req_num"`
	XreqType    string `json:"xreq_type"`
	CrossStatus string `json:"cross_status,omitempty"`
}

type Item

type Item struct {
	Price float64 `json:"price,string"`
	Size  float64 `json:"size"`
}

type LeverageFilter

type LeverageFilter struct {
	MinLeverage  float64 `json:"min_leverage"`
	MaxLeverage  float64 `json:"max_leverage"`
	LeverageStep float64 `json:"leverage_step,string"`
}

type LeverageItem

type LeverageItem struct {
	Leverage float64 `json:"leverage"`
}

type LotSizeFilter

type LotSizeFilter struct {
	MaxTradingQty float64 `json:"max_trading_qty"`
	MinTradingQty float64 `json:"min_trading_qty"`
	QtyStep       float64 `json:"qty_step"`
}

type OHLC

type OHLC struct {
	Symbol   string  `json:"symbol"`
	Interval string  `json:"interval"`
	OpenTime int64   `json:"open_time"`
	Open     float64 `json:"open,string"`
	High     float64 `json:"high,string"`
	Low      float64 `json:"low,string"`
	Close    float64 `json:"close,string"`
	Volume   float64 `json:"volume,string"`
	Turnover float64 `json:"turnover,string"`
}

type OHLC2

type OHLC2 struct {
	ID       int64   `json:"id"`
	Symbol   string  `json:"symbol"`
	Period   string  `json:"period"`
	Interval string  `json:"interval"`
	StartAt  int64   `json:"start_at"`
	OpenTime int64   `json:"open_time"`
	Volume   float64 `json:"volume"`
	Open     float64 `json:"open"`
	High     float64 `json:"high"`
	Low      float64 `json:"low"`
	Close    float64 `json:"close"`
	Turnover float64 `json:"turnover"`
}

type Order

type Order struct {
	OrderID       string     `json:"order_id"`
	StopOrderID   string     `json:"stop_order_id"`
	UserID        int        `json:"user_id"`
	Symbol        string     `json:"symbol"`
	Side          string     `json:"side"`
	OrderType     string     `json:"order_type"`
	Price         float64    `json:"price"`
	Qty           float64    `json:"qty"`
	TimeInForce   string     `json:"time_in_force"`
	OrderStatus   string     `json:"order_status"`
	LastExecTime  string     `json:"last_exec_time"`
	LastExecPrice float64    `json:"last_exec_price"`
	LeavesQty     float64    `json:"leaves_qty"`
	CumExecQty    float64    `json:"cum_exec_qty"`
	CumExecValue  float64    `json:"cum_exec_value"`
	CumExecFee    float64    `json:"cum_exec_fee"`
	RejectReason  string     `json:"reject_reason"`
	OrderLinkID   string     `json:"order_link_id"`
	CreatedAt     time.Time  `json:"created_at"`
	UpdatedAt     time.Time  `json:"updated_at"`
	ExtFields     *ExtFields `json:"ext_fields,omitempty"`
}

Order ...

type OrderBook

type OrderBook struct {
	Asks []Item    `json:"asks"`
	Bids []Item    `json:"bids"`
	Time time.Time `json:"time"`
}

type OrderListResult

type OrderListResult struct {
	RetCode         int    `json:"ret_code"`
	RetMsg          string `json:"ret_msg"`
	ExtCode         string `json:"ext_code"`
	Result          Order  `json:"result"`
	TimeNow         string `json:"time_now"`
	RateLimitStatus int    `json:"rate_limit_status"`
}

type OrderListV2Result

type OrderListV2Result struct {
	RetCode         int       `json:"ret_code"`
	RetMsg          string    `json:"ret_msg"`
	ExtCode         string    `json:"ext_code"`
	Result          []OrderV2 `json:"result"`
	TimeNow         string    `json:"time_now"`
	RateLimitStatus int       `json:"rate_limit_status"`
}

type OrderLite

type OrderLite struct {
	OrderID string `json:"order_id"`
}

type OrderV2

type OrderV2 struct {
	UserID        int          `json:"user_id"`
	OrderID       string       `json:"order_id"`
	Symbol        string       `json:"symbol"`
	Side          string       `json:"side"`
	OrderType     string       `json:"order_type"`
	Price         sjson.Number `json:"price"`
	Qty           float64      `json:"qty"`
	TimeInForce   string       `json:"time_in_force"`
	OrderStatus   string       `json:"order_status"`
	LastExecTime  sjson.Number `json:"last_exec_time"`
	LastExecPrice sjson.Number `json:"last_exec_price"`
	LeavesQty     float64      `json:"leaves_qty"`
	CumExecQty    float64      `json:"cum_exec_qty"`
	CumExecValue  sjson.Number `json:"cum_exec_value"`
	CumExecFee    sjson.Number `json:"cum_exec_fee"`
	RejectReason  string       `json:"reject_reason"`
	OrderLinkID   string       `json:"order_link_id"`
	CreatedAt     time.Time    `json:"created_at"`
	UpdatedAt     time.Time    `json:"updated_at"`
}

type OrderV2Result added in v0.3.0

type OrderV2Result struct {
	RetCode         int     `json:"ret_code"`
	RetMsg          string  `json:"ret_msg"`
	ExtCode         string  `json:"ext_code"`
	Result          OrderV2 `json:"result"`
	TimeNow         string  `json:"time_now"`
	RateLimitStatus int     `json:"rate_limit_status"`
}

type OrdersListResult added in v0.6.0

type OrdersListResult struct {
	RetCode         int     `json:"ret_code"`
	RetMsg          string  `json:"ret_msg"`
	ExtCode         string  `json:"ext_code"`
	Result          []Order `json:"result"`
	TimeNow         string  `json:"time_now"`
	RateLimitStatus int     `json:"rate_limit_status"`
}

type Position

type Position struct {
	ID                  int                `json:"id"`
	UserID              int                `json:"user_id"`
	RiskID              int                `json:"risk_id"`
	Symbol              string             `json:"symbol"`
	Size                float64            `json:"size"`
	Side                string             `json:"side"`
	EntryPrice          float64            `json:"entry_price,string"`
	LiqPrice            float64            `json:"liq_price,string"`
	BustPrice           float64            `json:"bust_price,string"`
	TakeProfit          float64            `json:"take_profit,string"`
	StopLoss            float64            `json:"stop_loss,string"`
	TrailingStop        float64            `json:"trailing_stop,string"`
	PositionValue       float64            `json:"position_value,string"`
	Leverage            float64            `json:"leverage,string"`
	PositionStatus      string             `json:"position_status"`
	AutoAddMargin       float64            `json:"auto_add_margin"`
	OrderMargin         float64            `json:"order_margin,string"`
	PositionMargin      float64            `json:"position_margin,string"`
	OccClosingFee       float64            `json:"occ_closing_fee,string"`
	OccFundingFee       float64            `json:"occ_funding_fee,string"`
	ExtFields           *PositionExtFields `json:"ext_fields"`
	WalletBalance       float64            `json:"wallet_balance,string"`
	CumRealisedPnl      float64            `json:"cum_realised_pnl,string"`
	CumCommission       float64            `json:"cum_commission,string"`
	RealisedPnl         float64            `json:"realised_pnl,string"`
	DeleverageIndicator float64            `json:"deleverage_indicator"`
	OcCalcData          string             `json:"oc_calc_data"`
	CrossSeq            float64            `json:"cross_seq"`
	PositionSeq         float64            `json:"position_seq"`
	CreatedAt           time.Time          `json:"created_at"`
	UpdatedAt           time.Time          `json:"updated_at"`
	UnrealisedPnl       float64            `json:"unrealised_pnl"`
}

type PositionExtFields

type PositionExtFields struct {
	Remark string `json:"_remark"`
}

type PositionLinear

type PositionLinear struct {
	Result PositionV1 `json:"data"`
}

type PositionListLinearResult

type PositionListLinearResult struct {
	BaseResult
	ExtInfo interface{}      `json:"ext_info"`
	Result  []PositionLinear `json:"result"`
}

type PositionListResult

type PositionListResult struct {
	BaseResult
	ExtInfo interface{}  `json:"ext_info"`
	Result  []PositionV1 `json:"result"`
}

type PositionV1

type PositionV1 struct {
	ID                  int                `json:"id"`
	UserID              int                `json:"user_id"`
	RiskID              int                `json:"risk_id"`
	Symbol              string             `json:"symbol"`
	Size                float64            `json:"size"`
	Side                string             `json:"side"`
	EntryPrice          float64            `json:"entry_price"`
	LiqPrice            float64            `json:"liq_price"`
	BustPrice           float64            `json:"bust_price"`
	TakeProfit          float64            `json:"take_profit"`
	StopLoss            float64            `json:"stop_loss"`
	TrailingStop        float64            `json:"trailing_stop"`
	PositionValue       float64            `json:"position_value"`
	Leverage            float64            `json:"leverage"`
	PositionStatus      string             `json:"position_status"`
	AutoAddMargin       float64            `json:"auto_add_margin"`
	OrderMargin         float64            `json:"order_margin"`
	PositionMargin      float64            `json:"position_margin"`
	OccClosingFee       float64            `json:"occ_closing_fee"`
	OccFundingFee       float64            `json:"occ_funding_fee"`
	ExtFields           *PositionExtFields `json:"ext_fields"`
	WalletBalance       float64            `json:"wallet_balance"`
	CumRealisedPnl      float64            `json:"cum_realised_pnl"`
	CumCommission       float64            `json:"cum_commission"`
	RealisedPnl         float64            `json:"realised_pnl"`
	DeleverageIndicator float64            `json:"deleverage_indicator"`
	OcCalcData          string             `json:"oc_calc_data"`
	CrossSeq            float64            `json:"cross_seq"`
	PositionSeq         float64            `json:"position_seq"`
	CreatedAt           time.Time          `json:"created_at"`
	UpdatedAt           time.Time          `json:"updated_at"`
	UnrealisedPnl       float64            `json:"unrealised_pnl"`
}

type PriceFilter

type PriceFilter struct {
	MinPrice float64 `json:"min_price,string"`
	MaxPrice float64 `json:"max_price,string"`
	TickSize float64 `json:"tick_size,string"`
}

type QueryOrderResult

type QueryOrderResult struct {
	RetCode          int     `json:"ret_code"`
	RetMsg           string  `json:"ret_msg"`
	ExtCode          string  `json:"ext_code"`
	ExtInfo          string  `json:"ext_info"`
	Result           OrderV2 `json:"result"`
	TimeNow          string  `json:"time_now"`
	RateLimitStatus  int     `json:"rate_limit_status"`
	RateLimitResetMs int64   `json:"rate_limit_reset_ms"`
	RateLimit        int     `json:"rate_limit"`
}

type RawItem

type RawItem struct {
	Symbol string  `json:"symbol"`
	Price  float64 `json:"price,string"`
	Size   float64 `json:"size"`
	Side   string  `json:"side"` // Buy/Sell
}

type ReplaceOrderResult

type ReplaceOrderResult struct {
	RetCode         int       `json:"ret_code"`
	RetMsg          string    `json:"ret_msg"`
	ExtCode         string    `json:"ext_code"`
	Result          OrderLite `json:"result"`
	TimeNow         string    `json:"time_now"`
	RateLimitStatus int       `json:"rate_limit_status"`
}

type StopOrder

type StopOrder struct {
	UserID          int64     `json:"user_id"`
	StopOrderStatus string    `json:"stop_order_status"`
	Symbol          string    `json:"symbol"`
	Side            string    `json:"side"`
	OrderType       string    `json:"order_type"`
	Price           float64   `json:"price"`
	Qty             float64   `json:"qty"`
	TimeInForce     string    `json:"time_in_force"`
	StopOrderType   string    `json:"stop_order_type"`
	TriggerBy       string    `json:"trigger_by"`
	BasePrice       float64   `json:"base_price"`
	OrderLinkID     string    `json:"order_link_id"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	StopPx          float64   `json:"stop_px"`
	StopOrderID     string    `json:"stop_order_id"`
}

type StopOrderListV2Result

type StopOrderListV2Result struct {
	RetCode         int           `json:"ret_code"`
	RetMsg          string        `json:"ret_msg"`
	ExtCode         string        `json:"ext_code"`
	Result          []StopOrderV2 `json:"result"`
	TimeNow         string        `json:"time_now"`
	RateLimitStatus int           `json:"rate_limit_status"`
}

type StopOrderV2

type StopOrderV2 struct {
	OrderID           string       `json:"order_id"`
	OrderLinkID       string       `json:"order_link_id"`
	UserID            int64        `json:"user_id"`
	Symbol            string       `json:"symbol"`
	Side              string       `json:"side"`
	OrderType         string       `json:"order_type"`
	Price             sjson.Number `json:"price"`
	StopPrice         sjson.Number `json:"stop_px"`
	Qty               float64      `json:"qty"`
	TimeInForce       string       `json:"time_in_force"`
	CreateType        string       `json:"create_type"`
	CancelType        string       `json:"cancel_type"`
	OrderStatus       string       `json:"order_status"`
	LeavesQty         float64      `json:"leaves_qty"`
	LeavesValue       string       `json:"leaves_value"`
	CreatedAt         time.Time    `json:"created_at"`
	UpdatedAt         time.Time    `json:"updated_at"`
	CrossStatus       string       `json:"cross_status"`
	CrossSeq          float64      `json:"cross_seq"`
	StopOrderType     string       `json:"stop_order_type"`
	TriggerBy         string       `json:"trigger_by"`
	BasePrice         sjson.Number `json:"base_price"`
	ExpectedDirection string       `json:"expected_direction"`
}

type SymbolInfo

type SymbolInfo struct {
	Name           string         `json:"name"`
	BaseCurrency   string         `json:"base_currency"`
	QuoteCurrency  string         `json:"quote_currency"`
	PriceScale     float64        `json:"price_scale"`
	TakerFee       float64        `json:"taker_fee,string"`
	MakerFee       float64        `json:"maker_fee,string"`
	LeverageFilter LeverageFilter `json:"leverage_filter"`
	PriceFilter    PriceFilter    `json:"price_filter"`
	LotSizeFilter  LotSizeFilter  `json:"lot_size_filter"`
}

type Ticker

type Ticker struct {
	Symbol               string    `json:"symbol"`
	BidPrice             float64   `json:"bid_price,string"`
	AskPrice             float64   `json:"ask_price,string"`
	LastPrice            float64   `json:"last_price,string"`
	LastTickDirection    string    `json:"last_tick_direction"`
	PrevPrice24H         float64   `json:"prev_price_24h,string"`
	Price24HPcnt         float64   `json:"price_24h_pcnt,string"`
	HighPrice24H         float64   `json:"high_price_24h,string"`
	LowPrice24H          float64   `json:"low_price_24h,string"`
	PrevPrice1H          float64   `json:"prev_price_1h,string"`
	Price1HPcnt          float64   `json:"price_1h_pcnt,string"`
	MarkPrice            float64   `json:"mark_price,string"`
	IndexPrice           float64   `json:"index_price,string"`
	OpenInterest         float64   `json:"open_interest"`
	OpenValue            float64   `json:"open_value,string"`
	TotalTurnover        float64   `json:"total_turnover,string"`
	Turnover24H          float64   `json:"turnover_24h,string"`
	TotalVolume          float64   `json:"total_volume"`
	Volume24H            float64   `json:"volume_24h"`
	FundingRate          float64   `json:"funding_rate,string"`
	PredictedFundingRate float64   `json:"predicted_funding_rate,string"`
	NextFundingTime      time.Time `json:"next_funding_time"`
	CountdownHour        int       `json:"countdown_hour"`
}

type TradingRecord

type TradingRecord struct {
	ID     int       `json:"id"`
	Symbol string    `json:"symbol"`
	Price  float64   `json:"price"`
	Qty    float64   `json:"qty"`
	Side   string    `json:"side"`
	Time   time.Time `json:"time"`
}

Jump to

Keyboard shortcuts

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