mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
tradingutil: add test on CollectTradeFee
This commit is contained in:
parent
4d293121d7
commit
ce8063654d
41
pkg/util/tradingutil/trades_test.go
Normal file
41
pkg/util/tradingutil/trades_test.go
Normal 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"])
|
||||
}
|
Loading…
Reference in New Issue
Block a user