tradingutil: add test on CollectTradeFee

This commit is contained in:
c9s 2023-08-05 16:38:46 +08:00
parent 4d293121d7
commit ce8063654d
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -0,0 +1,41 @@
package tradingutil
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
)
var number = fixedpoint.MustNewFromString
func Test_CollectTradeFee(t *testing.T) {
trades := []types.Trade{
{
ID: 1,
Price: number("21000"),
Quantity: number("0.001"),
Symbol: "BTCUSDT",
Side: types.SideTypeBuy,
Fee: number("0.00001"),
FeeCurrency: "BTC",
FeeDiscounted: false,
},
{
ID: 2,
Price: number("21200"),
Quantity: number("0.001"),
Symbol: "BTCUSDT",
Side: types.SideTypeBuy,
Fee: number("0.00002"),
FeeCurrency: "BTC",
FeeDiscounted: false,
},
}
fees := CollectTradeFee(trades)
assert.NotNil(t, fees)
assert.Equal(t, number("0.00003"), fees["BTC"])
}