diff --git a/pkg/util/math.go b/pkg/util/math.go index bf73885e7..1159ff59d 100644 --- a/pkg/util/math.go +++ b/pkg/util/math.go @@ -1,7 +1,6 @@ package util import ( - "math" "strconv" "github.com/c9s/bbgo/pkg/fixedpoint" @@ -27,34 +26,3 @@ func FormatValue(val fixedpoint.Value, prec int) string { func FormatFloat(val float64, prec int) string { return strconv.FormatFloat(val, 'f', prec, 64) } - -func ParseFloat(s string) (float64, error) { - if len(s) == 0 { - return 0.0, nil - } - - return strconv.ParseFloat(s, 64) -} - -func MustParseFloat(s string) float64 { - if len(s) == 0 { - return 0.0 - } - - v, err := strconv.ParseFloat(s, 64) - if err != nil { - panic(err) - } - return v -} - -const epsilon = 0.0000001 - -func Zero(v float64) bool { - return math.Abs(v) < epsilon -} - -func NotZero(v float64) bool { - return math.Abs(v) > epsilon -} - diff --git a/pkg/util/math_test.go b/pkg/util/math_test.go index 96d96a301..c7d868219 100644 --- a/pkg/util/math_test.go +++ b/pkg/util/math_test.go @@ -1,36 +1 @@ package util - -import "testing" - -func TestNotZero(t *testing.T) { - type args struct { - v float64 - } - tests := []struct { - name string - args args - want bool - }{ - { - name: "0", - args: args{ - v: 0, - }, - want: false, - }, - { - name: "0.00001", - args: args{ - v: 0.00001, - }, - want: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := NotZero(tt.args.v); got != tt.want { - t.Errorf("NotZero() = %v, want %v", got, tt.want) - } - }) - } -}