max: extend max exchange market information

This commit is contained in:
c9s 2020-10-14 10:53:18 +08:00
parent 6d00a7ba07
commit c58375f57e
3 changed files with 38 additions and 9 deletions

View File

@ -51,9 +51,6 @@ func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error) {
VolumePrecision: symbol.BaseAssetPrecision,
QuoteCurrency: symbol.QuoteAsset,
BaseCurrency: symbol.BaseAsset,
MinAmount: 0,
MinNotional: 0,
MinLot: 0,
}
if f := symbol.MinNotionalFilter() ; f != nil {

View File

@ -34,6 +34,36 @@ func (e *Exchange) Name() types.ExchangeName {
return types.ExchangeMax
}
func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error) {
remoteMarkets, err := e.client.PublicService.Markets()
if err != nil {
return nil, err
}
markets := types.MarketMap{}
for _, m := range remoteMarkets {
market := types.Market{
Symbol: toGlobalSymbol(m.ID),
PricePrecision: m.QuoteUnitPrecision,
VolumePrecision: m.BaseUnitPrecision,
QuoteCurrency: toGlobalCurrency(m.QuoteUnit),
BaseCurrency: toGlobalCurrency(m.BaseUnit),
MinNotional: m.MinQuoteAmount,
MinAmount: m.MinQuoteAmount,
MinLot: m.MinBaseAmount,
MinQuantity: m.MinBaseAmount,
MaxQuantity: 10000.0,
MinPrice: 0.1,
MaxPrice: 10000.0,
TickSize: 0.001,
}
markets[m.ID] = market
}
return markets, nil
}
func (e *Exchange) NewStream() types.Stream {
return NewStream(e.key, e.secret)
}

View File

@ -19,12 +19,14 @@ type PublicService struct {
}
type Market struct {
ID string `json:"id"`
Name string `json:"name"`
BaseUnit string `json:"base_unit"`
BaseUnitPrecision int `json:"base_unit_precision"`
QuoteUnit string `json:"quote_unit"`
QuoteUnitPrecision int `json:"quote_unit_precision"`
ID string `json:"id"`
Name string `json:"name"`
BaseUnit string `json:"base_unit"`
BaseUnitPrecision int `json:"base_unit_precision"`
QuoteUnit string `json:"quote_unit"`
QuoteUnitPrecision int `json:"quote_unit_precision"`
MinBaseAmount float64 `json:"min_base_amount"`
MinQuoteAmount float64 `json:"min_quote_amount"`
}
type Ticker struct {