diff --git a/pkg/exchange/ftx/convert.go b/pkg/exchange/ftx/convert.go index c72dd274a..79ae18cbb 100644 --- a/pkg/exchange/ftx/convert.go +++ b/pkg/exchange/ftx/convert.go @@ -21,6 +21,10 @@ func TrimUpperString(original string) string { return strings.ToUpper(strings.TrimSpace(original)) } +func TrimLowerString(original string) string { + return strings.ToLower(strings.TrimSpace(original)) +} + var errUnsupportedOrderStatus = fmt.Errorf("unsupported order status") func toGlobalOrderFromOpenOrder(r order) (types.Order, error) { diff --git a/pkg/exchange/ftx/convert_test.go b/pkg/exchange/ftx/convert_test.go index 6c480eb68..7161d6747 100644 --- a/pkg/exchange/ftx/convert_test.go +++ b/pkg/exchange/ftx/convert_test.go @@ -49,3 +49,50 @@ func Test_toGlobalOrderFromOpenOrder(t *testing.T) { assert.Equal(t, types.OrderStatusPartiallyFilled, o.Status) assert.Equal(t, float64(10), o.ExecutedQuantity) } + +func TestTrimLowerString(t *testing.T) { + type args struct { + original string + } + tests := []struct { + name string + args args + want string + }{ + { + name: "spaces", + args: args{ + original: " ", + }, + want: "", + }, + { + name: "uppercase", + args: args{ + original: " HELLO ", + }, + want: "hello", + }, + { + name: "lowercase", + args: args{ + original: " hello", + }, + want: "hello", + }, + { + name: "upper/lower cases", + args: args{ + original: " heLLo ", + }, + want: "hello", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := TrimLowerString(tt.args.original); got != tt.want { + t.Errorf("TrimLowerString() = %v, want %v", got, tt.want) + } + }) + } +}