mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
grid2: fix tests
This commit is contained in:
parent
622fe75ed3
commit
1629a25beb
|
@ -16,18 +16,6 @@ func TestStrategy_checkRequiredInvestmentByQuantity(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
t.Run("basic base balance check", func(t *testing.T) {
|
||||
_, _, err := s.checkRequiredInvestmentByQuantity(number(1.0), number(10_000.0), number(0.1), number(19000.0), []Pin{})
|
||||
assert.Error(t, err)
|
||||
assert.EqualError(t, err, "baseInvestment setup 2.000000 is greater than the total base balance 1.000000")
|
||||
})
|
||||
|
||||
t.Run("basic quote balance check", func(t *testing.T) {
|
||||
_, _, err := s.checkRequiredInvestmentByQuantity(number(1.0), number(100.0), number(0.1), number(19_000.0), []Pin{})
|
||||
assert.Error(t, err)
|
||||
assert.EqualError(t, err, "quoteInvestment setup 10000.000000 is greater than the total quote balance 100.000000")
|
||||
})
|
||||
|
||||
t.Run("quote to base balance conversion check", func(t *testing.T) {
|
||||
_, requiredQuote, err := s.checkRequiredInvestmentByQuantity(number(0.0), number(10_000.0), number(0.1), number(13_500.0), []Pin{
|
||||
Pin(number(10_000.0)), // 0.1 * 10_000 = 1000 USD (buy)
|
||||
|
@ -64,7 +52,7 @@ func TestStrategy_checkRequiredInvestmentByAmount(t *testing.T) {
|
|||
}
|
||||
|
||||
t.Run("quote to base balance conversion", func(t *testing.T) {
|
||||
_, requiredQuote, err := s.checkRequiredInvestmentByAmount(number(0.0), number(3_000.0),
|
||||
_, requiredQuote, err := s.checkRequiredInvestmentByAmount(
|
||||
number(0.0), number(3_000.0),
|
||||
number(1000.0),
|
||||
number(13_500.0), []Pin{
|
||||
|
@ -76,6 +64,6 @@ func TestStrategy_checkRequiredInvestmentByAmount(t *testing.T) {
|
|||
Pin(number(15_000.0)),
|
||||
})
|
||||
assert.EqualError(t, err, "quote balance (3000.000000 USDT) is not enough, required = quote 4999.999890")
|
||||
assert.Equal(t, number(4999.99989), requiredQuote)
|
||||
assert.InDelta(t, 4999.99989, requiredQuote.Float64(), number(0.001).Float64())
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user