Exemple #1
0
        public override void calculate_signals_impl(Object sender, MarketDataEventArgs args)
        {
            AppEvent appEvent = eventManager.storeEventQueue[stgName].Take();
            var      watch    = Stopwatch.StartNew();

            if (appEvent.Type.Equals(AppEventType.TickerPrice))
            {
                AppTickPriceEvent tickPriceEvent = (AppTickPriceEvent)appEvent;
                updateTick(tickPriceEvent);
            }
            else if (appEvent.Type.Equals(AppEventType.DailyReset))
            {
                stgDailyReset();
                return;
            }
            else
            {
                return;
            }

            if (!MDManager.isDataReady())
            {
                return;
            }

            if (!dataIsReady)
            {
                log.Info("Data is Ready.");
            }
            dataIsReady = true;
            Series <DateTime, MarketDataElement> seriesSelected = MDManager.getTimeBarSeries();

            cacluateRanges();
            calculateCurrentMax(seriesSelected);
            checkStgExitOrderCompleted(seriesSelected);
            checkStgEnterOrderCompleted(seriesSelected);
            exitTradeStrategy(seriesSelected);
            dayEndCloseTrade(seriesSelected);
            enterTradeStrategy(seriesSelected);
            watch.Stop();
            double ticks = watch.ElapsedTicks;

            log.Info("[Strategy] calculate_signals_impl running for = " + watch.ElapsedTicks * 1000000 / Stopwatch.Frequency + " micro second");
        }
Exemple #2
0
        public override void calculate_signals_impl(Object sender, MarketDataEventArgs args)
        {
            try
            {
                AppEvent appEvent = eventManager.storeEventQueue[stgName].Take();
                var      watch    = Stopwatch.StartNew();
                if (appEvent.Type.Equals(AppEventType.TickerPrice))
                {
                    AppTickPriceEvent tickPriceEvent = (AppTickPriceEvent)appEvent;
                    updateTick(tickPriceEvent);
                }
                else
                {
                    return;
                }

                //updateTick(tick);
                if (!MDManager.isDataReady())
                {
                    return;
                }
                if (!dataIsReady)
                {
                    log.Info("Data is Ready.");
                }
                dataIsReady = true;

                series1 = MDManager.getTimeBarSeries();
                checkStgEnterOrderCompleted(series1);
                checkStgExitOrderCompleted(series1);
                cutLossTrade(series1);
                exitTradeStrategy(series1);
                enterTradeStrategy(series1);
                // log.Info("[Strategy] day end close running for = " + watch.ElapsedMilliseconds + " millsecond");
                watch.Stop();
                double ticks = watch.ElapsedTicks;
                log.Info("[Strategy] calculate_signals_impl running for = " + watch.ElapsedTicks * 1000000 / Stopwatch.Frequency + " micro second");
            }
            catch (InvalidOperationException e)
            {
                return;
            }
        }
Exemple #3
0
        public override void calculate_signals_impl(Object sender, MarketDataEventArgs args)
        {
            AppEvent appEvent = eventManager.storeEventQueue[stgName].Take();

            if (appEvent.Type.Equals(AppEventType.TickerPrice))
            {
                AppTickPriceEvent tickPriceEvent = (AppTickPriceEvent)appEvent;
                updateTick(tickPriceEvent);
            }
            else if (appEvent.Type.Equals(AppEventType.DailyReset))
            {
                stgDailyReset();
                return;
            }
            else
            {
                return;
            }

            if (!MDManager.isDataReady())
            {
                return;
            }

            if (!dataIsReady)
            {
                log.Info("Data is Ready.");
            }
            dataIsReady = true;
            Series <DateTime, MarketDataElement> seriesSelected = MDManager.getTimeBarSeries();

            calculateExtreme(seriesSelected);
            cancelInvalidSignalOrder();
            cacluateRanges();
            calculateCurrentMax(seriesSelected);
            checkStgExitOrderCompleted(seriesSelected);
            checkStgEnterOrderCompleted(seriesSelected);
            exitTradeStrategy(seriesSelected);
            dayEndCloseTrade(seriesSelected);
            enterTradeStrategy(seriesSelected);
        }
        public override void calculate_signals_impl(Object sender, MarketDataEventArgs args)
        {
            try
            {
                AppEvent appEvent = eventManager.storeEventQueue[stgName].Take();
                if (appEvent.Type.Equals(AppEventType.TickerPrice))
                {
                    AppTickPriceEvent tickPriceEvent = (AppTickPriceEvent)appEvent;
                    updateTick(tickPriceEvent);
                }
                else
                {
                    return;
                }

                //updateTick(tick);
                if (!MDManager.isDataReady())
                {
                    return;
                }
                if (!dataIsReady)
                {
                    log.Info("Data is Ready.");
                }
                dataIsReady = true;
                series1     = MDManager.getTimeBarSeries();
                checkStgEnterOrderCompleted(series1);
                checkStgExitOrderCompleted(series1);
                cutLossTrade(series1);
                exitTradeStrategy(series1);
                enterTradeStrategy(series1);
            }
            catch (InvalidOperationException e)
            {
                return;
            }
        }