public static Trade AddSignalAndItsOrderAndTrade(this IDataContext context, Signal signal, double price, double amount) { Order order = context.AddSignalAndItsOrder(signal); if (order == null) { return(null); } order.FilledAmount += amount; order.DeliveryDate = order.DateTime.AddSeconds(1); Trade trade = new Trade(order, order.Portfolio, order.Symbol, price, order.TradeAction == TradeAction.Buy ? amount : -amount, order.DateTime); context.Get <ObservableHashSet <Trade> >().Add(trade); return(trade); }