Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        public JsonResult SetBtcCurPrice(decimal price)
        {
            try
            {
                if (BtcPrice.IsAutoUpdateBtcPrice)
                {
                    return(Json(new OperationResult {
                        Desc = "当前不允许手动设置", ResultCode = -2
                    }, JsonRequestBehavior.AllowGet));
                }
                BtcPrice.SetPrice(price);
                return(Json(new OperationResult {
                    Desc = "成功", ResultCode = (int)BtcPrice.Current
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                Singleton <TextLog> .Instance.Error(e);

                return(Json(new OperationResult {
                    ResultCode = -1, Desc = e.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }