public static HydroTimeSeries GetMissingValuesHydro(ITimeSeries ts, DateTime start, DateTime end, TimeStep step)
        {
            HydroTimeSeries missingTs = new HydroTimeSeries(start, end);
            List<int> breakIx = GetDataBreaks(ts);

            //TODO missing points before series start
            foreach (int begIndex in breakIx)
            {
                if (begIndex < ts.Count - 1)
                {
                    DateTime begDate = DateTime.FromOADate(ts[begIndex].X);
                    DateTime endDate = DateTime.FromOADate(ts[begIndex + 1].X);
                    if (step == TimeStep.Day)
                    {
                        int nd = (int)endDate.Subtract(begDate).TotalDays;
                        for (int i = 0; i < nd; i++)
                        {
                            DateTime newTime = begDate.AddDays(i);
                            missingTs.AddUnknownValue(newTime);
                        }
                    }
                    else
                    {
                        int nh = (int)endDate.Subtract(begDate).TotalHours;
                        for (int i = 0; i < nh; i++)
                        {
                            DateTime newTime = begDate.AddHours(i);
                            missingTs.AddUnknownValue(newTime);
                        }
                    }
                }
            }
            return missingTs;
        }
 /// <summary>
 /// Fills the data gaps inside the time-series by setting them to 'no data' vals
 /// </summary>
 /// <param name="ts"></param>
 public static ITimeSeries FillDataGaps(ITimeSeries ts, TimeStep step)
 {
     ITimeSeries myTs = MakeRegularTimeSeries(ts.Start, ts.End, step);
     if (step == TimeStep.Day)
     {
         double tStart = myTs[0].X;
         for (int i = 0; i < ts.Count - 1; i++)
         {
             double index = (ts[i].X - tStart);
             int ix = (int)index;
             myTs[ix].Y = ts[i].Y;
         }
     }
     else
     {
         double tStart = myTs[0].X * 24;
         for (int i = 0; i < ts.Count - 1; i++)
         {
             double index = (ts[i].X * 24 - tStart);
             int ix = (int)index;
             myTs[ix].Y = ts[i].Y;
         }
     }
     return myTs;
 }
示例#3
0
    public bool SetValues(ITimeSeries series_, int yAxisExtent_=40)
    {
      lcdInstrumentHistory.ClearSeries();
      if (series_ == null || series_.Series == null) return false;

      addSeries(series_, yAxisExtent_);

      return true;
    }
示例#4
0
 public void SetValues(ITimeSeries series_, TimePeriod initialPeriod_ = TimePeriod.None)
 {
   if (series_ == null) return;
   m_allValues = new[] {series_};
   lblTitle.Text = series_.Name;
   if (initialPeriod_ != TimePeriod.None)
     periodButtons1.SetPeriod(initialPeriod_,true);
   else
     apply();
 }
示例#5
0
        override public void Run()
        {
            //---------- initialization

            // set simulation time frame
            StartTime = DateTime.Parse("01/01/2015", CultureInfo.InvariantCulture);
            EndTime   = DateTime.Parse("12/31/2016", CultureInfo.InvariantCulture);

            // add instruments
            AddDataSource(_instrumentNick);

            //---------- simulation

            foreach (DateTime simTime in SimTimes)
            {
                // find our instrument. if we have only one instrument,
                // we could also just use Instruments.Values.First()
                Instrument instrument = FindInstrument(_instrumentNick);

                // calculate simple indicators
                // the output of an indicator is a time series
                ITimeSeries <double> ema26 = instrument.Close.EMA(26);
                ITimeSeries <double> ema12 = instrument.Close.EMA(12);

                // therefore, indicators can be calculated on top of indicators
                ITimeSeries <double> macd   = ema12.Subtract(ema26);
                ITimeSeries <double> signal = macd.EMA(9);

                // plot our data
                _plotter.SelectChart("indicators vs time", "date");
                _plotter.SetX(simTime.Date);
                _plotter.Plot(instrument.Symbol, instrument.Close[0] + _offsetPrice);
                _plotter.Plot("ema26", ema26[0] + _offsetPrice);
                _plotter.Plot("ema12", ema12[0] + _offsetPrice);
                _plotter.Plot("macd", macd[0]);
                _plotter.Plot("signal", signal[0]);
            }
        }
示例#6
0
        public void Test_Lambda()
        {
            double[,] testVectors =
            {
                { 100.00000, 100.00000, 101.00000, 102.00000, 103.00000, },
                { 105.00000, 105.00000, 106.00000, 107.00000, 108.00000, },
                { 102.50000, 102.50000, 103.50000, 104.50000, 105.50000, },
                { 107.50000, 107.50000, 108.50000, 109.50000, 110.50000, },
                { 105.00000, 105.00000, 106.00000, 107.00000, 108.00000, },
                { 110.00000, 110.00000, 111.00000, 112.00000, 113.00000, },
                { 107.50000, 107.50000, 108.50000, 109.50000, 110.50000, },
                { 112.50000, 112.50000, 113.50000, 114.50000, 115.50000, },
                { 110.00000, 110.00000, 111.00000, 112.00000, 113.00000, },
                { 115.00000, 115.00000, 116.00000, 117.00000, 118.00000, },
            };

            TimeSeries <double> stimulus = new TimeSeries <double>();

            for (int row = 0; row <= testVectors.GetUpperBound(0); row++)
            {
                stimulus.Value = testVectors[row, 0];
                ITimeSeries <double> response =
                    TuringTrader.Indicators.IndicatorsBasic.Lambda(
                        (t) => t + stimulus[0]);
                //Output.Write("{{ {0:F5}, ", testVectors[row, 0]);

                for (int col = 1; col <= testVectors.GetUpperBound(1); col++)
                {
                    int    t             = col - 1;
                    double responseValue = response[t];
                    double expectedValue = testVectors[row, col];
                    //Output.Write("{0:F5}, ", responseValue);

                    Assert.IsTrue(Math.Abs(responseValue - expectedValue) < 1e-5);
                }
                //Output.WriteLine("},");
            }
        }
示例#7
0
        public void setUp()
        {
            List <IBar> bars = new List <IBar>();

            // open, close, high, low
            bars.Add(new MockBar(44.98M, 45.05M, 45.17M, 44.96M));
            bars.Add(new MockBar(45.05M, 45.10M, 45.15M, 44.99M));
            bars.Add(new MockBar(45.11M, 45.19M, 45.32M, 45.11M));
            bars.Add(new MockBar(45.19M, 45.14M, 45.25M, 45.04M));
            bars.Add(new MockBar(45.12M, 45.15M, 45.20M, 45.10M));
            bars.Add(new MockBar(45.15M, 45.14M, 45.20M, 45.10M));
            bars.Add(new MockBar(45.13M, 45.10M, 45.16M, 45.07M));
            bars.Add(new MockBar(45.12M, 45.15M, 45.22M, 45.10M));
            bars.Add(new MockBar(45.15M, 45.22M, 45.27M, 45.14M));
            bars.Add(new MockBar(45.24M, 45.43M, 45.45M, 45.20M));
            bars.Add(new MockBar(45.43M, 45.44M, 45.50M, 45.39M));
            bars.Add(new MockBar(45.43M, 45.55M, 45.60M, 45.35M));
            bars.Add(new MockBar(45.58M, 45.55M, 45.61M, 45.39M));
            bars.Add(new MockBar(45.45M, 45.01M, 45.55M, 44.80M));
            bars.Add(new MockBar(45.03M, 44.23M, 45.04M, 44.17M));

            data = new BaseTimeSeries(bars);
        }
示例#8
0
        /**
         * Calculates the profit of a trade (Buy and sell).
         * @param series a time series
         * @param trade a trade
         * @return the profit of the trade
         */
        private decimal CalculateProfit(ITimeSeries series, Trade trade)
        {
            decimal profit = Decimals.ONE;

            if (trade.IsClosed())
            {
                // use price of entry/exit order, if NaN use close price of underlying time series
                decimal exitClosePrice = trade.GetExit().getPrice().IsNaN() ?
                                         series.GetBar(trade.GetExit().getIndex()).ClosePrice : trade.GetExit().getPrice();
                decimal entryClosePrice = trade.GetEntry().getPrice().IsNaN() ?
                                          series.GetBar(trade.GetEntry().getIndex()).ClosePrice : trade.GetEntry().getPrice();

                if (trade.GetEntry().isBuy())
                {
                    profit = exitClosePrice.DividedBy(entryClosePrice);
                }
                else
                {
                    profit = entryClosePrice.DividedBy(exitClosePrice);
                }
            }
            return(profit);
        }
示例#9
0
        /// <summary>
        /// Calculate Relative Strength Index, as described here:
        /// <see href="https://en.wikipedia.org/wiki/Relative_strength_index"/>
        /// </summary>
        /// <param name="series">input time series</param>
        /// <param name="n">smoothing period</param>
        /// <param name="parentId">caller cache id, optional</param>
        /// <param name="memberName">caller's member name, optional</param>
        /// <param name="lineNumber">caller line number, optional</param>
        /// <returns>RSI time series</returns>
        public static ITimeSeries <double> RSI(this ITimeSeries <double> series, int n = 14,
                                               CacheId parentId = null, [CallerMemberName] string memberName = "", [CallerLineNumber] int lineNumber = 0)
        {
            var cacheId = new CacheId(parentId, memberName, lineNumber,
                                      series.GetHashCode(), n);

            ITimeSeries <double> returns = series.Return(cacheId);

            double avgUp = returns
                           .Max(0.0, cacheId)
                           .EMA(n, cacheId)[0];

            double avgDown = -returns
                             .Min(0.0, cacheId)
                             .EMA(n, cacheId)[0];

            double rs = avgUp / Math.Max(1e-10, avgDown);

            return(IndicatorsBasic.BufferedLambda(
                       v => 100.0 - 100.0 / (1 + rs),
                       50.0,
                       cacheId));
        }
示例#10
0
        /// <summary>
        /// Calculate True Strength Index of input time series, as described here:
        /// <see href="https://en.wikipedia.org/wiki/True_strength_index"/>
        /// </summary>
        /// <param name="series">input time series</param>
        /// <param name="r">smoothing period for momentum</param>
        /// <param name="s">smoothing period for smoothed momentum</param>
        /// <param name="parentId">caller cache id, optional</param>
        /// <param name="memberName">caller's member name, optional</param>
        /// <param name="lineNumber">caller line number, optional</param>
        /// <returns>TSI time series</returns>
        public static ITimeSeries <double> TSI(this ITimeSeries <double> series, int r = 25, int s           = 13,
                                               CacheId parentId = null, [CallerMemberName] string memberName = "", [CallerLineNumber] int lineNumber = 0)
        {
            var cacheId = new CacheId(parentId, memberName, lineNumber,
                                      series.GetHashCode(), r, s);

            ITimeSeries <double> momentum = series
                                            .Return(cacheId);

            double numerator = momentum
                               .EMA(r, cacheId)
                               .EMA(s, cacheId)[0];

            double denominator = momentum
                                 .AbsValue(cacheId)
                                 .EMA(r, cacheId)
                                 .EMA(s, cacheId)[0];

            return(IndicatorsBasic.BufferedLambda(
                       v => 100.0 * numerator / Math.Max(1e-10, denominator),
                       0.5,
                       cacheId));
        }
示例#11
0
        private void MapToEquidistantTimeSeries <T>(ITimeSeries <T> series, KeyValuePair <DateTime, T> valueToMap) where T : struct
        {
            if (valueToMap.Key.ToUniversalTime() < series.Span.Begin.ToUniversalTime() || valueToMap.Key.ToUniversalTime() > series.Span.End.ToUniversalTime())
            {
                return;
            }

            int findBestIndex()
            {
                var indexDouble = (valueToMap.Key.ToUniversalTime() - series.Span.Begin.ToUniversalTime()) / series.Span.Duration;
                var index       = Math.Min(series.Count - 1, Math.Max(0, (int)Math.Floor(indexDouble)));

                if (!series[index].HasValue)
                {
                    return(index);
                }

                var prevIndex = Math.Max(0, index - 1);

                if (!series[prevIndex].HasValue)
                {
                    series[prevIndex] = series[index];
                    return(index);
                }

                var nextIndex = Math.Min(series.Count - 1, index + 1);

                if ((indexDouble - index) >= 0.5d && !series[nextIndex].HasValue)
                {
                    return(nextIndex);
                }

                return(index);
            }

            series[findBestIndex()] = valueToMap.Value;
        }
示例#12
0
        /// <summary>
        /// Calculate Commodity Channel Index of input time series, as described here:
        /// <see href="https://en.wikipedia.org/wiki/Commodity_channel_index"/>
        /// </summary>
        /// <param name="series">input time series</param>
        /// <param name="n">averaging length</param>
        /// <param name="parentId">caller cache id, optional</param>
        /// <param name="memberName">caller's member name, optional</param>
        /// <param name="lineNumber">caller line number, optional</param>
        /// <returns>CCI time series</returns>
        public static ITimeSeries <double> CCI(this ITimeSeries <double> series, int n = 20,
                                               CacheId parentId = null, [CallerMemberName] string memberName = "", [CallerLineNumber] int lineNumber = 0)
        {
            var cacheId = new CacheId(parentId, memberName, lineNumber,
                                      series.GetHashCode(), n);

            return(IndicatorsBasic.BufferedLambda(
                       (v) =>
            {
                ITimeSeries <double> delta = series
                                             .Subtract(
                    series
                    .SMA(n, cacheId),
                    cacheId);

                ITimeSeries <double> meanDeviation = delta
                                                     .AbsValue(cacheId)
                                                     .SMA(n, cacheId);

                return delta[0] / Math.Max(1e-10, 0.015 * meanDeviation[0]);
            },
                       0.5,
                       cacheId));
        }
示例#13
0
        public IDisposable OpenToRead(string symbol, out ITimeSeries timeSeries)
        {
            var metaFile = _filePathProvider.GetMetaFilePath(symbol);

            lock (_symbols)                       // Protection against other threads
            {
                var locker = metaFile.LockFile(); // Protection against other processes and machines

                if (!_symbols.TryGetValue(symbol, out var meta))
                {
                    _symbols.Add(symbol, meta = new TimeSeries(symbol));
                }
                timeSeries = meta;

                var lastWriteTime = File.GetLastWriteTimeUtc(metaFile);
                if (lastWriteTime > meta.LastWriteTimeUtc)
                {
                    meta.Restore(metaFile);
                    meta.LastWriteTimeUtc = lastWriteTime;
                }

                return(locker);
            }
        }
示例#14
0
        public void Test_StandardDeviation()
        {
            double[,] testVectors =
            {
                { 100.00000, 0.00000, 0.00000, 0.00000, 0.00000, },
                { 105.00000, 2.50000, 0.00000, 0.00000, 0.00000, },
                { 102.50000, 2.39357, 2.50000, 0.00000, 0.00000, },
                { 107.50000, 3.22749, 2.39357, 2.50000, 0.00000, },
                { 105.00000, 2.04124, 3.22749, 2.39357, 2.50000, },
                { 110.00000, 3.22749, 2.04124, 3.22749, 2.39357, },
                { 107.50000, 2.04124, 3.22749, 2.04124, 3.22749, },
                { 112.50000, 3.22749, 2.04124, 3.22749, 2.04124, },
                { 110.00000, 2.04124, 3.22749, 2.04124, 3.22749, },
                { 115.00000, 3.22749, 2.04124, 3.22749, 2.04124, },
            };

            TimeSeries <double> stimulus = new TimeSeries <double>();

            for (int row = 0; row <= testVectors.GetUpperBound(0); row++)
            {
                stimulus.Value = testVectors[row, 0];
                ITimeSeries <double> response = stimulus.StandardDeviation(4);
                //Output.Write("{{ {0:F5}, ", testVectors[row, 0]);

                for (int col = 1; col <= testVectors.GetUpperBound(1); col++)
                {
                    int    t             = col - 1;
                    double responseValue = response[t];
                    double expectedValue = testVectors[row, col];
                    //Output.Write("{0:F5}, ", responseValue);

                    Assert.IsTrue(Math.Abs(responseValue - expectedValue) < 1e-5);
                }
                //Output.WriteLine("},");
            }
        }
        public void Test_LogRegression()
        {
            double[,] testVectors =
            {
                { 100.00000, 0.00000, 0.00000, 0.00000, 0.00000, },
                { 105.00000, 0.01464, 0.00000, 0.00000, 0.00000, },
                { 102.50000, 0.01229, 0.01464, 0.00000, 0.00000, },
                { 107.50000, 0.01929, 0.01229, 0.01464, 0.00000, },
                { 105.00000, 0.00476, 0.01929, 0.01229, 0.01464, },
                { 110.00000, 0.01883, 0.00476, 0.01929, 0.01229, },
                { 107.50000, 0.00465, 0.01883, 0.00476, 0.01929, },
                { 112.50000, 0.01840, 0.00465, 0.01883, 0.00476, },
                { 110.00000, 0.00455, 0.01840, 0.00465, 0.01883, },
                { 115.00000, 0.01799, 0.00455, 0.01840, 0.00465, },
            };

            TimeSeries <double> stimulus = new TimeSeries <double>();

            for (int row = 0; row <= testVectors.GetUpperBound(0); row++)
            {
                stimulus.Value = testVectors[row, 0];
                ITimeSeries <double> response = stimulus.LogRegression(4).Slope;
                //Output.Write("{{{0:F5}, ", testVectors[row, 0]);

                for (int col = 1; col <= testVectors.GetUpperBound(1); col++)
                {
                    int    t             = col - 1;
                    double responseValue = response[t];
                    double expectedValue = testVectors[row, col];
                    //Output.Write("{0:F5}, ", responseValue);

                    Assert.IsTrue(Math.Abs(responseValue - expectedValue) < 1e-5);
                }
                //Output.WriteLine("},");
            }
        }
示例#16
0
        public void Test_FastStandardDeviation()
        {
            double[,] testVectors =
            {
                { 100.00000, 0.00000, 0.00000, 0.00000, 0.00000, },
                { 105.00000, 2.44949, 0.00000, 0.00000, 0.00000, },
                { 102.50000, 1.91311, 2.44949, 0.00000, 0.00000, },
                { 107.50000, 2.98958, 1.91311, 2.44949, 0.00000, },
                { 105.00000, 2.33956, 2.98958, 1.91311, 2.44949, },
                { 110.00000, 3.20987, 2.33956, 2.98958, 1.91311, },
                { 107.50000, 2.51299, 3.20987, 2.33956, 2.98958, },
                { 112.50000, 3.30295, 2.51299, 3.20987, 2.33956, },
                { 110.00000, 2.58598, 3.30295, 2.51299, 3.20987, },
                { 115.00000, 3.34207, 2.58598, 3.30295, 2.51299, },
            };

            TimeSeries <double> stimulus = new TimeSeries <double>();

            for (int row = 0; row <= testVectors.GetUpperBound(0); row++)
            {
                stimulus.Value = testVectors[row, 0];
                ITimeSeries <double> response = stimulus.FastStandardDeviation(4);
                //Output.Write("{{ {0:F5}, ", testVectors[row, 0]);

                for (int col = 1; col <= testVectors.GetUpperBound(1); col++)
                {
                    int    t             = col - 1;
                    double responseValue = response[t];
                    double expectedValue = testVectors[row, col];
                    //Output.Write("{0:F5}, ", responseValue);

                    Assert.IsTrue(Math.Abs(responseValue - expectedValue) < 1e-5);
                }
                //Output.WriteLine("},");
            }
        }
        public void Test_Covariance()
        {
            double[,] testVectors =
            {
                // instr1  instr2     results
                { 1.10000, 3.00000, 0.00000, 0.00000, 0.00000, },
                { 1.70000, 4.20000, 0.14400, 0.00000, 0.00000, },
                { 2.10000, 4.90000, 0.40700, 0.14400, 0.00000, },
                { 1.40000, 4.10000, 0.33850, 0.40700, 0.14400, },
                { 0.20000, 2.50000, 0.66500, 0.33850, 0.40700, },
            };

            TimeSeries <double> x = new TimeSeries <double>();
            TimeSeries <double> y = new TimeSeries <double>();

            for (int row = 0; row <= testVectors.GetUpperBound(0); row++)
            {
                x.Value = testVectors[row, 0];
                y.Value = testVectors[row, 1];

                ITimeSeries <double> response = x.Covariance(y, 5);
                //Output.Write("{{{0:F5},{1:F5},", testVectors[row, 0], testVectors[row, 1]);

                for (int col = 2; col <= testVectors.GetUpperBound(1); col++)
                {
                    int    t             = col - 2;
                    double responseValue = response[t];
                    double expectedValue = testVectors[row, col];
                    //Output.Write("{0:F5},", responseValue);

                    Assert.IsTrue(Math.Abs(responseValue - expectedValue) < 1e-5);
                }
                //Output.WriteLine("},");
            }
            #endregion
        }
示例#18
0
        public void Test_EMA()
        {
            double[,] testVectors =
            {
                { 100.00000, 100.00000, 100.00000, 100.00000, 100.00000, },
                { 105.00000, 102.00000, 100.00000, 100.00000, 100.00000, },
                { 102.50000, 102.20000, 102.00000, 100.00000, 100.00000, },
                { 107.50000, 104.32000, 102.20000, 102.00000, 100.00000, },
                { 105.00000, 104.59200, 104.32000, 102.20000, 102.00000, },
                { 110.00000, 106.75520, 104.59200, 104.32000, 102.20000, },
                { 107.50000, 107.05312, 106.75520, 104.59200, 104.32000, },
                { 112.50000, 109.23187, 107.05312, 106.75520, 104.59200, },
                { 110.00000, 109.53912, 109.23187, 107.05312, 106.75520, },
                { 115.00000, 111.72347, 109.53912, 109.23187, 107.05312, },
            };

            TimeSeries <double> stimulus = new TimeSeries <double>();

            for (int row = 0; row <= testVectors.GetUpperBound(0); row++)
            {
                stimulus.Value = testVectors[row, 0];
                ITimeSeries <double> response = stimulus.EMA(4);
                //Output.Write("{{{0:F5},", testVectors[row, 0]);

                for (int col = 1; col <= testVectors.GetUpperBound(1); col++)
                {
                    int    t             = col - 1;
                    double responseValue = response[t];
                    double expectedValue = testVectors[row, col];
                    //Output.Write("{0:F5},", responseValue);

                    Assert.IsTrue(Math.Abs(responseValue - expectedValue) < 1e-5);
                }
                //Output.WriteLine("},");
            }
        }
示例#19
0
 public void init()
 {
     data = new BaseTimeSeries();
     data.AddBar(new BaseBar(DateTime.Now.AddDays(1), 168.28M, 169.87M, 167.15M, 169.64M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(2), 168.84M, 169.36M, 168.2M, 168.71M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(3), 168.88M, 169.29M, 166.41M, 167.74M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(4), 168M, 168.38M, 166.18M, 166.32M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(5), 166.89M, 167.7M, 166.33M, 167.24M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(6), 165.25M, 168.43M, 165M, 168.05M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(7), 168.17M, 170.18M, 167.63M, 169.92M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(8), 170.42M, 172.15M, 170.06M, 171.97M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(9), 172.41M, 172.92M, 171.31M, 172.02M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(10), 171.2M, 172.39M, 169.55M, 170.72M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(11), 170.91M, 172.48M, 169.57M, 172.09M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(12), 171.8M, 173.31M, 170.27M, 173.21M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(13), 173.09M, 173.49M, 170.8M, 170.95M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(14), 172.41M, 173.89M, 172.2M, 173.51M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(15), 173.87M, 174.17M, 175M, 172.96M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(16), 173M, 173.17M, 172.06M, 173.05M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(17), 172.26M, 172.28M, 170.5M, 170.96M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(18), 170.88M, 172.34M, 170.26M, 171.64M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(19), 171.85M, 172.07M, 169.34M, 170.01M, 0));
     data.AddBar(new BaseBar(DateTime.Now.AddDays(20), 170.75M, 172.56M, 170.36M, 172.52M, 0)); // FB, daily, 9.19.'17
 }
示例#20
0
        public void Test_Normalize()
        {
            double[,] testVectors =
            {
                { 100.00000, 1.00000, 1.00000, 1.00000, 1.00000, },
                { 105.00000, 1.02439, 1.00000, 1.00000, 1.00000, },
                { 102.50000, 1.00000, 1.02439, 1.00000, 1.00000, },
                { 107.50000, 1.02381, 1.00000, 1.02439, 1.00000, },
                { 105.00000, 1.00000, 1.02381, 1.00000, 1.02439, },
                { 110.00000, 1.02326, 1.00000, 1.02381, 1.00000, },
                { 107.50000, 1.00000, 1.02326, 1.00000, 1.02381, },
                { 112.50000, 1.02273, 1.00000, 1.02326, 1.00000, },
                { 110.00000, 1.00000, 1.02273, 1.00000, 1.02326, },
                { 115.00000, 1.02222, 1.00000, 1.02273, 1.00000, },
            };

            TimeSeries <double> stimulus = new TimeSeries <double>();

            for (int row = 0; row <= testVectors.GetUpperBound(0); row++)
            {
                stimulus.Value = testVectors[row, 0];
                ITimeSeries <double> response = stimulus.Normalize(3);
                //Output.Write("{{ {0:F5}, ", testVectors[row, 0]);

                for (int col = 1; col <= testVectors.GetUpperBound(1); col++)
                {
                    int    t             = col - 1;
                    double responseValue = response[t];
                    double expectedValue = testVectors[row, col];
                    //Output.Write("{0:F5}, ", responseValue);

                    Assert.IsTrue(Math.Abs(responseValue - expectedValue) < 1e-5);
                }
                //Output.WriteLine("},");
            }
        }
示例#21
0
        /// <summary>
        /// Splits a regular time-series with data gaps into two or more sub-series
        /// The maximum allowed gap size is determined by GetDefaultTimeStep()
        /// Use this function for stage and discharge
        /// </summary>
        /// <param name="ts">The time series</param>
        /// <returns>the list of splitted regular time-series</returns>
        public static List<HydroTimeSeries> SplitTimeSeries(ITimeSeries ts)
        {
            List<HydroTimeSeries> hsList = new List<HydroTimeSeries>();
            List<int> breakIx = GetDataBreaks(ts);

            if (breakIx.Count > 0)
            {
                //for the final segment
                if (breakIx[breakIx.Count - 1] != ts.Count - 1)
                {
                    breakIx.Add(ts.Count - 1);
                }

                int begIndex = 0;
                for (int i = 0; i < breakIx.Count; i++)
                {
                    //all data before each break
                    int endIndex = breakIx[i];
                    DateTime begDate = DateTime.FromOADate(ts[begIndex].X);
                    DateTime endDate = DateTime.FromOADate(ts[endIndex].X);
                    HydroTimeSeries newTs = new HydroTimeSeries(begDate, endDate);
                    for (int j = begIndex; j <= endIndex; j++)
                    {
                        newTs.AddObservation(DateTime.FromOADate(ts[j].X), ts[j].Y);
                    }
                    begIndex = endIndex + 1;
                    if (newTs.Count > 0)
                    {
                        hsList.Add(newTs);
                    }
                }
            }
            else
            {
                hsList.Add((HydroTimeSeries)ts);
            }
            return hsList;
        }
示例#22
0
        //plot chart titles and other text description, setup the axes etc.
        private void SetupChart(ITimeSeries ts, ChartLabelInfo chartText, string chType, GraphPane pane)
        {
            //Station st = ts.Station;
            //Variable var = ts.Variable;
            DateTime start = ts.Start;
            DateTime end = ts.End;
            DrawTitle(pane, chartText.StationName, chartText.ChannelName, start, end);

            SetupAxis(pane, chType, chartText, start, end);
            SetupGrid(pane, chType);
            SetupLegend(pane);
        }
示例#23
0
        private void PlotVlh(ITimeSeries ts, GraphPane myPane)
        {
            if (ts.Count > 0)
            {
                Color lineColor = Color.Blue;

                //Main creation of curve
                LineItem myCurve = myPane.AddCurve("", ts, lineColor, SymbolType.None);
                myCurve.Line.Width = 2F;
                myCurve.Line.Fill = new Fill(Color.FromArgb(128, Color.AliceBlue));
            }
        }
示例#24
0
 private void SetupChart(ITimeSeries ts, Channel ch, GraphPane pane)
 {
     Station st = ch.Station;
     Variable var = ch.Variable;
     DateTime start = ts.Start;
     DateTime end = ts.End;
     DrawTitle(pane, var, st, start, end);
     SetupAxis(pane, var, start, end);
     SetupGrid(pane, var.VarEnum);
     SetupLegend(pane);
 }
 public ISquareTimeSeriesData Add(ITimeSeries timeSeries)
 {
     // implement here
 }
 public SeriesExtractResult(ITimeSeries series_)
 {
   Series = series_;
 }
        private static AnalyticsBondStaticData ConvertCarbonBondStaticToAnalyticBondStatic(ICarbonClient client, ITimeSeries data)
        {
            var result = new AnalyticsBondStaticData
            {
                Id = client.GetSingleStaticDataInternal<string>(data, "isin"),
                MaturityDate = client.GetSingleStaticDataInternal<DateTime>(data, "maturityDt"),
                EffectiveDate = client.GetSingleStaticDataInternal<DateTime>(data, "effectiveDt")
            };

            //  Check if there is a more recent effective date due to subsequent auctions.
            DateTime latestEffectiveDate;
            object o = data.GetCarbonBondMostRecentEffectiveDate();
            if (o is DateTime)
                latestEffectiveDate = (DateTime)o;
            else
                latestEffectiveDate = result.EffectiveDate;
            result.FirstCouponDate = client.GetSingleStaticDataInternal<DateTime>(data, "firstCpnDt");
            result.Coupon = client.GetSingleStaticDataInternal<double>(data, "cpnRate");

            return DecorateAnalyticsBondStaticData(result, latestEffectiveDate);
        }
示例#28
0
        /// <summary>
        /// Plot the hourly precipitation !!!!
        /// </summary>
        private void PlotPrecipHour(ITimeSeries ts, GraphPane myPane)
        {
            TimeInterval interval = new TimeInterval(ts.Start, ts.End);
            string varName = Resources.precip_label;

            //Main creation of curve
            if ( interval.Length.TotalDays <= 2 )
            {
                BarItem myCurve = myPane.AddBar(varName, ts, Color.Blue);
                myCurve.Bar.Border.Color = Color.Blue;
                myCurve.Bar.Border.IsVisible = true;
                myCurve.Bar.Fill.Type = FillType.Solid;
                myCurve.Bar.Fill.IsScaled = false;
            }
            else
            {
                StickItem myCurve = myPane.AddStick(varName, ts, Color.Blue);
            }

            //cumulative precipitation..
            ITimeSeries ts2 = ts.ShowCumulative();
            LineItem myCurve2 = myPane.AddCurve(Resources.precip_sum_label,
                ts2, Color.Red, SymbolType.None);
            myCurve2.IsY2Axis = true;
            myPane.AxisChange();
        }
示例#29
0
 public AmountIndicator(ITimeSeries series)
     : base(series)
 {
     _series = series;
 }
 /**
  * @param series a time series
  * @param trade a trade
  * @return the criterion value for the trade
  */
 public abstract decimal Calculate(ITimeSeries series, Trade trade);
示例#31
0
 private void PlotSoilWater(ITimeSeries ts, GraphPane myPane)
 {
     if ( ts.Count > 0 )
     {
         //Main creation of curve
         LineItem myCurve = myPane.AddCurve("", ts, Color.Blue, SymbolType.None);
         myCurve.Line.Width = 2F;
     }
 }
示例#32
0
        private static List<int> GetDataBreaks(ITimeSeries ts)
        {
            double breakTresholdDays = 1.1;
            List<int> breakIx = new List<int>();

            for (int i = 0; i < ts.Count - 1; i++)
            {
                double x1 = ts[i].X;
                double x2 = ts[i + 1].X;
                if (x2 - x1 > breakTresholdDays)
                {
                    breakIx.Add(i);
                }
            }
            return breakIx;
        }
示例#33
0
        /// <summary>
        /// Plot the snow !!!!
        /// </summary>
        /// <param name="ts"></param>
        /// <param name="myPane"></param>
        private void PlotSnow(ITimeSeries ts, GraphPane myPane)
        {
            TimeInterval interval = new TimeInterval(ts.Start, ts.End);

            //Main creation of curve
            if ( interval.Length.TotalDays < 160 )
            {
                BarItem myCurve = myPane.AddBar("", ts, Color.Blue);
                myCurve.Bar.Border.Color = Color.Blue;
                myCurve.Bar.Border.IsVisible = true;
                myCurve.Bar.Fill.Type = FillType.Solid;
                myCurve.Bar.Fill.IsScaled = false;
            }
            else if (interval.Length.TotalDays < 200)
            {
                StickItem myCurve = myPane.AddStick("", ts, Color.Blue);
            }
            else if (interval.Length.TotalDays < 400)
            {
                BarItem myCurve = myPane.AddBar("", ts, Color.Blue);
                myCurve.Bar.Border.Color = Color.Blue;
                myCurve.Bar.Border.IsVisible = true;
                myCurve.Bar.Fill.Type = FillType.Solid;
                myCurve.Bar.Fill.IsScaled = false;
            }
            else
            {
                StickItem myCurve = myPane.AddStick("", ts, Color.Blue);
            }
            //else
            //{
            //    StickItem myCurve = myPane.AddStick("", ts, Color.Blue);
            //    //LineItem myCurve = myPane.AddCurve("", ts, Color.Blue, SymbolType.None);
            //    //myCurve.Line.Width = 0F;
            //    //myCurve.Line.Fill = new Fill(Color.Blue);
            //}
        }
示例#34
0
        // plot the stage!
        private void PlotStageDischarge(ITimeSeries ts, GraphPane myPane)
        {
            TimeInterval interval = new TimeInterval(ts.Start, ts.End);

            if ( ts.Count > 0 )
            {
                List<HydroTimeSeries> tsList = TimeSeriesManager.SplitTimeSeries(ts);

                foreach (HydroTimeSeries ts2 in tsList)
                {
                    LineItem myCurve = myPane.AddCurve("", ts2, Color.Blue, SymbolType.None);
                    myCurve.Line.Width = 1F;
                    myCurve.Line.Fill = new Fill(Color.FromArgb(128, Color.Blue));
                }
                //mark missing data points
                if (tsList.Count > 1)
                {
                    TimeStep step = TimeSeriesManager.GetDefaultTimeStep(VariableEnum.Stage, interval);

                    HydroTimeSeries missingTs = TimeSeriesManager.GetMissingValuesHydro(ts, ts.Start, ts.End, step);
                    PlotMissingData(missingTs, myPane);

                }
            }
        }
示例#35
0
 public override decimal Calculate(ITimeSeries series, ITradingRecord tradingRecord)
 {
     return(_totalProfit.Calculate(series, tradingRecord).DividedBy(_maxDrawdown.Calculate(series, tradingRecord)));
 }
示例#36
0
 /// <summary>
 /// Creates a chart - plots are made for all sensors in the time series
 /// </summary>
 /// <param name="ts">The time series of data to be ploted</param>
 /// <param name="ch">The channel (contains station, variable and copyright description)
 /// </param>
 /// <returns>The chart png image</returns>
 public Bitmap CreateChart(Channel ch, ITimeSeries ts)
 {
     GraphPane pane = SetupGraphPane();
     SetupChart(ts, ch, pane);
     PlotChartForChannel(ts, ch, pane);
     return ExportGraph(pane);
 }
示例#37
0
        /// <summary>
        /// puts little "crosses" on missing data points
        /// </summary>
        private void PlotMissingData(ITimeSeries ts, GraphPane myPane)
        {
            string noDataText = Resources.no_data;

            float crossSize = 10F;
            //double yAxisH = myPane.YAxis.Scale.ReverseTransform(crossSize);
            double yAxisH = myPane.YAxis.Scale.Max / 25.0;

            //ITimeSeries ts2 = ts.ShowUnknown(yAxisH);
            for (int i = 0; i < ts.Count; i++ )
            {
                ts[i].Y = yAxisH;
            }

            if ( ts != null )
            {
                if ( ts.Count > 0 )
                {
                    LineItem missingCurve = myPane.AddCurve(noDataText, ts, Color.Red, SymbolType.XCross);
                    missingCurve.Line.IsVisible = false;
                    missingCurve.Symbol.Size = crossSize;
                    missingCurve.Symbol.IsVisible = true;
                    myPane.AxisChange();
                }
            }
        }
示例#38
0
 /**
  * Constructor.
  * @param series the series
  * @param timeFrame the time frame
  */
 public DPOIndicator(ITimeSeries series, int timeFrame)
     : this(new ClosePriceIndicator(series), timeFrame)
 {
 }
示例#39
0
        private void PlotChartForChannel(ITimeSeries ts, Channel ch, GraphPane pane)
        {
            VariableEnum varEnum = ch.Variable.VarEnum;

            if (ts.End < Convert.ToDateTime("2013-01-01") && ts.PercentAvailableData < 1.0) //no data..
            {
                ShowNoDataTextBox(Resources.no_data, pane);
                ShowErrorTextBox(Resources.no_data_message, pane);
            }
            else
            {
                switch (varEnum)
                {
                    case VariableEnum.Stage:
                        PlotStageDischarge(ts, pane);
                        break;
                    case VariableEnum.Discharge:
                        PlotStageDischarge(ts, pane);
                        break;
                    case VariableEnum.Snow:
                        PlotSnow(ts, pane);
                        break;
                    case VariableEnum.SoilWater10:
                    case VariableEnum.SoilWater50:
                        PlotSoilWater(ts, pane);
                        break;
                    case VariableEnum.Precip:
                        PlotPrecip(ts, pane);
                        break;
                    case VariableEnum.PrecipHour:
                        PlotPrecipHour(ts, pane);
                        break;
                    case VariableEnum.Temperature:
                        PlotTemperature(ts, pane);
                        break;
                    default:
                        break;
                }

                //also plot 'no data' if necessary
                if (ch.Variable.VarEnum != VariableEnum.Stage &&
                    ch.Variable.VarEnum != VariableEnum.Discharge &&
                    ts.PercentAvailableData > 0.01)
                {
                    //PlotMissingData(ts, pane);
                }

                //add 'copyright' notice
                ShowCopyrightTextBox("data: " + ch.Station.Operator, pane);
            }
        }
示例#40
0
 public void setUp()
 {
     data = new MockTimeSeries(1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2);
 }
示例#41
0
 public static ITimeSeries MakeCumulative(ITimeSeries ts)
 {
     HydroTimeSeries ts2 = new HydroTimeSeries(ts.Start, ts.End);
     double sum = 0.0;
     PointPair curPt;
     for ( int i = 0; i < ts.Count; ++i )
     {
         curPt = ts[i];
         if ( curPt.IsMissing )
         {
             ts2.AddUnknownValue(XDate.XLDateToDateTime(curPt.X));
         }
         else
         {
             if (curPt.Y > 0)
             {
                 sum += curPt.Y;
             }
             ts2.AddObservation(XDate.XLDateToDateTime(curPt.X), sum);
         }
     }
     return ts2;
 }
示例#42
0
 /**
  * Constructor with custom parameters and  increment value
  * @param series the time series for this indicator
  * @param aF acceleration factor
  * @param MaxA Maximum acceleration
  */
 public ParabolicSarIndicator(ITimeSeries series, decimal aF, decimal MaxA)
     : this(series, aF, MaxA, 0.02M)
 {
 }
 ITimeSeriesData ITimeSeriesData.Add(ITimeSeries timeSeries)
 {
     return(this.Add(timeSeries));    // call the overridden Add method
 }
示例#44
0
 private void PlotTemperature(ITimeSeries ts, GraphPane myPane)
 {
     if (ts.Count > 0)
     {
         TimeInterval interv = new TimeInterval(ts.Start, ts.End);
         TimeStep step = TimeSeriesManager.GetDefaultTimeStep(VariableEnum.Temperature, interv);
         ITimeSeries ts2 = TimeSeriesManager.FillDataGaps(ts, step);
         LineItem myCurve = myPane.AddCurve("", ts2, Color.Blue, SymbolType.None);
         myCurve.Line.Width = 0.5F;
     }
 }
 /**
  * @param series a time series
  * @param tradingRecord a trading record
  * @return the criterion value for the trades
  */
 public abstract decimal Calculate(ITimeSeries series, ITradingRecord tradingRecord);
示例#46
0
        /// <summary>
        /// Creates a chart of given type from the time series
        /// </summary>
        /// <param name="ts"></param>
        /// <param name="labels"></param>
        /// <param name="chartType"></param>
        /// <returns></returns>
        public void CreateChart(ITimeSeries ts, ChartLabelInfo chartText, string chartType, string file)
        {
            Bitmap bmp;

            GraphPane pane = SetupGraphPane();
            SetupChart(ts, chartText, chartType, pane);
            PlotChartForSensor(ts, pane, chartType);

            if (ts.Count == 0 || Math.Abs(ts.MaxValue - ts.MinValue) < 0.001)
            {
                AddText(pane,"čidlo mimo provoz");
            }

            bmp = ExportGraph(pane);

            string filePath = Path.Combine(_dir , file + ".png");
            bmp.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
            //DrawThumb(bmp, file);
            bmp.Dispose();

            //draws the 'thumb' image
            //DrawThumb2(ts, chartType, filePath.Replace(".png", "-m.png"));

            DrawThumb(pane, filePath.Replace(".png", "-m.png"));
        }
示例#47
0
 /**
  * Constructor.
  * @param series a time series
  */
 public BullishHaramiIndicator(ITimeSeries series)
     : base(series)
 {
     _series = series;
 }
示例#48
0
        /// <summary>
        /// Draws the 'thumb' version of the chart
        /// </summary>
        /// <param name="ts"></param>
        /// <param name="chartType"></param>
        /// <param name="file"></param>
        private void DrawThumb2(ITimeSeries ts, string chartType, string file)
        {
            GraphPane myPane = new GraphPane(new RectangleF(0, 0, this.ThumbWidth, this.ThumbHeight),
                "", "", "");
            if (ts.Count > 0)
            {
                myPane.XAxis.Scale.Min = XDate.DateTimeToXLDate(ts.Start);
                myPane.XAxis.Scale.Max = XDate.DateTimeToXLDate(ts.End);
                LineItem myCurve;
                StickItem myCurve2;
                switch (chartType)
                {
                    case "hla":
                        myCurve = myPane.AddCurve("", ts, Color.Blue, SymbolType.None);
                        myCurve.Line.Width = 0;
                        myCurve.Line.Fill = new Fill(Color.Blue);
                        break;
                    case "rad":
                        myCurve = myPane.AddCurve("", ts, Color.Orange, SymbolType.None);
                        myCurve.Line.Width = 0;
                        myCurve.Line.Fill = new Fill(Color.Orange);
                        break;
                    case "sra":
                        myCurve2 = myPane.AddStick("", ts, Color.Blue);
                        //cumulative precipitation..
                        ITimeSeries ts2 = ts.ShowCumulative();
                        myCurve = myPane.AddCurve("", ts2, Color.Red, SymbolType.None);
                        myCurve.IsY2Axis = true;
                        break;
                    case "tep":
                        myCurve = myPane.AddCurve("", ts, Color.Red, SymbolType.None);
                        double[] xdata = new double[]{XDate.DateTimeToXLDate(ts.Start),
                            XDate.DateTimeToXLDate(ts.End)};
                        double[] ydata = new double[]{0.0, 0.0};
                        LineItem myCurve3 = myPane.AddCurve("", xdata, ydata, Color.Blue);
                        break;
                    default:
                        myCurve = myPane.AddCurve("", ts, Color.Red, SymbolType.None);
                        break;
                }
                myPane.XAxis.IsVisible = false;
                myPane.YAxis.IsVisible = false;
                myPane.Y2Axis.IsVisible = false;
                myPane.XAxis.MajorGrid.IsVisible = false;
                myPane.Border.Color = Color.White;
                myPane.Legend.IsVisible = false;

                myPane.AxisChange();
                Bitmap bmp = ExportGraph(myPane);
                //string filePath = _dir + "m-" + file;
                bmp.Save(file, System.Drawing.Imaging.ImageFormat.Png);
                bmp.Dispose();
            }
        }
示例#49
0
 public override decimal Calculate(ITimeSeries series, Trade trade)
 {
     return(_totalProfit.Calculate(series, trade) / _maxDrawdown.Calculate(series, trade));
 }
示例#50
0
 private void PlotChartForSensor(ITimeSeries ts, GraphPane pane, string chartType)
 {
     switch ( chartType )
     {
         case "hla":
             PlotStage(ts, pane);
             break;
         case "sra":
             PlotPrecipHour(ts, pane);
             break;
         case "tep":
         case "tvo":
         case "tpu":
         case "tp1":
         case "tp2":
             PlotTemperature(ts, pane);
             break;
         case "ph":
             PlotPh(ts, pane);
             break;
         case "rad":
             PlotRad(ts, pane);
             break;
         case "vlh":
             PlotVlh(ts, pane);
             break;
         case "ryv":
             PlotRyv(ts, pane);
             break;
         default:
             PlotTemperature(ts, pane);
             break;
     }
     //also plot 'no data' if necessary
     //if ( ts.Count > ts.NumValid )
     //{
     //    PlotMissingData(ts, pane);
     //}
 }
示例#51
0
 /**
  * Constructor.
  * <p>
  * Calculates the pivot point based on the time level parameter.
  * @param series the time series with adequate endTime of each bar for the given time level.
  * @param timeLevel the corresponding {@link TimeLevel} for pivot calculation:
  *       <ul>
  *          <li>1-, 5-, 10- and 15-Minute charts use the prior days high, low and close: <b>timeLevelId</b> = TimeLevel.DAY</li>
  *          <li>30- 60- and 120-Minute charts use the prior week's high, low, and close: <b>timeLevelId</b> =  TimeLevel.WEEK</li>
  *          <li>Pivot Points for daily charts use the prior month's high, low and close: <b>timeLevelId</b> = TimeLevel.MONTH</li>
  *          <li>Pivot Points for weekly and monthly charts use the prior year's high, low and close: <b>timeLevelId</b> = TimeLevel.YEAR (= 4)</li>
  *          <li> If you want to use just the last bar data: <b>timeLevelId</b> = TimeLevel.BARBASED</li>
  *      </ul>
  * The user has to make sure that there are enough previous bars to Calculate correct pivots at the first bar that matters. For example for PIVOT_TIME_LEVEL_ID_MONTH
  * there will be only correct pivot point values (and reversals) after the first complete month
  */
 public PivotPointIndicator(ITimeSeries series, TimeLevel timeLevel)
     : base(series)
 {
     _timeLevel = timeLevel;
 }
示例#52
0
        /// <summary>
        /// Plot the hourly precipitation !!!!
        /// </summary>
        /// <param name="ts"></param>
        /// <param name="myPane"></param>
        private void PlotPrecipHour(ITimeSeries ts, GraphPane myPane)
        {
            DateTime MinDate, MaxDate;

            if (ts.Count > 0)
            {
                TimeSeries ts1 = (TimeSeries)ts.AggregateHourly();

                MinDate = ts1.Start;
                MaxDate = ts1.End;

                //Main creation of curve
                double totalDays = (MaxDate.Subtract(MinDate)).TotalDays;
                if (totalDays < 2)
                {
                    BarItem myCurve = myPane.AddBar("srážky", ts1, Color.Blue);
                    myCurve.Bar.Border.Color = Color.Blue;
                    myCurve.Bar.Border.IsVisible = true;
                    myCurve.Bar.Fill.Type = FillType.Solid;
                    myCurve.Bar.Fill.IsScaled = false;
                }
                else
                {
                    StickItem myCurve = myPane.AddStick("srážky", ts1, Color.Blue);
                }

                //cumulative precipitation..
                if (ts != null)
                {

                    TimeSeries ts2 = (TimeSeries)ts.ShowCumulative();
                    LineItem myCurve2 = myPane.AddCurve("suma srážek", ts2, Color.Red, SymbolType.None);
                    myCurve2.IsY2Axis = true;

                    myPane.AxisChange();
                }
            }
        }
示例#53
0
        private decimal _minMaxExtremePoint;  // depending on trend the Maximum or Minimum extreme point value of trend

        /**
         * Constructor with  parameters
         * @param series the time series for this indicator
         */
        public ParabolicSarIndicator(ITimeSeries series)
            : this(series, 0.02M, 0.2M, 0.02M)
        {
        }
示例#54
0
        /// <summary>
        /// Do actual plotting - first try - STAGE !!!
        /// </summary>
        private void PlotStage(ITimeSeries ts, GraphPane myPane)
        {
            DateTime MinDate, MaxDate;

            if ( ts.Count > 0 )
            {
                MinDate = ts.Start;
                MaxDate = ts.End;

                //Main creation of curve
                LineItem myCurve = myPane.AddCurve("", ts, Color.Blue, SymbolType.None);
                if ( ( (TimeSpan) ( MaxDate - MinDate ) ).TotalDays < 1 )
                {
                    myCurve.Line.Width = 2F;
                }
                else
                {
                    myCurve.Line.Width = 1F;
                    myCurve.Line.Fill = new Fill(Color.FromArgb(128, Color.Blue));
                }
            }
        }
 public void setUp()
 {
     timeSeries            = new MockTimeSeries();
     typicalPriceIndicator = new TypicalPriceIndicator(timeSeries);
 }
示例#56
0
        /// <summary>
        /// Plot the temperature !!!!
        /// </summary>
        /// <param name="ts"></param>
        /// <param name="myPane"></param>
        private void PlotTemperature(ITimeSeries ts, GraphPane myPane)
        {
            if (ts.Count > 0)
            {
                Color lineColor = Color.Red;

                //Main creation of curve
                LineItem myCurve = myPane.AddCurve("", ts, lineColor, SymbolType.None);
                myCurve.Line.Width = 2F;
            }
        }
示例#57
-1
    private void addSeries(ITimeSeries series_, int yAxisExtent_)
    {
      if (series_ == null || series_.Series == null) return;

      var values = series_.Series;

      if (DoCumulative)
        values = values.ToCumulative();

      var chart = lcdInstrumentHistory.AddSeries(values, series_.Name, yAxisExtent_, "##0.0#");
      chart.AxisX.TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.Smart;
      chart.AxisY.TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.Smart;
      chart.AxisY.MajorGridLines.Visible = false;
    }