Merge pull request #26 from c9s/fix/pnl-check

fix: early return if len of trades == 0
This commit is contained in:
Yo-An Lin 2020-10-24 17:21:42 +08:00 committed by GitHub
commit 5a6ca491aa

View File

@ -23,6 +23,17 @@ func (c *AverageCostCalculator) Calculate(symbol string, trades []types.Trade, c
var bidFeeUSD = 0.0 var bidFeeUSD = 0.0
var feeRate = 0.0015 var feeRate = 0.0015
if len(trades) == 0 {
return &AverageCostPnlReport{
Symbol: symbol,
CurrentPrice: currentPrice,
NumTrades: 0,
BidVolume: bidVolume,
AskVolume: askVolume,
FeeUSD: feeUSD,
}
}
var currencyFees = map[string]float64{} var currencyFees = map[string]float64{}
for _, trade := range trades { for _, trade := range trades {