public void ToCryptoOrder_Should_ConvertFromHistoricOrder() { var bittrexOrder = new BittrexOrderHistoryOrder { Exchange = "BTC-XLM", OrderType = OrderSideExtended.LimitBuy, Price = 0.001M, Quantity = 100, PricePerUnit = 0.0001M, Limit = 0.0001M, Commission = 0.00001M, Closed = DateTime.MaxValue, TimeStamp = DateTime.MinValue, OrderUuid = Guid.NewGuid(), QuantityRemaining = 0.002M, }; var order = bittrexOrder.ToCryptoOrder(); order.Market.Should().Be(bittrexOrder.Exchange); order.OrderType.Should().Be(CryptoOrderType.LimitBuy); order.Price.Should().Be(bittrexOrder.Price); order.Quantity.Should().Be(bittrexOrder.Quantity); order.QuantityRemaining.Should().Be(bittrexOrder.QuantityRemaining); order.PricePerUnit.Should().Be(bittrexOrder.PricePerUnit); order.Uuid.Should().Be(bittrexOrder.OrderUuid.ToString()); order.CommissionPaid.Should().Be(bittrexOrder.Commission); order.Limit.Should().Be(bittrexOrder.Limit); order.Opened.Should().Be(bittrexOrder.TimeStamp); order.IsClosed.Should().BeTrue(); order.Closed.Should().Be(bittrexOrder.Closed.GetValueOrDefault()); }
public static CryptoOrder ToCryptoOrder(this BittrexOrderHistoryOrder completedOrder) { return(new CryptoOrder { Market = completedOrder.Exchange, OrderType = completedOrder.OrderType == OrderSideExtended.LimitBuy ? CryptoOrderType.LimitBuy : CryptoOrderType.LimitSell, Price = completedOrder.Price.RoundSatoshi(), Quantity = completedOrder.Quantity.RoundSatoshi(), PricePerUnit = completedOrder.Limit.RoundSatoshi(), CommissionPaid = completedOrder.Commission.RoundSatoshi(), Uuid = completedOrder.OrderUuid.ToString(), Opened = completedOrder.TimeStamp, Closed = completedOrder.Closed.GetValueOrDefault(), Limit = completedOrder.Limit.RoundSatoshi(), QuantityRemaining = completedOrder.QuantityRemaining.RoundSatoshi(), IsClosed = true }); }