private Order Convert(DSX.Order x, SymbolInformation si, IEnumerable <DSX.Deal> deals = null) { var orderPrice = x.rate; if (x.orderType == "market" && deals != null) { // calc. average price using deals. decimal totalQuote = 0m; foreach (var deal in deals) { totalQuote += deal.volume * deal.rate; } if (totalQuote > decimal.Zero) { orderPrice = totalQuote / (x.volume - x.remainingVolume); orderPrice = Math.Round(orderPrice, si.PriceDecimals); } } return(new Order(si) { Price = orderPrice, Quantity = x.volume, ExecutedQuantity = x.volume - x.remainingVolume, Side = x.type == "buy" ? TradeSide.Buy : TradeSide.Sell, Status = Code2OrderStatus(x.status), Created = x.timestampCreated.FromUnixSeconds(), Updated = x.timestampCreated.FromUnixSeconds(), Type = x.orderType, OrderId = x.id.ToString() }); }
private Order Convert(DSX.Order x) { var orderPrice = x.rate; SymbolInformation si = GetSymbolInformation(x.pair); return(new Order(si) { Price = orderPrice, Quantity = x.volume, ExecutedQuantity = x.volume - x.remainingVolume, Side = x.type == "buy" ? TradeSide.Buy : TradeSide.Sell, Status = Code2OrderStatus(x.status), Created = x.timestampCreated.FromUnixSeconds(), Updated = x.timestampCreated.FromUnixSeconds(), Type = x.orderType, OrderId = x.id.ToString() }); }