add LocalSymbol field for exchange specific symbol

This commit is contained in:
c9s 2021-05-26 02:13:59 +08:00
parent 97b377da0a
commit ea78c0308b
5 changed files with 15 additions and 4 deletions

View File

@ -122,6 +122,7 @@ func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error) {
for _, symbol := range exchangeInfo.Symbols {
market := types.Market{
Symbol: symbol.Symbol,
LocalSymbol: symbol.Symbol,
PricePrecision: symbol.QuotePrecision,
VolumePrecision: symbol.BaseAssetPrecision,
QuoteCurrency: symbol.QuoteAsset,

View File

@ -106,6 +106,8 @@ func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error) {
market := types.Market{
Symbol: symbol,
LocalSymbol: m.Name,
// The max precision is length(DefaultPow). For example, currently fixedpoint.DefaultPow
// is 1e8, so the max precision will be 8.
PricePrecision: fixedpoint.NumFractionalDigits(fixedpoint.NewFromFloat(m.PriceIncrement)),

View File

@ -128,6 +128,7 @@ func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error) {
market := types.Market{
Symbol: symbol,
LocalSymbol: m.ID,
PricePrecision: m.QuoteUnitPrecision,
VolumePrecision: m.BaseUnitPrecision,
QuoteCurrency: toGlobalCurrency(m.QuoteUnit),

View File

@ -9,6 +9,9 @@ import (
"github.com/sirupsen/logrus"
)
// OKB is the platform currency of OKEx, pre-allocate static string here
const OKB = "OKB"
var log = logrus.WithFields(logrus.Fields{
"exchange": "okex",
})
@ -48,6 +51,8 @@ func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error) {
symbol := toGlobalSymbol(instrument.InstrumentID)
market := types.Market{
Symbol: symbol,
LocalSymbol: instrument.InstrumentID,
QuoteCurrency: instrument.QuoteCurrency,
BaseCurrency: instrument.BaseCurrency,
@ -83,5 +88,5 @@ func (e *Exchange) QueryTickers(ctx context.Context, symbol string) (*types.Tick
}
func (e *Exchange) PlatformFeeCurrency() string {
return "OKB"
return OKB
}

View File

@ -48,6 +48,8 @@ func (d *Duration) UnmarshalJSON(data []byte) error {
type Market struct {
Symbol string
LocalSymbol string // LocalSymbol is used for exchange's API
PricePrecision int
VolumePrecision int
QuoteCurrency string