From a659bacb0d9207044eab1496ae49f5ca9f50c0eb Mon Sep 17 00:00:00 2001 From: ycdesu Date: Thu, 1 Apr 2021 11:54:16 +0800 Subject: [PATCH] ftx: remove back slash from symbol --- pkg/exchange/ftx/convert.go | 4 ++-- pkg/exchange/ftx/convert_test.go | 4 ++++ pkg/exchange/ftx/exchange_test.go | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/exchange/ftx/convert.go b/pkg/exchange/ftx/convert.go index 7dd4afb97..8ab41ff12 100644 --- a/pkg/exchange/ftx/convert.go +++ b/pkg/exchange/ftx/convert.go @@ -17,7 +17,7 @@ func toGlobalCurrency(original string) string { } func toGlobalSymbol(original string) string { - return TrimUpperString(original) + return strings.ReplaceAll(TrimUpperString(original), "/", "") } func TrimUpperString(original string) string { @@ -133,7 +133,7 @@ func toGlobalTrade(f fill) (types.Trade, error) { func toGlobalKLine(symbol string, interval types.Interval, h Candle) (types.KLine, error) { return types.KLine{ Exchange: types.ExchangeFTX.String(), - Symbol: symbol, + Symbol: toGlobalSymbol(symbol), StartTime: h.StartTime.Time, EndTime: h.StartTime.Add(interval.Duration()), Interval: interval, diff --git a/pkg/exchange/ftx/convert_test.go b/pkg/exchange/ftx/convert_test.go index a805d9f2d..dc848f4dd 100644 --- a/pkg/exchange/ftx/convert_test.go +++ b/pkg/exchange/ftx/convert_test.go @@ -96,3 +96,7 @@ func TestTrimLowerString(t *testing.T) { }) } } + +func Test_toGlobalSymbol(t *testing.T) { + assert.Equal(t, "BTCUSDT", toGlobalSymbol("BTC/USDT")) +} diff --git a/pkg/exchange/ftx/exchange_test.go b/pkg/exchange/ftx/exchange_test.go index a79d393d3..ab340963e 100644 --- a/pkg/exchange/ftx/exchange_test.go +++ b/pkg/exchange/ftx/exchange_test.go @@ -416,7 +416,7 @@ func TestExchange_QueryMarkets(t *testing.T) { assert.Len(t, resp, 1) assert.Equal(t, types.Market{ - Symbol: "BTC/USD", + Symbol: "BTCUSD", PricePrecision: 0, VolumePrecision: 4, QuoteCurrency: "USD", @@ -424,7 +424,7 @@ func TestExchange_QueryMarkets(t *testing.T) { MinQuantity: 0.001, StepSize: 0.0001, TickSize: 1, - }, resp["BTC/USD"]) + }, resp["BTCUSD"]) } func TestExchange_QueryDepositHistory(t *testing.T) { @@ -606,7 +606,7 @@ func TestExchange_QueryTrades(t *testing.T) { Price: 672.5, Quantity: 1.0, QuoteQuantity: 672.5 * 1.0, - Symbol: "TSLA/USD", + Symbol: "TSLAUSD", Side: types.SideTypeSell, IsBuyer: false, IsMaker: true,