bitget

package
v1.53.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: AGPL-3.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ID = "bitget"

	PlatformToken = "BGB"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionType added in v1.53.0

type ActionType string
const (
	ActionTypeSnapshot ActionType = "snapshot"
	ActionTypeUpdate   ActionType = "update"
)

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 (
	// 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"
)

type Exchange

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

func New

func New(key, secret, passphrase string) *Exchange

func (*Exchange) CancelOrders added in v1.53.0

func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) error

func (*Exchange) Name

func (e *Exchange) Name() types.ExchangeName

func (*Exchange) NewStream added in v1.53.0

func (e *Exchange) NewStream() types.Stream

func (*Exchange) PlatformFeeCurrency

func (e *Exchange) PlatformFeeCurrency() string

func (*Exchange) QueryAccount added in v1.53.0

func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error)

func (*Exchange) QueryAccountBalances added in v1.53.0

func (e *Exchange) QueryAccountBalances(ctx context.Context) (types.BalanceMap, error)

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(`CTime`) 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.

** 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)

func (*Exchange) QueryMarkets added in v1.53.0

func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error)

func (*Exchange) QueryOpenOrders added in v1.53.0

func (e *Exchange) QueryOpenOrders(ctx context.Context, symbol string) (orders []types.Order, err error)

func (*Exchange) QueryTicker added in v1.53.0

func (e *Exchange) QueryTicker(ctx context.Context, symbol string) (*types.Ticker, error)

func (*Exchange) QueryTickers added in v1.53.0

func (e *Exchange) QueryTickers(ctx context.Context, symbols ...string) (map[string]types.Ticker, error)

func (*Exchange) SubmitOrder added in v1.53.0

func (e *Exchange) SubmitOrder(ctx context.Context, order types.SubmitOrder) (createdOrder *types.Order, err error)

type InstType added in v1.53.0

type InstType string

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
}

func (KLine) ToGlobal added in v1.53.0

func (k KLine) ToGlobal(interval types.Interval, symbol string) types.KLine

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 MarketTrade added in v1.53.0

type MarketTrade struct {
	Ts    types.MillisecondTimestamp
	Price fixedpoint.Value
	Size  fixedpoint.Value
	Side  SideType
}

func (MarketTrade) ToGlobal added in v1.53.0

func (m MarketTrade) ToGlobal(symbol string) (types.Trade, error)

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 SideType added in v1.53.0

type SideType string
const (
	SideBuy  SideType = "buy"
	SideSell SideType = "sell"
)

func (SideType) ToGlobal added in v1.53.0

func (s SideType) ToGlobal() (types.SideType, error)

type Stream added in v1.53.0

type Stream struct {
	types.StandardStream

	KLineEventCallbacks []func(o KLineEvent)
	// contains filtered or unexported fields
}

func NewStream added in v1.53.0

func NewStream() *Stream

func (*Stream) EmitBookEvent added in v1.53.0

func (s *Stream) EmitBookEvent(o BookEvent)

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) OnBookEvent added in v1.53.0

func (s *Stream) OnBookEvent(cb func(o BookEvent))

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) Unsubscribe added in v1.53.0

func (s *Stream) Unsubscribe()

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"`
}

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) IsOp added in v1.53.0

func (w *WsEvent) IsOp() bool

IsOp represents the data event will be empty

func (*WsEvent) IsValid added in v1.53.0

func (w *WsEvent) IsValid() error

type WsEventType added in v1.53.0

type WsEventType string
const (
	WsEventSubscribe   WsEventType = "subscribe"
	WsEventUnsubscribe WsEventType = "unsubscribe"
	WsEventError       WsEventType = "error"
)

type WsOp added in v1.53.0

type WsOp struct {
	Op   WsEventType `json:"op"`
	Args []WsArg     `json:"args"`
}

Directories

Path Synopsis
v2

Jump to

Keyboard shortcuts

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