Exemple #1
0
        /// <summary>
        /// Trying to find if current Cape is the lowest Cape in three months to indicate selling period
        /// </summary>
        public void OnData(CAPE data)
        {
            newLow = false;
            //Adds first four Cape Ratios to array c
            currCape = data.Cape;
            if (counter < 4)
            {
                c[counter++] = currCape;
            }
            //Replaces oldest Cape with current Cape
            //Checks to see if current Cape is lowest in the previous quarter
            //Indicating a sell off
            else
            {
                Array.Copy(c, cCopy, 4);
                Array.Sort(cCopy);
                if (cCopy[0] > currCape)
                {
                    newLow = true;
                }
                c[counter2++] = currCape;
                if (counter2 == 4)
                {
                    counter2 = 0;
                }
            }

            Debug("Current Cape: " + currCape + " on " + data.Time);
            if (newLow)
            {
                Debug("New Low has been hit on " + data.Time);
            }
        }
Exemple #2
0
        /// <summary>
        /// Reader Method :: using set of arguements we specify read out type. Enumerate
        /// until the end of the data stream or file. E.g. Read CSV file line by line and convert
        /// into data types.
        /// </summary>
        /// <returns>BaseData type set by Subscription Method.</returns>
        /// <param name="config">Config.</param>
        /// <param name="line">Line.</param>
        /// <param name="date">Date.</param>
        /// <param name="isLiveMode">true if we're in live mode, false for backtesting mode</param>
        public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode)
        {
            var index = new CAPE();

            try
            {
                //Example File Format:
                //Date   |  Price |  Div  | Earning | CPI  | FractionalDate | Interest Rate | RealPrice | RealDiv | RealEarnings | CAPE
                //2014.06  1947.09  37.38   103.12   238.343    2014.37          2.6           1923.95     36.94        101.89     25.55
                string[] data = line.Split(',');
                //Dates must be in the format YYYY-MM-DD. If your data source does not have this format, you must use
                //DateTime.ParseExact() and explicit declare the format your data source has.
                string dateString = data[0];
                index.Time   = DateTime.ParseExact(dateString, format, provider);
                index.Cape   = Convert.ToDecimal(data[10], CultureInfo.InvariantCulture);
                index.Symbol = "CAPE";
                index.Value  = index.Cape;
            }
            catch
            {
            }
            return(index);
        }
Exemple #3
0
        /// <summary>
        /// Trying to find if current Cape is the lowest Cape in three months to indicate selling period
        /// </summary>
        public void OnData(CAPE data)
        {
            newLow = false;
            //Adds first four Cape Ratios to array c
            currCape = data.Cape;
            if (counter < 4)
            {
                c[counter++] = currCape;
            }
            //Replaces oldest Cape with current Cape
            //Checks to see if current Cape is lowest in the previous quarter
            //Indicating a sell off 
            else
            {
                Array.Copy(c, cCopy, 4);
                Array.Sort(cCopy);
                if (cCopy[0] > currCape) newLow = true;
                c[counter2++] = currCape;
                if (counter2 == 4) counter2 = 0;
            }

            Debug("Current Cape: " + currCape + " on " + data.Time);
            if (newLow) Debug("New Low has been hit on " + data.Time);
        }
Exemple #4
0
        /// <summary>
        /// Reader Method :: using set of arguements we specify read out type. Enumerate
        /// until the end of the data stream or file. E.g. Read CSV file line by line and convert
        /// into data types.
        /// </summary>
        /// <returns>BaseData type set by Subscription Method.</returns>
        /// <param name="config">Config.</param>
        /// <param name="line">Line.</param>
        /// <param name="date">Date.</param>
        /// <param name="isLiveMode">true if we're in live mode, false for backtesting mode</param>
        public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode)
        {
            var index = new CAPE();

            try
            {
                //Example File Format:
                //Date   |  Price |  Div  | Earning | CPI  | FractionalDate | Interest Rate | RealPrice | RealDiv | RealEarnings | CAPE 
                //2014.06  1947.09  37.38   103.12   238.343    2014.37          2.6           1923.95     36.94        101.89     25.55
                string[] data = line.Split(',');
                //Dates must be in the format YYYY-MM-DD. If your data source does not have this format, you must use
                //DateTime.ParseExact() and explicit declare the format your data source has.
                string dateString = data[0];
                index.Time = DateTime.ParseExact(dateString, format, provider);
                index.Cape = Convert.ToDecimal(data[10], CultureInfo.InvariantCulture);
                index.Symbol = "CAPE";
                index.Value = index.Cape;
            }
            catch
            {

            }
            return index;
        }