コード例 #1
0
        public void test_IsPositionSignalBothEmpty_Positive()
        {
            ISignalContext context = new SignalContext();

            context.CurrentMarketPosition = 0;
            Assert.AreEqual(true, context.isPositionSignalBothEmpty());
        }
コード例 #2
0
        private void enterTradeStrategy(Series <DateTime, MarketDataElement> series)
        {
            if (!execution.isPositionSignalBothEmpty())
            {
                return;
            }

            if (series == null)
            {
                return;
            }

            double tickClose = calculateMid();

            if (tickClose.Equals(double.NaN))
            {
                return;
            }

            Random rnd    = new Random();
            int    number = rnd.Next(0, 19);

            int residure = number % 10;
            int q        = number / 10;

            if (residure == 5)
            {
                if (q == 0)
                {
                    String reason = "[Strategy] : residure={0}; q={1}; tickClose={2}".Replace("{0}", residure.ToString()).Replace("{1}", q.ToString()).Replace("{2}", tickClose.ToString());
                    log.Info("[Strategy] : Buy Signal Generated!");
                    log.Info(reason);
                    log.Info("******************************************************************");
                    if (sentOrder)
                    {
                        stgHelper.placeMarketTrade(AppConstant.BUY_SIGNAL, "Random Rule", tickClose, "", orderSize, 1);
                        //stgHelper.placeEnterTrade(TSAppConstant.BUY_SIGNAL, "Random Rule", reason, tickClose, orderSize);
                    }
                }
                if (q == 1)
                {
                    String reason = "[Strategy] : residure={0}; q={1}; tickClose={2}".Replace("{0}", residure.ToString()).Replace("{1}", q.ToString()).Replace("{2}", tickClose.ToString());
                    log.Info("[Strategy] : Sell Signal Generated!");
                    log.Info(reason);
                    log.Info("******************************************************************");
                    if (sentOrder)
                    {
                        stgHelper.placeMarketTrade(AppConstant.SELL_SIGNAL, "Random Rule", tickClose, "", orderSize, 1);
                        //stgHelper.placeEnterTrade(TSAppConstant.SELL_SIGNAL, "Random Rule", reason, tickClose, orderSize);
                    }
                }
            }
        }
コード例 #3
0
        public void test_IsPositionSignalBothEmpty_Negative()
        {
            ISignalContext context = new SignalContext();

            context.CurrentMarketPosition = 1;
            Assert.AreEqual(false, context.isPositionSignalBothEmpty());

            context = new SignalContext();
            context.CurrentMarketPosition = 0;
            context.setPendingSignal1(AppConstant.BUY_SIGNAL, 20000, createOrder_Buy1Contract_0Complete(), "Buy Order");
            Assert.AreEqual(false, context.isPositionSignalBothEmpty());
        }