mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-15 19:43:53 +00:00
21 lines
458 B
Go
21 lines
458 B
Go
package tradingutil
|
|
|
|
import (
|
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
|
"github.com/c9s/bbgo/pkg/types"
|
|
)
|
|
|
|
// CollectTradeFee collects the fee from the given trade slice
|
|
func CollectTradeFee(trades []types.Trade) map[string]fixedpoint.Value {
|
|
fees := make(map[string]fixedpoint.Value)
|
|
for _, t := range trades {
|
|
if fee, ok := fees[t.FeeCurrency]; ok {
|
|
fees[t.FeeCurrency] = fee.Add(t.Fee)
|
|
} else {
|
|
fees[t.FeeCurrency] = t.Fee
|
|
}
|
|
}
|
|
|
|
return fees
|
|
}
|