public override object getResponseData()
        {
            InfDisplayInfoData        rc            = new InfDisplayInfoData();
            BogeyCounterData          bogey1        = new BogeyCounterData();
            BogeyCounterData          bogey2        = new BogeyCounterData();
            SignalStrengthData        signal        = new SignalStrengthData();
            BandAndArrowIndicatorData bandAndArrow1 = new BandAndArrowIndicatorData();
            BandAndArrowIndicatorData bandAndArrow2 = new BandAndArrowIndicatorData();
            AuxiliaryData             auxData       = new AuxiliaryData();

            bogey1.SetFromByte(payloadData[0]);
            bogey2.SetFromByte(payloadData[1]);
            signal.SetFromByte(payloadData[2]);
            bandAndArrow1.SetFromByte(payloadData[3]);
            bandAndArrow2.SetFromByte(payloadData[4]);
            auxData.SetFromByte(payloadData[5]);

            rc.Aux1Data = payloadData[6];
            rc.Aux2Data = payloadData[7];

            rc.BogeyCounterData1      = bogey1;
            rc.BogeyCounterData2      = bogey2;
            rc.SignalStrengthData     = signal;
            rc.BandAndArrowIndicator1 = bandAndArrow1;
            rc.BandAndArrowIndicator2 = bandAndArrow2;
            rc.AuxData = auxData;

            return(rc);
        }
Esempio n. 2
0
 /// <summary>
 /// Retrieves some auxiliary data previously set to this skeleton.
 /// </summary>
 /// <typeparam name="T">The type of the array, which should match the type passed in</typeparam>
 public T[] GetData <T>(string name)
 {
     if (!AuxiliaryData.ContainsKey(name))
     {
         return(null);
     }
     return((T[])AuxiliaryData[name].Data);
 }
Esempio n. 3
0
            public AuxiliaryData GetAuxData()
            {
                AuxiliaryData data = new AuxiliaryData();

                data.B_auxiliary_data_type = Type;
                data.B_auxiliary_data      = TableData.TableDataHelper.GetFileData(DisplayData);
                return(data);
            }
Esempio n. 4
0
        /// <summary>
        /// Check for dividends and emit them into the aux data queue
        /// </summary>
        private void CheckForSplit(DateTime date)
        {
            if (_splitFactor != null)
            {
                var close = GetRawClose();
                var split = new Split(_config.Symbol, date, close, _splitFactor.Value);
                AuxiliaryData.Enqueue(split);
                _splitFactor = null;
            }

            decimal splitFactor;

            if (_factorFile.HasSplitEventOnNextTradingDay(date, out splitFactor))
            {
                _splitFactor = splitFactor;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Check for dividends and emit them into the aux data queue
        /// </summary>
        private void CheckForDividend(DateTime date)
        {
            if (_priceFactorRatio != null)
            {
                var close    = GetRawClose();
                var dividend = new Dividend(_config.Symbol, date, close, _priceFactorRatio.Value);
                // let the config know about it for normalization
                _config.SumOfDividends += dividend.Distribution;
                AuxiliaryData.Enqueue(dividend);
                _priceFactorRatio = null;
            }

            // check the factor file to see if we have a dividend event tomorrow
            decimal priceFactorRatio;

            if (_factorFile.HasDividendEventOnNextTradingDay(date, out priceFactorRatio))
            {
                _priceFactorRatio = priceFactorRatio;
            }
        }
Esempio n. 6
0
        /********************************************************
         * CLASS METHODS
         *********************************************************/
        /// <summary>
        /// Try and create a new instance of the object and return it using the MoveNext enumeration pattern ("Current" public variable).
        /// </summary>
        /// <remarks>This is a highly called method and should be kept lean as possible.</remarks>
        /// <returns>Boolean true on successful move next. Set Current public property.</returns>
        public bool MoveNext()
        {
            // yield the aux data first
            if (AuxiliaryData.Count != 0)
            {
                Previous = Current;
                Current  = AuxiliaryData.Dequeue();
                return(true);
            }

            BaseData instance           = null;
            var      instanceMarketOpen = false;

            //Log.Debug("SubscriptionDataReader.MoveNext(): Starting MoveNext...");

            try
            {
                //Calls this when no file, first "moveNext()" in refresh source.
                if (_endOfStream || _reader == null || _reader.EndOfStream)
                {
                    if (_reader == null)
                    {
                        //Handle the 1% of time:: getReader failed e.g. missing day so skip day:
                        Current = null;
                    }
                    else
                    {
                        //This is a MoveNext() after reading the last line of file:
                        _lastBarOfStream = Current;
                    }
                    _endOfStream = true;
                    return(false);
                }

                //Log.Debug("SubscriptionDataReader.MoveNext(): Launching While-InstanceNotNull && not EOS: " + reader.EndOfStream);
                //Keep looking until output's an instance:
                while (instance == null && !_reader.EndOfStream)
                {
                    //Get the next string line from file, create instance of BaseData:
                    var line = _reader.ReadLine();
                    try
                    {
                        instance = _dataFactory.Reader(_config, line, _date, _feedEndpoint);
                    }
                    catch (Exception err)
                    {
                        //Log.Debug("SubscriptionDataReader.MoveNext(): Error invoking instance: " + err.Message);
                        Engine.ResultHandler.RuntimeError("Error invoking " + _config.Symbol + " data reader. Line: " + line + " Error: " + err.Message, err.StackTrace);
                        _endOfStream = true;
                        continue;
                    }

                    if (instance != null)
                    {
                        instanceMarketOpen = _security.Exchange.DateTimeIsOpen(instance.Time);

                        //Apply custom user data filters:
                        try
                        {
                            if (!_security.DataFilter.Filter(_security, instance))
                            {
                                instance = null;
                                continue;
                            }
                        }
                        catch (Exception err)
                        {
                            Log.Error("SubscriptionDataReader.MoveNext(): Error applying filter: " + err.Message);
                            Engine.ResultHandler.RuntimeError("Runtime error applying data filter. Assuming filter pass: "******"SubscriptionDataReader.MoveNext(): Instance null, continuing...");
                            continue;
                        }


                        //Check if we're in date range of the data request
                        if (instance.Time < _periodStart)
                        {
                            _lastBarOutsideMarketHours = instance;
                            instance = null;
                            continue;
                        }
                        if (instance.Time > _periodFinish)
                        {
                            instance = null;
                            continue;
                        }

                        //Save bar for extended market hours (fill forward).
                        if (!instanceMarketOpen)
                        {
                            _lastBarOutsideMarketHours = instance;
                        }

                        //However, if we only want market hours data, don't return yet: Discard and continue looping.
                        if (!_config.ExtendedMarketHours && !instanceMarketOpen)
                        {
                            instance = null;
                        }
                    }
                }

                //Handle edge conditions: First Bar Read:
                // -> Use previous bar from yesterday if available
                if (Current == null)
                {
                    //Handle first loop where not set yet:
                    if (_lastBarOfStream == null)
                    {
                        //For first bar, fill forward from premarket data where possible
                        _lastBarOfStream = _lastBarOutsideMarketHours ?? instance;
                    }
                    //If current not set yet, set Previous to yesterday/last bar read.
                    Previous = _lastBarOfStream;
                }
                else
                {
                    Previous = Current;
                }

                Current = instance;

                //End of Stream: rewind reader to last
                if (_reader.EndOfStream && instance == null)
                {
                    //Log.Debug("SubscriptionDataReader.MoveNext(): Reader EOS.");
                    _endOfStream = true;

                    if (_isFillForward && Previous != null)
                    {
                        //If instance == null, current is null, so clone previous to record the final sample:
                        Current = Previous.Clone(true);
                        //When market closes fastforward current bar to the last bar fill forwarded to close time.
                        Current.Time = _security.Exchange.TimeOfDayClosed(Previous.Time);
                        // Save the previous bar as last bar before next stream (for fill forwrd).
                        _lastBarOfStream = Previous;
                    }
                    return(false);
                }
                return(true);
            }
            catch (Exception err)
            {
                Log.Error("SubscriptionDataReader.MoveNext(): " + err.Message);
                return(false);
            }
        }