public void PerformsStopMarketFillSell() { var model = new EquityTransactionModel(); var order = new StopMarketOrder(Symbols.SPY, -100, 101.5m, Noon); var config = CreateTradeBarConfig(); var security = new Security( SecurityExchangeHoursTests.CreateUsEquitySecurityExchangeHours(), config, new Cash(CashBook.AccountCurrency, 0, 1m), SymbolProperties.GetDefault(CashBook.AccountCurrency), ErrorCurrencyConverter.Instance ); security.SetLocalTimeKeeper(TimeKeeper.GetLocalTimeKeeper(TimeZones.NewYork)); security.SetMarketPrice(new IndicatorDataPoint(Symbols.SPY, Noon, 102m)); var fill = model.StopMarketFill(security, order); Assert.AreEqual(0, fill.FillQuantity); Assert.AreEqual(0, fill.FillPrice); Assert.AreEqual(OrderStatus.None, fill.Status); security.SetMarketPrice(new IndicatorDataPoint(Symbols.SPY, Noon, 101m)); fill = model.StopMarketFill(security, order); // this fills worst case scenario, so it's min of asset/stop price Assert.AreEqual(order.Quantity, fill.FillQuantity); Assert.AreEqual(Math.Min(security.Price, order.StopPrice), fill.FillPrice); Assert.AreEqual(OrderStatus.Filled, fill.Status); }
public void PerformsStopMarketFillSell() { var model = new EquityTransactionModel(); var order = new StopMarketOrder(Symbol, -100, 101.5m, Noon, type: SecurityType.Equity); var config = CreateTradeBarConfig(Symbol); var security = new Security(SecurityExchangeHoursTests.CreateUsEquitySecurityExchangeHours(), config, 1); security.SetLocalTimeKeeper(TimeKeeper.GetLocalTimeKeeper(TimeZones.NewYork)); security.SetMarketPrice(new IndicatorDataPoint(Symbol, Noon, 102m)); var fill = model.StopMarketFill(security, order); Assert.AreEqual(0, fill.FillQuantity); Assert.AreEqual(0, fill.FillPrice); Assert.AreEqual(OrderStatus.None, fill.Status); Assert.AreEqual(OrderStatus.None, order.Status); security.SetMarketPrice(new IndicatorDataPoint(Symbol, Noon, 101m)); fill = model.StopMarketFill(security, order); // this fills worst case scenario, so it's min of asset/stop price Assert.AreEqual(order.Quantity, fill.FillQuantity); Assert.AreEqual(Math.Min(security.Price, order.StopPrice), fill.FillPrice); Assert.AreEqual(OrderStatus.Filled, fill.Status); Assert.AreEqual(OrderStatus.Filled, order.Status); }
public void PerformsStopMarketFillSell() { var model = new EquityTransactionModel(); var order = new StopMarketOrder(Symbol, -100, 101.5m, DateTime.Now, type: SecurityType.Equity); var config = new SubscriptionDataConfig(typeof(TradeBar), SecurityType.Equity, Symbol, Resolution.Minute, true, true, true, true, false, 0); var security = new Security(config, 1); security.SetMarketPrice(DateTime.Now, new IndicatorDataPoint(Symbol, DateTime.Now, 102m)); var fill = model.StopMarketFill(security, order); Assert.AreEqual(0, fill.FillQuantity); Assert.AreEqual(0, fill.FillPrice); Assert.AreEqual(OrderStatus.None, fill.Status); Assert.AreEqual(OrderStatus.None, order.Status); security.SetMarketPrice(DateTime.Now, new IndicatorDataPoint(Symbol, DateTime.Now, 101m)); fill = model.StopMarketFill(security, order); // this fills worst case scenario, so it's min of asset/stop price Assert.AreEqual(order.Quantity, fill.FillQuantity); Assert.AreEqual(Math.Min(security.Price, order.StopPrice), fill.FillPrice); Assert.AreEqual(OrderStatus.Filled, fill.Status); Assert.AreEqual(OrderStatus.Filled, order.Status); }
public void PerformsStopMarketFillSell() { var model = new EquityTransactionModel(); var order = new StopMarketOrder(Symbol, -100, 101.5m, Noon, type: SecurityType.Equity); var config = CreateTradeBarConfig(Symbol); var security = new Security(SecurityExchangeHoursTests.CreateUsEquitySecurityExchangeHours(), config, 1); security.SetMarketPrice(Noon, new IndicatorDataPoint(Symbol, Noon, 102m)); var fill = model.StopMarketFill(security, order); Assert.AreEqual(0, fill.FillQuantity); Assert.AreEqual(0, fill.FillPrice); Assert.AreEqual(OrderStatus.None, fill.Status); Assert.AreEqual(OrderStatus.None, order.Status); security.SetMarketPrice(Noon, new IndicatorDataPoint(Symbol, Noon, 101m)); fill = model.StopMarketFill(security, order); // this fills worst case scenario, so it's min of asset/stop price Assert.AreEqual(order.Quantity, fill.FillQuantity); Assert.AreEqual(Math.Min(security.Price, order.StopPrice), fill.FillPrice); Assert.AreEqual(OrderStatus.Filled, fill.Status); Assert.AreEqual(OrderStatus.Filled, order.Status); }
public void PerformsStopMarketFillSell() { var model = new EquityTransactionModel(); var order = new StopMarketOrder(Symbols.SPY, -100, 101.5m, Noon); var config = CreateTradeBarConfig(); var security = new Security(SecurityExchangeHoursTests.CreateUsEquitySecurityExchangeHours(), config, new Cash(CashBook.AccountCurrency, 0, 1m), SymbolProperties.GetDefault(CashBook.AccountCurrency)); security.SetLocalTimeKeeper(TimeKeeper.GetLocalTimeKeeper(TimeZones.NewYork)); security.SetMarketPrice(new IndicatorDataPoint(Symbols.SPY, Noon, 102m)); var fill = model.StopMarketFill(security, order); Assert.AreEqual(0, fill.FillQuantity); Assert.AreEqual(0, fill.FillPrice); Assert.AreEqual(OrderStatus.None, fill.Status); security.SetMarketPrice(new IndicatorDataPoint(Symbols.SPY, Noon, 101m)); fill = model.StopMarketFill(security, order); // this fills worst case scenario, so it's min of asset/stop price Assert.AreEqual(order.Quantity, fill.FillQuantity); Assert.AreEqual(Math.Min(security.Price, order.StopPrice), fill.FillPrice); Assert.AreEqual(OrderStatus.Filled, fill.Status); }
public void PerformsStopMarketFillSell() { var model = new EquityTransactionModel(); var order = new StopMarketOrder(Symbol, -100, 101.5m, DateTime.Now, type: SecurityType.Equity); var config = new SubscriptionDataConfig(typeof(TradeBar), SecurityType.Equity, Symbol, Resolution.Minute, true, true, true, true, false, 0); var security = new Security(config, 1); security.SetMarketPrice(DateTime.Now, new IndicatorDataPoint(Symbol, DateTime.Now, 102m)); var fill = model.StopMarketFill(security, order); Assert.AreEqual(0, fill.FillQuantity); Assert.AreEqual(0, fill.FillPrice); Assert.AreEqual(OrderStatus.None, fill.Status); Assert.AreEqual(OrderStatus.None, order.Status); security.SetMarketPrice(DateTime.Now, new IndicatorDataPoint(Symbol, DateTime.Now, 101m)); fill = model.StopMarketFill(security, order); // this fills worst case scenario, so it's min of asset/stop price Assert.AreEqual(order.Quantity, fill.FillQuantity); Assert.AreEqual(Math.Min(security.Price, order.StopPrice), fill.FillPrice); Assert.AreEqual(OrderStatus.Filled, fill.Status); Assert.AreEqual(OrderStatus.Filled, order.Status); }