mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 17:13:51 +00:00
ftx: add conversion helper
This commit is contained in:
parent
778ceb2985
commit
506fdcd84f
|
@ -21,6 +21,10 @@ func TrimUpperString(original string) string {
|
||||||
return strings.ToUpper(strings.TrimSpace(original))
|
return strings.ToUpper(strings.TrimSpace(original))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TrimLowerString(original string) string {
|
||||||
|
return strings.ToLower(strings.TrimSpace(original))
|
||||||
|
}
|
||||||
|
|
||||||
var errUnsupportedOrderStatus = fmt.Errorf("unsupported order status")
|
var errUnsupportedOrderStatus = fmt.Errorf("unsupported order status")
|
||||||
|
|
||||||
func toGlobalOrderFromOpenOrder(r order) (types.Order, error) {
|
func toGlobalOrderFromOpenOrder(r order) (types.Order, error) {
|
||||||
|
|
|
@ -49,3 +49,50 @@ func Test_toGlobalOrderFromOpenOrder(t *testing.T) {
|
||||||
assert.Equal(t, types.OrderStatusPartiallyFilled, o.Status)
|
assert.Equal(t, types.OrderStatusPartiallyFilled, o.Status)
|
||||||
assert.Equal(t, float64(10), o.ExecutedQuantity)
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user