Beispiel #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);
        }
Beispiel #2
0
 public void SmartBuyout(BtcPrice btcPrice, Strategy strategy)
 {
     if (Convert.ToDouble(btcPrice.price_btc) <= strategy.Floor)
     {
         //
         _providers.BuyCoins(btcPrice.name, Convert.ToDouble(btcPrice.price_btc), strategy.BtcBag);
     }
 }
Beispiel #3
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);
        }
Beispiel #4
0
        public void SmartSell(BtcPrice btcPrice, Strategy strategy)
        {
            var trans           = _transactionDAO.GetTransaction();
            var btcCurrentPrice = Convert.ToDouble(btcPrice.price_btc);
            var btcSellPrice    = (btcCurrentPrice * strategy.Discount);

            if (btcSellPrice < trans.BoughtPrice)
            {
                btcSellPrice = btcCurrentPrice;
            }

            if (btcCurrentPrice <= (strategy.Profit * btcCurrentPrice))
            {
                //Venda
                _providers.SellCoins(btcPrice.name, btcSellPrice, trans.BuyAmmount);
            }
        }
Beispiel #5
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);
        }
Beispiel #6
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));
            }
        }
Beispiel #7
0
 public BtcPrice InsertCurrency(BtcPrice btcPrice)
 {
     return(new BtcPrice());
 }