fix(pnl): do not calculate the "self" trade

This commit is contained in:
Jui-Nan Lin 2021-02-06 17:34:13 +08:00
parent 30f085fa91
commit b38b65ce83

View File

@ -37,7 +37,7 @@ func (c *AverageCostCalculator) Calculate(symbol string, trades []types.Trade, c
for _, trade := range trades {
if trade.Symbol == symbol {
if trade.Side == types.SideTypeBuy {
if trade.IsBuyer && trade.Side != types.SideTypeSelf {
bidVolume += trade.Quantity
bidAmount += trade.Price * trade.Quantity
}
@ -76,7 +76,7 @@ func (c *AverageCostCalculator) Calculate(symbol string, trades []types.Trade, c
continue
}
if t.Side == types.SideTypeBuy {
if t.IsBuyer || t.Side == types.SideTypeSelf {
continue
}