Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
ccxtExchange should correctly populate cost of trade, closes #344
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilsaraf committed Jan 18, 2020
1 parent 8f3e5fc commit db4531d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions plugins/ccxtExchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package plugins
import (
"fmt"
"log"
"math"
"sort"
"strconv"
"time"
Expand Down Expand Up @@ -311,7 +310,7 @@ func (c ccxtExchange) readTrade(pair *model.TradingPair, pairString string, rawT
Timestamp: model.MakeTimestamp(rawTrade.Timestamp),
},
TransactionID: model.MakeTransactionID(rawTrade.ID),
Cost: model.NumberFromFloat(rawTrade.Cost, int8(math.Max(float64(pricePrecision), float64(volumePrecision)))),
Cost: model.NumberFromFloat(rawTrade.Cost, feecCostPrecision),
Fee: model.NumberFromFloat(rawTrade.Fee.Cost, feecCostPrecision),
}

Expand All @@ -323,8 +322,8 @@ func (c ccxtExchange) readTrade(pair *model.TradingPair, pairString string, rawT
return nil, fmt.Errorf("unrecognized value for 'side' field: %s", rawTrade.Side)
}

if rawTrade.Cost != 0.0 {
trade.Cost = model.NumberFromFloat(rawTrade.Cost, feecCostPrecision)
if rawTrade.Cost == 0.0 {
trade.Cost = model.NumberFromFloat(rawTrade.Price*rawTrade.Amount, feecCostPrecision)
}

return &trade, nil
Expand Down

0 comments on commit db4531d

Please sign in to comment.