mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
all: add exchange field to types.Market
This commit is contained in:
parent
945c442b92
commit
4aca676b4d
|
@ -15,6 +15,7 @@ import (
|
|||
|
||||
func toGlobalMarket(symbol binance.Symbol) types.Market {
|
||||
market := types.Market{
|
||||
Exchange: types.ExchangeBinance,
|
||||
Symbol: symbol.Symbol,
|
||||
LocalSymbol: symbol.Symbol,
|
||||
PricePrecision: symbol.QuotePrecision,
|
||||
|
@ -59,6 +60,7 @@ func toGlobalMarket(symbol binance.Symbol) types.Market {
|
|||
// TODO: Cuz it returns types.Market as well, merge following to the above function
|
||||
func toGlobalFuturesMarket(symbol futures.Symbol) types.Market {
|
||||
market := types.Market{
|
||||
Exchange: types.ExchangeBinance,
|
||||
Symbol: symbol.Symbol,
|
||||
LocalSymbol: symbol.Symbol,
|
||||
PricePrecision: symbol.QuotePrecision,
|
||||
|
|
|
@ -30,6 +30,7 @@ func toGlobalMarket(s v2.Symbol) types.Market {
|
|||
}
|
||||
|
||||
return types.Market{
|
||||
Exchange: types.ExchangeBitget,
|
||||
Symbol: s.Symbol,
|
||||
LocalSymbol: s.Symbol,
|
||||
PricePrecision: s.PricePrecision.Int(),
|
||||
|
|
|
@ -78,6 +78,7 @@ func Test_toGlobalMarket(t *testing.T) {
|
|||
}
|
||||
|
||||
exp := types.Market{
|
||||
Exchange: types.ExchangeBitget,
|
||||
Symbol: inst.Symbol,
|
||||
LocalSymbol: inst.Symbol,
|
||||
PricePrecision: 2,
|
||||
|
|
|
@ -146,6 +146,7 @@ func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error) {
|
|||
symbol := toGlobalSymbol(m.ID)
|
||||
|
||||
market := types.Market{
|
||||
Exchange: types.ExchangeMax,
|
||||
Symbol: symbol,
|
||||
LocalSymbol: m.ID,
|
||||
PricePrecision: m.QuoteUnitPrecision,
|
||||
|
@ -372,7 +373,9 @@ func (e *Exchange) queryClosedOrdersByLastOrderID(
|
|||
return types.SortOrdersAscending(orders), nil
|
||||
}
|
||||
|
||||
func (e *Exchange) queryClosedOrdersByTime(ctx context.Context, symbol string, since, until time.Time, orderByType maxapi.OrderByType) (orders []types.Order, err error) {
|
||||
func (e *Exchange) queryClosedOrdersByTime(
|
||||
ctx context.Context, symbol string, since, until time.Time, orderByType maxapi.OrderByType,
|
||||
) (orders []types.Order, err error) {
|
||||
if err := e.closedOrderQueryLimiter.Wait(ctx); err != nil {
|
||||
return orders, err
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error) {
|
|||
for _, instrument := range instruments {
|
||||
symbol := toGlobalSymbol(instrument.InstrumentID)
|
||||
market := types.Market{
|
||||
Exchange: types.ExchangeOKEx,
|
||||
Symbol: symbol,
|
||||
LocalSymbol: instrument.InstrumentID,
|
||||
|
||||
|
@ -383,7 +384,9 @@ func (e *Exchange) NewStream() types.Stream {
|
|||
return NewStream(e.client, e)
|
||||
}
|
||||
|
||||
func (e *Exchange) QueryKLines(ctx context.Context, symbol string, interval types.Interval, options types.KLineQueryOptions) ([]types.KLine, error) {
|
||||
func (e *Exchange) QueryKLines(
|
||||
ctx context.Context, symbol string, interval types.Interval, options types.KLineQueryOptions,
|
||||
) ([]types.KLine, error) {
|
||||
if err := queryKLineLimiter.Wait(ctx); err != nil {
|
||||
return nil, fmt.Errorf("query k line rate limiter wait error: %w", err)
|
||||
}
|
||||
|
@ -477,7 +480,9 @@ If you want to query all orders within a large time range (e.g. total orders > 1
|
|||
|
||||
** since and until are inclusive, you can include the lastTradeId as well. **
|
||||
*/
|
||||
func (e *Exchange) QueryClosedOrders(ctx context.Context, symbol string, since, until time.Time, lastOrderID uint64) (orders []types.Order, err error) {
|
||||
func (e *Exchange) QueryClosedOrders(
|
||||
ctx context.Context, symbol string, since, until time.Time, lastOrderID uint64,
|
||||
) (orders []types.Order, err error) {
|
||||
if symbol == "" {
|
||||
return nil, ErrSymbolRequired
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import (
|
|||
)
|
||||
|
||||
type Market struct {
|
||||
Exchange ExchangeName `json:"exchange,omitempty"`
|
||||
|
||||
Symbol string `json:"symbol"`
|
||||
|
||||
// LocalSymbol is used for exchange's API (exchange package internal)
|
||||
|
|
Loading…
Reference in New Issue
Block a user