fix takerfeerate column and makerfeerate column issue in yaml

This commit is contained in:
zenix 2022-02-09 20:37:49 +09:00
parent fad85d0992
commit 5315378b9e
3 changed files with 19 additions and 9 deletions

View File

@ -7,6 +7,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"github.com/c9s/bbgo/pkg/fixedpoint"
) )
func init() { func init() {
@ -14,11 +16,11 @@ func init() {
} }
type TestStrategy struct { type TestStrategy struct {
Symbol string `json:"symbol"` Symbol string `json:"symbol"`
Interval string `json:"interval"` Interval string `json:"interval"`
BaseQuantity float64 `json:"baseQuantity"` BaseQuantity fixedpoint.Value `json:"baseQuantity"`
MaxAssetQuantity float64 `json:"maxAssetQuantity"` MaxAssetQuantity fixedpoint.Value `json:"maxAssetQuantity"`
MinDropPercentage float64 `json:"minDropPercentage"` MinDropPercentage fixedpoint.Value `json:"minDropPercentage"`
} }
func (s *TestStrategy) ID() string { func (s *TestStrategy) ID() string {
@ -69,9 +71,9 @@ func TestLoadConfig(t *testing.T) {
Strategy: &TestStrategy{ Strategy: &TestStrategy{
Symbol: "BTCUSDT", Symbol: "BTCUSDT",
Interval: "1m", Interval: "1m",
BaseQuantity: 0.1, BaseQuantity: fixedpoint.NewFromFloat(0.1),
MaxAssetQuantity: 1.1, MaxAssetQuantity: fixedpoint.NewFromFloat(1.1),
MinDropPercentage: -0.05, MinDropPercentage: fixedpoint.NewFromFloat(-0.05),
}, },
}}, config.ExchangeStrategies) }}, config.ExchangeStrategies)
@ -82,10 +84,14 @@ func TestLoadConfig(t *testing.T) {
"max": map[string]interface{}{ "max": map[string]interface{}{
"exchange": "max", "exchange": "max",
"envVarPrefix": "MAX", "envVarPrefix": "MAX",
"takerFeeRate": 0.,
"makerFeeRate": 0.,
}, },
"binance": map[string]interface{}{ "binance": map[string]interface{}{
"exchange": "binance", "exchange": "binance",
"envVarPrefix": "BINANCE", "envVarPrefix": "BINANCE",
"takerFeeRate": 0.,
"makerFeeRate": 0.,
}, },
}, },
"build": map[string]interface{}{ "build": map[string]interface{}{

View File

@ -50,7 +50,7 @@ func TestAdjustQuantityByMinAmount(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
q := AdjustFloatQuantityByMinAmount(test.args.quantity, test.args.price, test.args.minAmount) q := AdjustFloatQuantityByMinAmount(test.args.quantity, test.args.price, test.args.minAmount)
assert.Equal(t, test.wanted, q.String()) assert.Equal(t, fixedpoint.MustNewFromString(test.wanted), q)
}) })
} }
} }

View File

@ -3,9 +3,13 @@ sessions:
max: max:
exchange: max exchange: max
envVarPrefix: MAX envVarPrefix: MAX
takerFeeRate: 0
makerFeeRate: 0
binance: binance:
exchange: binance exchange: binance
envVarPrefix: BINANCE envVarPrefix: BINANCE
takerFeeRate: 0
makerFeeRate: 0
exchangeStrategies: exchangeStrategies:
- on: ["binance"] - on: ["binance"]