public void fuse_max() { BtcPrice.SetPrice(2000); Contract c = new Contract { Id = 1, Name = "1", Code = "1", ExcutePrice = 2100, ContractType = ContractType.期权, OptionType = OptionType.认购期权 }; ContractFuse cf = new ContractFuse(c); cf.Handle(new Deal { Price = 300 }); Assert.AreEqual(600, cf.MaxPrice); Assert.AreEqual(150, cf.MinPrice); Assert.AreEqual(false, cf.IsFusing); cf.Handle(new Deal { Price = 700 }); Assert.AreEqual(true, cf.IsFusing); Order o1 = new Order { Price = 700, Direction = TradeDirectType.卖, OrderType = OrderType.开仓 }; var r1 = cf.ShouldAccept(o1); Assert.AreEqual(true, r1); Order o2 = new Order { Price = 70, Direction = TradeDirectType.卖, OrderType = OrderType.开仓 }; var r2 = cf.ShouldAccept(o2); Assert.AreEqual(false, r2); Order o3 = new Order { Price = 700, Direction = TradeDirectType.买, OrderType = OrderType.开仓 }; var r3 = cf.ShouldAccept(o3); Assert.AreEqual(false, r3); Order o4 = new Order { Price = 70, Direction = TradeDirectType.买, OrderType = OrderType.开仓 }; var r4 = cf.ShouldAccept(o4); Assert.AreEqual(true, r4); }
public void accept_max_test_2() { BtcPrice.SetPrice(2000); Contract c = new Contract { Id = 1, Name = "1", Code = "1", ExcutePrice = 2100, ContractType = ContractType.期权, OptionType = OptionType.认购期权 }; ContractFuse cf = new ContractFuse(c); cf.Handle(new Deal { Price = 300 }); Order o = new Order { Price = 70, Direction = TradeDirectType.买, OrderType = OrderType.开仓 }; var r = cf.ShouldAccept(o); Assert.AreEqual(true, r); }
public void handle_deal_test() { BtcPrice.SetPrice(2000); Contract c = new Contract { Id = 1, Name = "1", Code = "1", ExcutePrice = 2100, ContractType = ContractType.期权, OptionType = OptionType.认购期权 }; ContractFuse cf = new ContractFuse(c); cf.Handle(new Deal { Price = 300 }); Assert.AreEqual(600, cf.MaxPrice); Assert.AreEqual(150, cf.MinPrice); Assert.AreEqual(false, cf.IsFusing); }