fix go fmt, fix convert.go (the legacy fixedpoint implementation) in all tests

This commit is contained in:
zenix 2022-02-15 14:55:19 +09:00
parent eb70410f80
commit 8648528435
62 changed files with 169 additions and 203 deletions

View File

@ -7,8 +7,8 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
) )
func zero(a float64) bool { func zero(a float64) bool {

View File

@ -7,8 +7,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
) )
func TestStockManager(t *testing.T) { func TestStockManager(t *testing.T) {

View File

@ -39,4 +39,3 @@ func (s *Stream) Connect(ctx context.Context) error {
func (s *Stream) Close() error { func (s *Stream) Close() error {
return nil return nil
} }

View File

@ -8,4 +8,3 @@ import (
type Context struct { type Context struct {
sync.Mutex sync.Mutex
} }

View File

@ -3,4 +3,3 @@ package bbgo
import "errors" import "errors"
var ErrSessionAlreadyInitialized = errors.New("session is already initialized") var ErrSessionAlreadyInitialized = errors.New("session is already initialized")

View File

@ -8,9 +8,9 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/interact" "github.com/c9s/bbgo/pkg/interact"
"github.com/c9s/bbgo/pkg/types" "github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint"
) )
type PositionCloser interface { type PositionCloser interface {

View File

@ -3,8 +3,8 @@ package bbgo
import ( import (
"testing" "testing"
"github.com/stretchr/testify/assert"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/stretchr/testify/assert"
) )
func TestAdjustQuantityByMinAmount(t *testing.T) { func TestAdjustQuantityByMinAmount(t *testing.T) {

View File

@ -4,7 +4,6 @@ import (
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
const Delta = 1e-9 const Delta = 1e-9
@ -200,4 +199,3 @@ func TestPercentageScale(t *testing.T) {
assert.InDelta(t, 100.0, v, Delta) assert.InDelta(t, 100.0, v, Delta)
}) })
} }

View File

@ -173,8 +173,8 @@ type ExchangeSession struct {
// Withdrawal is used for enabling withdrawal functions // Withdrawal is used for enabling withdrawal functions
Withdrawal bool `json:"withdrawal,omitempty" yaml:"withdrawal,omitempty"` Withdrawal bool `json:"withdrawal,omitempty" yaml:"withdrawal,omitempty"`
MakerFeeRate fixedpoint.Value `json:"makerFeeRate,omitempty" yaml:"makerFeeRate,omitempty"` MakerFeeRate fixedpoint.Value `json:"makerFeeRate" yaml:"makerFeeRate"`
TakerFeeRate fixedpoint.Value `json:"takerFeeRate,omitempty" yaml:"takerFeeRate,omitempty"` TakerFeeRate fixedpoint.Value `json:"takerFeeRate" yaml:"takerFeeRate"`
PublicOnly bool `json:"publicOnly,omitempty" yaml:"publicOnly"` PublicOnly bool `json:"publicOnly,omitempty" yaml:"publicOnly"`
Margin bool `json:"margin,omitempty" yaml:"margin"` Margin bool `json:"margin,omitempty" yaml:"margin"`

View File

@ -5,8 +5,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
) )
func TestTradeCollector_ShouldNotCountDuplicatedTrade(t *testing.T) { func TestTradeCollector_ShouldNotCountDuplicatedTrade(t *testing.T) {

View File

@ -21,9 +21,9 @@ import (
"github.com/c9s/bbgo/pkg/backtest" "github.com/c9s/bbgo/pkg/backtest"
"github.com/c9s/bbgo/pkg/bbgo" "github.com/c9s/bbgo/pkg/bbgo"
"github.com/c9s/bbgo/pkg/cmd/cmdutil" "github.com/c9s/bbgo/pkg/cmd/cmdutil"
"github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/service" "github.com/c9s/bbgo/pkg/service"
"github.com/c9s/bbgo/pkg/types" "github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint"
) )
type BackTestReport struct { type BackTestReport struct {

View File

@ -24,7 +24,6 @@ var balancesCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background() ctx := context.Background()
configFile, err := cmd.Flags().GetString("config") configFile, err := cmd.Flags().GetString("config")
if err != nil { if err != nil {
return err return err
@ -39,7 +38,6 @@ var balancesCmd = &cobra.Command{
return err return err
} }
// if config file exists, use the config loaded from the config file. // if config file exists, use the config loaded from the config file.
// otherwise, use a empty config object // otherwise, use a empty config object
var userConfig *bbgo.Config var userConfig *bbgo.Config
@ -63,7 +61,6 @@ var balancesCmd = &cobra.Command{
return err return err
} }
if len(sessionName) > 0 { if len(sessionName) > 0 {
session, ok := environ.Session(sessionName) session, ok := environ.Session(sessionName)
if !ok { if !ok {
@ -89,7 +86,6 @@ var balancesCmd = &cobra.Command{
} }
} }
return nil return nil
}, },
} }

View File

@ -14,6 +14,7 @@ import (
_ "github.com/c9s/bbgo/pkg/strategy/pricedrop" _ "github.com/c9s/bbgo/pkg/strategy/pricedrop"
_ "github.com/c9s/bbgo/pkg/strategy/rebalance" _ "github.com/c9s/bbgo/pkg/strategy/rebalance"
_ "github.com/c9s/bbgo/pkg/strategy/schedule" _ "github.com/c9s/bbgo/pkg/strategy/schedule"
_ "github.com/c9s/bbgo/pkg/strategy/skeleton"
_ "github.com/c9s/bbgo/pkg/strategy/support" _ "github.com/c9s/bbgo/pkg/strategy/support"
_ "github.com/c9s/bbgo/pkg/strategy/swing" _ "github.com/c9s/bbgo/pkg/strategy/swing"
_ "github.com/c9s/bbgo/pkg/strategy/techsignal" _ "github.com/c9s/bbgo/pkg/strategy/techsignal"
@ -22,5 +23,4 @@ import (
_ "github.com/c9s/bbgo/pkg/strategy/xmaker" _ "github.com/c9s/bbgo/pkg/strategy/xmaker"
_ "github.com/c9s/bbgo/pkg/strategy/xnav" _ "github.com/c9s/bbgo/pkg/strategy/xnav"
_ "github.com/c9s/bbgo/pkg/strategy/xpuremaker" _ "github.com/c9s/bbgo/pkg/strategy/xpuremaker"
_ "github.com/c9s/bbgo/pkg/strategy/skeleton"
) )

View File

@ -85,7 +85,6 @@ var cancelOrderCmd = &cobra.Command{
var sessions = environ.Sessions() var sessions = environ.Sessions()
if len(sessionName) > 0 { if len(sessionName) > 0 {
ses, ok := environ.Session(sessionName) ses, ok := environ.Session(sessionName)
if !ok { if !ok {

View File

@ -164,7 +164,6 @@ func runConfig(basectx context.Context, cmd *cobra.Command, userConfig *bbgo.Con
environ.BindSync(userConfig) environ.BindSync(userConfig)
} }
trader := bbgo.NewTrader(environ) trader := bbgo.NewTrader(environ)
if err := trader.Configure(userConfig); err != nil { if err := trader.Configure(userConfig); err != nil {
return err return err

View File

@ -58,8 +58,6 @@ var SyncCmd = &cobra.Command{
return err return err
} }
sessionName, err := cmd.Flags().GetString("session") sessionName, err := cmd.Flags().GetString("session")
if err != nil { if err != nil {
return err return err

View File

@ -10,8 +10,8 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/c9s/bbgo/pkg/bbgo" "github.com/c9s/bbgo/pkg/bbgo"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
) )
func init() { func init() {

View File

@ -6,8 +6,8 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/c9s/bbgo/pkg/exchange/ftx" "github.com/c9s/bbgo/pkg/exchange/ftx"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
) )
func inQuoteAsset(balances types.BalanceMap, market types.Market, price fixedpoint.Value) fixedpoint.Value { func inQuoteAsset(balances types.BalanceMap, market types.Market, price fixedpoint.Value) fixedpoint.Value {

View File

@ -3,8 +3,8 @@
package fixedpoint package fixedpoint
import ( import (
"bytes"
"database/sql/driver" "database/sql/driver"
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"math" "math"
@ -57,7 +57,7 @@ func (v Value) Value() (driver.Value, error) {
func (v *Value) Scan(src interface{}) error { func (v *Value) Scan(src interface{}) error {
switch d := src.(type) { switch d := src.(type) {
case int64: case int64:
*v = Value(d) *v = NewFromInt(d)
return nil return nil
case float64: case float64:
@ -95,7 +95,8 @@ func (v Value) String() string {
} }
func (v Value) FormatString(prec int) string { func (v Value) FormatString(prec int) string {
return strconv.FormatFloat(float64(v)/DefaultPow, 'f', prec, 64) result := strconv.FormatFloat(float64(v)/DefaultPow, 'f', prec+1, 64)
return result[:len(result)-1]
} }
func (v Value) Percentage() string { func (v Value) Percentage() string {
@ -109,7 +110,8 @@ func (v Value) FormatPercentage(prec int) string {
if v == 0 { if v == 0 {
return "0" return "0"
} }
return strconv.FormatFloat(float64(v)/DefaultPow*100., 'f', prec, 64) + "%" result := strconv.FormatFloat(float64(v)/DefaultPow*100., 'f', prec+1, 64)
return result[:len(result)-1] + "%"
} }
func (v Value) SignedPercentage() string { func (v Value) SignedPercentage() string {
@ -223,36 +225,21 @@ func (v Value) MarshalJSON() ([]byte, error) {
} }
func (v *Value) UnmarshalJSON(data []byte) error { func (v *Value) UnmarshalJSON(data []byte) error {
var a interface{} if bytes.Compare(data, []byte{'n', 'u', 'l', 'l'}) == 0 {
var err = json.Unmarshal(data, &a) *v = Zero
if err != nil { return nil
}
if len(data) == 0 {
*v = Zero
return nil
}
var err error
if data[0] == '"' {
data = data[1 : len(data)-1]
}
if *v, err = NewFromString(string(data)); err != nil {
return err return err
} }
switch d := a.(type) {
case float64:
*v = NewFromFloat(d)
case float32:
*v = NewFromFloat(float64(d))
case int64:
*v = NewFromInt(d)
case int:
*v = NewFromInt(int64(d))
case string:
v2, err := NewFromString(d)
if err != nil {
return err
}
*v = v2
default:
return fmt.Errorf("unsupported type: %T %v", d, d)
}
return nil return nil
} }

View File

@ -166,7 +166,7 @@ func NewFromFloat(f float64) Value {
} }
_, e := math.Frexp(f) _, e := math.Frexp(f)
e = int(float32(e) / log2of10) e = int(float32(e) / log2of10)
c := uint64(f / math.Pow(10, float64(e-16))) c := uint64(f/math.Pow10(e-16) + 0.5)
return newNoSignCheck(sign, c, e) return newNoSignCheck(sign, c, e)
} }
@ -995,8 +995,9 @@ func (v *Value) UnmarshalYAML(unmarshal func(a interface{}) error) (err error) {
return err return err
} }
// FIXME: should we limit to 8 prec?
func (v Value) MarshalJSON() ([]byte, error) { func (v Value) MarshalJSON() ([]byte, error) {
return []byte(v.String()), nil return []byte(v.FormatString(8)), nil
} }
func (v *Value) UnmarshalJSON(data []byte) error { func (v *Value) UnmarshalJSON(data []byte) error {

View File

@ -1,12 +1,12 @@
package indicator package indicator
import ( import (
"encoding/json"
"math" "math"
"testing" "testing"
"encoding/json"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
) )
// generated from: // generated from:
@ -1030,7 +1030,7 @@ func Test_calculateEWMA(t *testing.T) {
priceF KLinePriceMapper priceF KLinePriceMapper
window int window int
} }
var input []fixedpoint.Value; var input []fixedpoint.Value
if err := json.Unmarshal(ethusdt5m, &input); err != nil { if err := json.Unmarshal(ethusdt5m, &input); err != nil {
panic(err) panic(err)
} }

View File

@ -1,12 +1,12 @@
package indicator package indicator
import ( import (
"encoding/json"
"math" "math"
"testing" "testing"
"encoding/json"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
) )
/* /*

View File

@ -1,13 +1,13 @@
package indicator package indicator
import ( import (
"testing"
"encoding/json" "encoding/json"
"testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
) )
const Delta = 1e-9 const Delta = 1e-9
@ -53,7 +53,7 @@ func Test_calculateOBV(t *testing.T) {
obv := OBV{IntervalWindow: types.IntervalWindow{Window: tt.window}} obv := OBV{IntervalWindow: types.IntervalWindow{Window: tt.window}}
obv.calculateAndUpdate(tt.kLines) obv.calculateAndUpdate(tt.kLines)
assert.Equal(t, len(obv.Values), len(tt.want)) assert.Equal(t, len(obv.Values), len(tt.want))
for i, v := range(obv.Values) { for i, v := range obv.Values {
assert.InDelta(t, v, tt.want[i], Delta) assert.InDelta(t, v, tt.want[i], Delta)
} }
}) })

View File

@ -1,13 +1,13 @@
package indicator package indicator
import ( import (
"encoding/json"
"math" "math"
"testing" "testing"
"time" "time"
"encoding/json"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
) )
/* /*

View File

@ -1,13 +1,14 @@
package indicator package indicator
import ( import (
"encoding/json"
"math" "math"
"testing" "testing"
"encoding/json"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
) )
var trivialPrices = []byte(`[0]`) var trivialPrices = []byte(`[0]`)
var trivialVolumes = []byte(`[1]`) var trivialVolumes = []byte(`[1]`)
var easyPrices = []byte(`[1, 2, 3]`) var easyPrices = []byte(`[1, 2, 3]`)

View File

@ -1,4 +1,4 @@
// +build web //go:build web
package server package server

View File

@ -1,4 +1,4 @@
// +build !web //go:build !web
package server package server

View File

@ -22,7 +22,6 @@ type Strategy struct {
Notifiability *bbgo.Notifiability Notifiability *bbgo.Notifiability
TotalAmount fixedpoint.Value `json:"totalAmount,omitempty"` TotalAmount fixedpoint.Value `json:"totalAmount,omitempty"`
// Interval is the period that you want to submit order // Interval is the period that you want to submit order

View File

@ -9,9 +9,9 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/c9s/bbgo/pkg/bbgo" "github.com/c9s/bbgo/pkg/bbgo"
"github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/indicator" "github.com/c9s/bbgo/pkg/indicator"
"github.com/c9s/bbgo/pkg/types" "github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint"
) )
const ID = "flashcrash" const ID = "flashcrash"

View File

@ -4,8 +4,8 @@ import (
"context" "context"
"github.com/c9s/bbgo/pkg/bbgo" "github.com/c9s/bbgo/pkg/bbgo"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
) )
const ID = "pricealert" const ID = "pricealert"

View File

@ -6,11 +6,12 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/c9s/bbgo/pkg/bbgo" "github.com/c9s/bbgo/pkg/bbgo"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
) )
const ID = "skeleton" const ID = "skeleton"
var log = logrus.WithField("strategy", ID) var log = logrus.WithField("strategy", ID)
func init() { func init() {
@ -25,7 +26,6 @@ func (s *Strategy) ID() string {
return ID return ID
} }
func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) { func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) {
log.Infof("subscribe %s", s.Symbol) log.Infof("subscribe %s", s.Symbol)
session.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: "1m"}) session.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: "1m"})

View File

@ -7,8 +7,8 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/c9s/bbgo/pkg/bbgo" "github.com/c9s/bbgo/pkg/bbgo"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
) )
const ID = "swing" const ID = "swing"

View File

@ -130,7 +130,6 @@ func (s *Strategy) listenToFundingRate(ctx context.Context, exchange *binance.Ex
} }
} }
previousIndex = index previousIndex = index
if fundingRate24HoursLowIndex != nil { if fundingRate24HoursLowIndex != nil {
if fundingRate24HoursLowIndex.Time.Before(time.Now().Add(24 * time.Hour)) { if fundingRate24HoursLowIndex.Time.Before(time.Now().Add(24 * time.Hour)) {

View File

@ -467,6 +467,7 @@ func (s *Strategy) updateQuote(ctx context.Context, orderExecutionRouter bbgo.Or
var lastPriceModifier = fixedpoint.NewFromFloat(1.001) var lastPriceModifier = fixedpoint.NewFromFloat(1.001)
var minGap = fixedpoint.NewFromFloat(1.02) var minGap = fixedpoint.NewFromFloat(1.02)
func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value) { func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value) {
side := types.SideTypeBuy side := types.SideTypeBuy
if pos.IsZero() { if pos.IsZero() {

View File

@ -1,2 +1 @@
package xnav package xnav

View File

@ -1,2 +1 @@
package types package types

View File

@ -32,4 +32,3 @@ func IsFiatCurrency(currency string) bool {
} }
return false return false
} }

View File

@ -1,8 +1,8 @@
package types package types
import ( import (
"time"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"time"
) )
type DepositStatus string type DepositStatus string

View File

@ -6,8 +6,8 @@ import (
"github.com/slack-go/slack" "github.com/slack-go/slack"
"github.com/c9s/bbgo/pkg/util"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/util"
) )
type Direction int type Direction int
@ -137,7 +137,6 @@ func (k KLine) GetAmplification() fixedpoint.Value {
return k.GetMaxChange().Div(k.GetLow()) return k.GetMaxChange().Div(k.GetLow())
} }
// GetThickness returns the thickness of the kline. 1 => thick, 0.1 => thin // GetThickness returns the thickness of the kline. 1 => thick, 0.1 => thin
func (k KLine) GetThickness() fixedpoint.Value { func (k KLine) GetThickness() fixedpoint.Value {
out := k.GetChange().Div(k.GetMaxChange()) out := k.GetChange().Div(k.GetMaxChange())

View File

@ -1,9 +1,9 @@
package types package types
import ( import (
"testing"
"github.com/stretchr/testify/assert"
"encoding/json" "encoding/json"
"github.com/stretchr/testify/assert"
"testing"
) )
func TestKLineWindow_Tail(t *testing.T) { func TestKLineWindow_Tail(t *testing.T) {

View File

@ -5,8 +5,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/stretchr/testify/assert"
) )
var s func(string) fixedpoint.Value = fixedpoint.MustNewFromString var s func(string) fixedpoint.Value = fixedpoint.MustNewFromString

View File

@ -10,8 +10,8 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/slack-go/slack" "github.com/slack-go/slack"
"github.com/c9s/bbgo/pkg/util"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/util"
) )
func init() { func init() {

View File

@ -3,8 +3,8 @@ package types
import ( import (
"testing" "testing"
"github.com/stretchr/testify/assert"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/stretchr/testify/assert"
) )
func TestPriceVolumeSlice_Remove(t *testing.T) { func TestPriceVolumeSlice_Remove(t *testing.T) {

View File

@ -33,10 +33,12 @@ type Reward struct {
} }
type RewardSlice []Reward type RewardSlice []Reward
func (s RewardSlice) Len() int { return len(s) } func (s RewardSlice) Len() int { return len(s) }
func (s RewardSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s RewardSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
type RewardSliceByCreationTime RewardSlice type RewardSliceByCreationTime RewardSlice
func (s RewardSliceByCreationTime) Len() int { return len(s) } func (s RewardSliceByCreationTime) Len() int { return len(s) }
func (s RewardSliceByCreationTime) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s RewardSliceByCreationTime) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

View File

@ -1,8 +1,8 @@
package types package types
import ( import (
"time"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"time"
) )
type Ticker struct { type Ticker struct {

View File

@ -146,7 +146,6 @@ func (trade Trade) PlainText() string {
var slackTradeTextTemplate = ":handshake: Trade {{ .Symbol }} {{ .Side }} {{ .Quantity }} @ {{ .Price }}" var slackTradeTextTemplate = ":handshake: Trade {{ .Symbol }} {{ .Side }} {{ .Quantity }} @ {{ .Price }}"
func exchangeFooterIcon(exName ExchangeName) string { func exchangeFooterIcon(exName ExchangeName) string {
footerIcon := "" footerIcon := ""

View File

@ -29,9 +29,9 @@ func Test_trimTrailingZero(t *testing.T) {
{ {
name: "non trailing zero", name: "non trailing zero",
args: args{ args: args{
a: "1.0001234567", a: "1.00012345",
}, },
want: "1.0001234567", want: "1.00012345",
}, },
{ {
name: "integer", name: "integer",

View File

@ -2,8 +2,8 @@ package types
import ( import (
"fmt" "fmt"
"time"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
"time"
) )
type Withdraw struct { type Withdraw struct {
@ -35,4 +35,3 @@ type WithdrawalOptions struct {
Network string Network string
AddressTag string AddressTag string
} }

View File

@ -1,9 +1,9 @@
package util package util
import ( import (
"github.com/c9s/bbgo/pkg/fixedpoint"
"math" "math"
"strconv" "strconv"
"github.com/c9s/bbgo/pkg/fixedpoint"
) )
const MaxDigits = 18 // MAX_INT64 ~ 9 * 10^18 const MaxDigits = 18 // MAX_INT64 ~ 9 * 10^18

View File

@ -30,4 +30,3 @@ func TestReonce_DoAndReset(t *testing.T) {
time.Sleep(time.Second) time.Sleep(time.Second)
assert.Equal(t, 2, cnt) assert.Equal(t, 2, cnt)
} }

View File

@ -33,7 +33,3 @@ func ParseTimeWithFormats(strTime string, formats []string) (time.Time, error) {
} }
return time.Time{}, fmt.Errorf("failed to parse time %s, valid formats are %+v", strTime, formats) return time.Time{}, fmt.Errorf("failed to parse time %s, valid formats are %+v", strTime, formats)
} }