mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
grid2: log base fee rounding precision
This commit is contained in:
parent
b2bbf2d6ca
commit
f553ee05a0
|
@ -7,6 +7,7 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/backtest"
|
||||
|
@ -14,6 +15,7 @@ import (
|
|||
"github.com/c9s/bbgo/pkg/exchange"
|
||||
"github.com/c9s/bbgo/pkg/service"
|
||||
"github.com/c9s/bbgo/pkg/types"
|
||||
"github.com/c9s/bbgo/pkg/util"
|
||||
)
|
||||
|
||||
func RunBacktest(t *testing.T, strategy bbgo.SingleExchangeStrategy) {
|
||||
|
@ -154,3 +156,29 @@ func RunBacktest(t *testing.T, strategy bbgo.SingleExchangeStrategy) {
|
|||
<-doneC
|
||||
// }}}
|
||||
}
|
||||
|
||||
func TestBacktestStrategy(t *testing.T) {
|
||||
if v, ok := util.GetEnvVarBool("TEST_BACKTEST"); !ok || !v {
|
||||
t.Skip("backtest flag is required")
|
||||
return
|
||||
}
|
||||
|
||||
market := types.Market{
|
||||
BaseCurrency: "BTC",
|
||||
QuoteCurrency: "USDT",
|
||||
TickSize: number(0.01),
|
||||
PricePrecision: 2,
|
||||
VolumePrecision: 8,
|
||||
}
|
||||
strategy := &Strategy{
|
||||
logger: logrus.NewEntry(logrus.New()),
|
||||
Symbol: "BTCUSDT",
|
||||
Market: market,
|
||||
GridProfitStats: newGridProfitStats(market),
|
||||
UpperPrice: number(60_000),
|
||||
LowerPrice: number(28_000),
|
||||
GridNum: 100,
|
||||
QuoteInvestment: number(9000.0),
|
||||
}
|
||||
RunBacktest(t, strategy)
|
||||
}
|
||||
|
|
|
@ -417,7 +417,10 @@ func (s *Strategy) processFilledOrder(o types.Order) {
|
|||
s.logger.Infof("GRID BUY ORDER BASE FEE: %s %s", baseSellQuantityReduction.String(), s.Market.BaseCurrency)
|
||||
|
||||
baseSellQuantityReduction = baseSellQuantityReduction.Round(s.Market.VolumePrecision, fixedpoint.Up)
|
||||
s.logger.Infof("GRID BUY ORDER BASE FEE (Rounding): %s %s", baseSellQuantityReduction.String(), s.Market.BaseCurrency)
|
||||
s.logger.Infof("GRID BUY ORDER BASE FEE (Rounding with precision %d): %s %s",
|
||||
s.Market.VolumePrecision,
|
||||
baseSellQuantityReduction.String(),
|
||||
s.Market.BaseCurrency)
|
||||
|
||||
newQuantity = newQuantity.Sub(baseSellQuantityReduction)
|
||||
|
||||
|
|
|
@ -13,11 +13,9 @@ import (
|
|||
|
||||
"github.com/c9s/bbgo/pkg/bbgo"
|
||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||
gridmocks "github.com/c9s/bbgo/pkg/strategy/grid2/mocks"
|
||||
"github.com/c9s/bbgo/pkg/types"
|
||||
"github.com/c9s/bbgo/pkg/types/mocks"
|
||||
"github.com/c9s/bbgo/pkg/util"
|
||||
|
||||
gridmocks "github.com/c9s/bbgo/pkg/strategy/grid2/mocks"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -919,29 +917,3 @@ func TestStrategy_checkMinimalQuoteInvestment(t *testing.T) {
|
|||
assert.EqualError(t, err, "need at least 14979.995500 USDT for quote investment, 10000.000000 USDT given")
|
||||
})
|
||||
}
|
||||
|
||||
func TestBacktestStrategy(t *testing.T) {
|
||||
if v, ok := util.GetEnvVarBool("TEST_BACKTEST"); !ok || !v {
|
||||
t.Skip("backtest flag is required")
|
||||
return
|
||||
}
|
||||
|
||||
market := types.Market{
|
||||
BaseCurrency: "BTC",
|
||||
QuoteCurrency: "USDT",
|
||||
TickSize: number(0.01),
|
||||
PricePrecision: 2,
|
||||
VolumePrecision: 8,
|
||||
}
|
||||
strategy := &Strategy{
|
||||
logger: logrus.NewEntry(logrus.New()),
|
||||
Symbol: "BTCUSDT",
|
||||
Market: market,
|
||||
GridProfitStats: newGridProfitStats(market),
|
||||
UpperPrice: number(60_000),
|
||||
LowerPrice: number(28_000),
|
||||
GridNum: 100,
|
||||
QuoteInvestment: number(9000.0),
|
||||
}
|
||||
RunBacktest(t, strategy)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user