public static List <Trade> BinanceToTrades(IEnumerable <AccountTrade> response, string baseCurrency, string termsCurrency, ILogger logger) { var tradeList = new List <Trade>(); var completedOrders = response.ToList(); foreach (var completedOrder in completedOrders) { var trade = new Trade { Exchange = Constants.Binance, Base = baseCurrency, Terms = termsCurrency, Commission = completedOrder.Commission, ExchangeId = completedOrder.Id.ToString(), Limit = completedOrder.Price, Quantity = completedOrder.Quantity, QuantityRemaining = 0, Timestamp = completedOrder.Time(), Side = completedOrder.IsBuyer ? TradeSide.Buy : TradeSide.Sell }; trade.Cost = (completedOrder.Price * completedOrder.Quantity) * 0.999m; tradeList.Add(trade); } return(tradeList); }
public static List <Trade> PoloniexToTrades(IList <ITrade> trades) { var tradeList = new List <Trade>(); foreach (var completedOrder in trades) { var ccy = completedOrder.Pair.Split('_'); var trade = new Trade { Exchange = Constants.Poloniex, Side = completedOrder.Type == Jojatekok.PoloniexAPI.OrderType.Buy ? TradeSide.Buy : TradeSide.Sell, Base = ccy[0], Terms = ccy[1], ExchangeId = completedOrder.IdOrder.ToString(), Limit = Convert.ToDecimal(completedOrder.PricePerCoin), Timestamp = completedOrder.Time, }; var baseAmount = Convert.ToDecimal(completedOrder.AmountBase); if (trade.Side == TradeSide.Buy) { trade.Commission = Convert.ToDecimal((completedOrder.AmountQuote * 0.0025) * completedOrder.PricePerCoin); trade.Quantity = Convert.ToDecimal(completedOrder.AmountQuote - completedOrder.AmountQuote * 0.0025); trade.Cost = baseAmount; } else { trade.Commission = baseAmount * 0.0025m; trade.Quantity = Convert.ToDecimal(completedOrder.AmountQuote); trade.Cost = baseAmount - trade.Commission; } tradeList.Add(trade); } return(tradeList); }