qbtrade/pkg/testing/testhelper/number.go

19 lines
388 B
Go
Raw Permalink Normal View History

2024-06-27 14:42:38 +00:00
package testhelper
import "git.qtrade.icu/lychiyu/qbtrade/pkg/fixedpoint"
func Number(a interface{}) fixedpoint.Value {
switch v := a.(type) {
case string:
return fixedpoint.MustNewFromString(v)
case int:
return fixedpoint.NewFromInt(int64(v))
case int64:
return fixedpoint.NewFromInt(int64(v))
case float64:
return fixedpoint.NewFromFloat(v)
}
return fixedpoint.Zero
}