Documentation ¶
Index ¶
- Constants
- type AccountEvent
- type ActionType
- type Balance
- type BookEvent
- type ChannelType
- type Exchange
- func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (errs error)
- func (e *Exchange) Name() types.ExchangeName
- func (e *Exchange) NewStream() types.Stream
- func (e *Exchange) PlatformFeeCurrency() string
- func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error)
- func (e *Exchange) QueryAccountBalances(ctx context.Context) (types.BalanceMap, error)
- func (e *Exchange) QueryClosedOrders(ctx context.Context, symbol string, since, until time.Time, lastOrderID uint64) (orders []types.Order, err error)
- func (e *Exchange) QueryKLines(ctx context.Context, symbol string, interval types.Interval, ...) ([]types.KLine, error)
- func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error)
- func (e *Exchange) QueryOpenOrders(ctx context.Context, symbol string) (orders []types.Order, err error)
- func (e *Exchange) QueryTicker(ctx context.Context, symbol string) (*types.Ticker, error)
- func (e *Exchange) QueryTickers(ctx context.Context, symbols ...string) (map[string]types.Ticker, error)
- func (e *Exchange) QueryTrades(ctx context.Context, symbol string, options *types.TradeQueryOptions) (trades []types.Trade, err error)
- func (e *Exchange) SubmitOrder(ctx context.Context, order types.SubmitOrder) (createdOrder *types.Order, err error)
- type InstType
- type KLine
- type KLineEvent
- type KLineSlice
- type LogFunction
- type MarketTrade
- type MarketTradeEvent
- type MarketTradeSlice
- type Order
- type OrderTradeEvent
- type SideType
- type Stream
- func (s *Stream) EmitAccountEvent(e AccountEvent)
- func (s *Stream) EmitBookEvent(o BookEvent)
- func (s *Stream) EmitKLineEvent(o KLineEvent)
- func (s *Stream) EmitMarketTradeEvent(o MarketTradeEvent)
- func (s *Stream) EmitOrderTradeEvent(e OrderTradeEvent)
- func (s *Stream) OnAccountEvent(cb func(e AccountEvent))
- func (s *Stream) OnBookEvent(cb func(o BookEvent))
- func (s *Stream) OnKLineEvent(cb func(o KLineEvent))
- func (s *Stream) OnMarketTradeEvent(cb func(o MarketTradeEvent))
- func (s *Stream) OnOrderTradeEvent(cb func(e OrderTradeEvent))
- func (s *Stream) SetPrivateChannelSymbols(symbols []string)
- func (s *Stream) Unsubscribe()
- type Trade
- type WsArg
- type WsEvent
- type WsEventType
- type WsOp
Constants ¶
const ( ID = "bitget" PlatformToken = "BGB" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountEvent ¶ added in v1.54.0
type AccountEvent struct { Balances []Balance // contains filtered or unexported fields }
type ActionType ¶ added in v1.53.0
type ActionType string
const ( ActionTypeSnapshot ActionType = "snapshot" ActionTypeUpdate ActionType = "update" )
type Balance ¶ added in v1.54.0
type Balance struct { Coin string `json:"coin"` Available fixedpoint.Value `json:"available"` // Amount of frozen assets Usually frozen when the order is placed Frozen fixedpoint.Value `json:"frozen"` // Amount of locked assets Locked assests required to become a fiat merchants, etc. Locked fixedpoint.Value `json:"locked"` // Restricted availability For spot copy trading LimitAvailable fixedpoint.Value `json:"limitAvailable"` UpdatedTime types.MillisecondTimestamp `json:"uTime"` }
type BookEvent ¶ added in v1.53.0
type BookEvent struct { Events []struct { // Order book on sell side, ascending order Asks types.PriceVolumeSlice `json:"asks"` // Order book on buy side, descending order Bids types.PriceVolumeSlice `json:"bids"` Ts types.MillisecondTimestamp `json:"ts"` Checksum int `json:"checksum"` } // contains filtered or unexported fields }
{ "asks":[ [ "28350.78", "0.2082" ], ], "bids":[ [ "28350.70", "0.5585" ], ], "checksum":0, "ts":"1697593934630" }
func (*BookEvent) ToGlobalOrderBooks ¶ added in v1.53.0
func (e *BookEvent) ToGlobalOrderBooks() []types.SliceOrderBook
type ChannelType ¶ added in v1.53.0
type ChannelType string
const ( ChannelAccount ChannelType = "account" // ChannelOrderBook snapshot and update might return less than 200 bids/asks as per symbol's orderbook various from // each other; The number of bids/asks is not a fixed value and may vary in the future ChannelOrderBook ChannelType = "books" // ChannelOrderBook5 top 5 order book of "books" that begins from bid1/ask1 ChannelOrderBook5 ChannelType = "books5" // ChannelOrderBook15 top 15 order book of "books" that begins from bid1/ask1 ChannelOrderBook15 ChannelType = "books15" ChannelTrade ChannelType = "trade" ChannelOrders ChannelType = "orders" )
type Exchange ¶
type Exchange struct {
// contains filtered or unexported fields
}
func (*Exchange) CancelOrders ¶ added in v1.53.0
func (*Exchange) Name ¶
func (e *Exchange) Name() types.ExchangeName
func (*Exchange) PlatformFeeCurrency ¶
func (*Exchange) QueryAccount ¶ added in v1.53.0
func (*Exchange) QueryAccountBalances ¶ added in v1.53.0
func (*Exchange) QueryClosedOrders ¶ added in v1.53.0
func (e *Exchange) QueryClosedOrders( ctx context.Context, symbol string, since, until time.Time, lastOrderID uint64, ) (orders []types.Order, err error)
QueryClosedOrders queries closed order by time range(`CreatedTime`) and id. The order of the response is in descending order. If you need to retrieve all data, please utilize the function pkg/exchange/batch.ClosedOrderBatchQuery.
REMARK: If your start time is 90 days earlier, we will update it to now - 90 days. ** Since is inclusive, Until is exclusive. If you use a time range to query, you must provide both a start time and an end time. ** ** Since and Until cannot exceed 90 days. ** ** Since from the last 90 days can be queried **
func (*Exchange) QueryKLines ¶ added in v1.53.0
func (e *Exchange) QueryKLines( ctx context.Context, symbol string, interval types.Interval, options types.KLineQueryOptions, ) ([]types.KLine, error)
QueryKLines queries the k line data by interval and time range...etc.
If you provide only the start time, the system will return the latest data. If you provide both the start and end times, the system will return data within the specified range. If you provide only the end time, the system will return data that occurred before the end time.
The end time has different limits. 1m, 5m can query for one month,15m can query for 52 days,30m can query for 62 days, 1H can query for 83 days,4H can query for 240 days,6H can query for 360 days.
func (*Exchange) QueryMarkets ¶ added in v1.53.0
func (*Exchange) QueryOpenOrders ¶ added in v1.53.0
func (*Exchange) QueryTicker ¶ added in v1.53.0
func (*Exchange) QueryTickers ¶ added in v1.53.0
func (*Exchange) QueryTrades ¶ added in v1.54.0
func (e *Exchange) QueryTrades( ctx context.Context, symbol string, options *types.TradeQueryOptions, ) (trades []types.Trade, err error)
QueryTrades queries fill trades. The trade of the response is in descending order. The time-based query are typically using (`CreatedTime`) as the search criteria. If you need to retrieve all data, please utilize the function pkg/exchange/batch.TradeBatchQuery.
REMARK: If your start time is 90 days earlier, we will update it to now - 90 days. ** StartTime is inclusive, EndTime is exclusive. If you use the EndTime, the StartTime is required. ** ** StartTime and EndTime cannot exceed 90 days. **
func (*Exchange) SubmitOrder ¶ added in v1.53.0
func (e *Exchange) SubmitOrder(ctx context.Context, order types.SubmitOrder) (createdOrder *types.Order, err error)
SubmitOrder submits an order.
Remark: 1. We support only GTC for time-in-force, because the response from queryOrder does not include time-in-force information. 2. For market buy orders, the size unit is quote currency, whereas the unit for order.Quantity is in base currency. Therefore, we need to calculate the equivalent quote currency amount based on the ticker data.
Note that there is a bug in Bitget where you can place a market order with the 'post_only' option successfully, which should not be possible. The issue has been reported.
type KLine ¶ added in v1.53.0
type KLine struct { StartTime types.MillisecondTimestamp OpenPrice fixedpoint.Value HighestPrice fixedpoint.Value LowestPrice fixedpoint.Value ClosePrice fixedpoint.Value Volume fixedpoint.Value }
type KLineEvent ¶ added in v1.53.0
type KLineEvent struct { Events KLineSlice // contains filtered or unexported fields }
func (KLineEvent) CacheKey ¶ added in v1.53.0
func (k KLineEvent) CacheKey() string
type KLineSlice ¶ added in v1.53.0
type KLineSlice []KLine
func (*KLineSlice) UnmarshalJSON ¶ added in v1.53.0
func (m *KLineSlice) UnmarshalJSON(b []byte) error
type LogFunction ¶ added in v1.55.0
type LogFunction func(msg string, args ...interface{})
type MarketTrade ¶ added in v1.53.0
type MarketTrade struct { Ts types.MillisecondTimestamp Price fixedpoint.Value Size fixedpoint.Value Side SideType }
type MarketTradeEvent ¶ added in v1.53.0
type MarketTradeEvent struct { Events MarketTradeSlice // contains filtered or unexported fields }
type MarketTradeSlice ¶ added in v1.53.0
type MarketTradeSlice []MarketTrade
func (*MarketTradeSlice) UnmarshalJSON ¶ added in v1.53.0
func (m *MarketTradeSlice) UnmarshalJSON(b []byte) error
type Order ¶ added in v1.54.0
type Order struct { Trade InstId string `json:"instId"` // OrderId are always numeric. It's confirmed with official customer service. https://t.me/bitgetOpenapi/24172 OrderId types.StrInt64 `json:"orderId"` ClientOrderId string `json:"clientOid"` // Size is base coin when orderType=limit; quote coin when orderType=market Size fixedpoint.Value `json:"size"` // Buy amount, returned when buying at market price Notional fixedpoint.Value `json:"notional"` OrderType v2.OrderType `json:"orderType"` Force v2.OrderForce `json:"force"` Side v2.SideType `json:"side"` AccBaseVolume fixedpoint.Value `json:"accBaseVolume"` PriceAvg fixedpoint.Value `json:"priceAvg"` // The Price field is only applicable to limit orders. Price fixedpoint.Value `json:"price"` Status v2.OrderStatus `json:"status"` CreatedTime types.MillisecondTimestamp `json:"cTime"` UpdatedTime types.MillisecondTimestamp `json:"uTime"` FeeDetail []struct { FeeCoin string `json:"feeCoin"` Fee string `json:"fee"` } `json:"feeDetail"` EnterPointSource string `json:"enterPointSource"` }
type OrderTradeEvent ¶ added in v1.54.0
type OrderTradeEvent struct { Orders []Order // contains filtered or unexported fields }
type Stream ¶ added in v1.53.0
type Stream struct { types.StandardStream KLineEventCallbacks []func(o KLineEvent) // contains filtered or unexported fields }
func (*Stream) EmitAccountEvent ¶ added in v1.54.0
func (s *Stream) EmitAccountEvent(e AccountEvent)
func (*Stream) EmitBookEvent ¶ added in v1.53.0
func (*Stream) EmitKLineEvent ¶ added in v1.53.0
func (s *Stream) EmitKLineEvent(o KLineEvent)
func (*Stream) EmitMarketTradeEvent ¶ added in v1.53.0
func (s *Stream) EmitMarketTradeEvent(o MarketTradeEvent)
func (*Stream) EmitOrderTradeEvent ¶ added in v1.54.0
func (s *Stream) EmitOrderTradeEvent(e OrderTradeEvent)
func (*Stream) OnAccountEvent ¶ added in v1.54.0
func (s *Stream) OnAccountEvent(cb func(e AccountEvent))
func (*Stream) OnBookEvent ¶ added in v1.53.0
func (*Stream) OnKLineEvent ¶ added in v1.53.0
func (s *Stream) OnKLineEvent(cb func(o KLineEvent))
func (*Stream) OnMarketTradeEvent ¶ added in v1.53.0
func (s *Stream) OnMarketTradeEvent(cb func(o MarketTradeEvent))
func (*Stream) OnOrderTradeEvent ¶ added in v1.54.0
func (s *Stream) OnOrderTradeEvent(cb func(e OrderTradeEvent))
func (*Stream) SetPrivateChannelSymbols ¶ added in v1.54.0
func (*Stream) Unsubscribe ¶ added in v1.53.0
func (s *Stream) Unsubscribe()
type Trade ¶ added in v1.54.0
type Trade struct { // Latest filled price FillPrice fixedpoint.Value `json:"fillPrice"` TradeId types.StrInt64 `json:"tradeId"` // Number of latest filled orders BaseVolume fixedpoint.Value `json:"baseVolume"` FillTime types.MillisecondTimestamp `json:"fillTime"` // Transaction fee of the latest transaction, negative value FillFee fixedpoint.Value `json:"fillFee"` // Currency of transaction fee of the latest transaction FillFeeCoin string `json:"fillFeeCoin"` // Direction of liquidity of the latest transaction TradeScope string `json:"tradeScope"` }
type WsArg ¶ added in v1.53.0
type WsArg struct { InstType InstType `json:"instType"` Channel ChannelType `json:"channel"` // InstId Instrument ID. e.q. BTCUSDT, ETHUSDT InstId string `json:"instId"` Coin string `json:"coin"` ApiKey string `json:"apiKey"` Passphrase string `json:"passphrase"` Timestamp string `json:"timestamp"` Sign string `json:"sign"` }
type WsEvent ¶ added in v1.53.0
type WsEvent struct { // for comment event Arg WsArg `json:"arg"` // for op event Event WsEventType `json:"event"` Code int `json:"code"` Msg string `json:"msg"` Op string `json:"op"` // for data event Action ActionType `json:"action"` Data json.RawMessage `json:"data"` }
WsEvent is the lowest level of event type. We use this struct to convert the received data, so that we will know whether the event belongs to `op` or `data`.
func (*WsEvent) IsAuthenticated ¶ added in v1.54.0
type WsEventType ¶ added in v1.53.0
type WsEventType string
const ( WsEventSubscribe WsEventType = "subscribe" WsEventUnsubscribe WsEventType = "unsubscribe" WsEventLogin WsEventType = "login" WsEventError WsEventType = "error" )
type WsOp ¶ added in v1.53.0
type WsOp struct { Op WsEventType `json:"op"` Args []WsArg `json:"args"` }