public void Update(BasicallyMe.RobinhoodNet.OrderSnapshot s) { if (s.AveragePrice.HasValue) { AveragePrice = (decimal)s.AveragePrice; } Quantity = s.Quantity; // Update the status UpdatedAt = s.UpdatedAt; RefreshedAt = DateTime.Now; switch (s.State) { case ("filled"): Status = OrderStatus.COMPLETE; break; case ("cancelled"): Status = OrderStatus.CANCELLED; break; case ("failed"): Status = OrderStatus.FAILED; break; } }
public RobinhoodOrder(string symbol, BasicallyMe.RobinhoodNet.OrderSnapshot s) { Dictionary <BasicallyMe.RobinhoodNet.OrderType, Broker.Order.OrderType> orderTypeLookup = new Dictionary <BasicallyMe.RobinhoodNet.OrderType, OrderType>() { { BasicallyMe.RobinhoodNet.OrderType.Market, Broker.Order.OrderType.MARKET }, { BasicallyMe.RobinhoodNet.OrderType.Limit, Broker.Order.OrderType.LIMIT }, { BasicallyMe.RobinhoodNet.OrderType.StopLoss, Broker.Order.OrderType.STOP }, }; OrderId = s.OrderId; Type = orderTypeLookup[s.Type]; BuySell = (s.Side == Side.Buy ? Broker.Order.BuySellType.BUY : Broker.Order.BuySellType.SELL); if ((Type == OrderType.STOP) && (s.StopPrice.HasValue)) { StopPrice = (decimal)s.StopPrice; } Symbol = symbol; Update(s); }