Skip to content

Commit 890025e

Browse files
authored
Poloniex ParseOrderTrades (#630)
Added null check when calculating average price.
1 parent ed59719 commit 890025e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ExchangeSharp/API/Exchanges/Poloniex/ExchangePoloniexAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public void ParseOrderTrades(IEnumerable<JToken> trades, ExchangeOrderResult ord
166166
decimal tradeAmt = trade["amount"].ConvertInvariant<decimal>();
167167
decimal tradeRate = trade["rate"].ConvertInvariant<decimal>();
168168

169-
order.AveragePrice = (order.AveragePrice * order.AmountFilled + tradeAmt * tradeRate) / (order.AmountFilled + tradeAmt);
169+
order.AveragePrice = (order.AveragePrice.GetValueOrDefault(decimal.Zero) * order.AmountFilled + tradeAmt * tradeRate) / (order.AmountFilled + tradeAmt);
170170
if (order.Amount == 0m)
171171
{
172172
order.Amount += tradeAmt;

0 commit comments

Comments
 (0)