Ejemplo n.º 1
0
        public void Start()
        {
            FinancialTimeSpans.All.ForEach(timeFrame => {
                string path = new SeriesDescriptor()
                              .InstrumentDescriptors.Single(x => x.Name == "EURUSD")
                              .ProviderDescriptors.Single(x => x.Name == "Dukascopy")
                              .Path;

                BarsReader reader = BarsReader.Create(timeFrame, path);

                if (reader != null)
                {
                    IndicatorsCreator creator = new IndicatorsCreator(timeFrame, path);
                    creator.AddIndicator(new RSI(15));
                    creator.AddIndicator(new RSI(20));
                    creator.AddIndicator(new RSI(25));

                    DateTime dateTime;
                    decimal price;
                    int lastMonth = -1;

                    while (reader.Next(out dateTime, out price))
                    {
                        creator.Update(dateTime, price);
                        if (dateTime.Month != lastMonth)
                        {
                            Console.WriteLine("{0} -> {1} -> {2}", dateTime, price, CreateString(creator.Values));
                            lastMonth = dateTime.Month;
                        }
                    }

                    creator.Finish();
                }
            });
        }
Ejemplo n.º 2
0
        public void TestSMA()
        {
            var path = new SeriesDescriptor()
                       .InstrumentDescriptors.Single(x => x.Name == "EURUSD")
                       .ProviderDescriptors.Single(x => x.Name == "Dukascopy")
                       .Path;
            var         timeFrame = FinancialTimeSpans.M1;
            var         reader    = BarsReader.Create(timeFrame, path);
            List <IBar> bars      = reader.ReadAll();
            var         smaValues = bars.SMA(60);

            Assert.AreEqual(bars.Count, smaValues.InstantValues.Count);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            string path = new SeriesDescriptor()
                          .InstrumentDescriptors.Single(x => x.Name == "EURUSD")
                          .ProviderDescriptors.Single(x => x.Name == "Dukascopy")
                          .Path;

            BarsReader reader = BarsReader.Create(TimeSpan.FromHours(1), path /*, new DateTime(2010, 1, 1), new DateTime(2010, 2, 1)*/);

            DateTime dateTime;
            decimal  price;

            while (reader.Next(out dateTime, out price))
            {
                Console.WriteLine("{0} -> {1}", dateTime, price);
            }

            Console.ReadLine();
        }
Ejemplo n.º 4
0
        public void TestBBands()
        {
            var path = new SeriesDescriptor()
                       .InstrumentDescriptors.Single(x => x.Name == "EURUSD")
                       .ProviderDescriptors.Single(x => x.Name == "Dukascopy")
                       .Path;
            var timeFrame = FinancialTimeSpans.M1;
            var reader    = BarsReader.Create(timeFrame, path);

            DateTime[] dateTimes;
            double[]   prices;
            reader.ReadAll(out dateTimes, out prices);

            // corregir
            throw new InvalidOperationException();
            //var smaValues = prices.Bbands(15, 2, 2, TicTacTec.TA.Library.Core.MAType.Ema);

            //Assert.AreEqual(prices.Length, smaValues.Item1.Length);
            //Assert.AreEqual(prices.Length, smaValues.Item2.Length);
            //Assert.AreEqual(prices.Length, smaValues.Item3.Length);
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            string path = new SeriesDescriptor()
                          .InstrumentDescriptors.Single(x => x.Name == "EURUSD")
                          .ProviderDescriptors.Single(x => x.Name == "Dukascopy")
                          .Path;

            // creo un groupReader para leer los bars e indicadores de forma coordinada
            var groupReader = new DateTimeAndPriceGroupReader();

            // voy a consumir el barsReader a través del groupReader
            BarsReader barsReader = BarsReader.Create(TimeSpan.FromHours(1), path);

            groupReader.AddReader(barsReader);

            // también los indicadores basados en horas
            FinancialTimeSpans.Hours.ForEach(timeFrame => {
                IndicatorsReader indicatorsReader = IndicatorsReader.Create(new RSI(25), timeFrame, path);
                groupReader.AddReader(indicatorsReader);
            });

            DateTime groupDateTime;

            decimal[] barAndIndicatorsPrices;

            while (groupReader.Next(out groupDateTime, out barAndIndicatorsPrices))
            {
                StringBuilder sb = new StringBuilder();
                barAndIndicatorsPrices.ToList().ForEach(price => {
                    if (sb.Length > 0)
                    {
                        sb.Append(", ");
                    }
                    sb.AppendFormat("{0:0.000000}", price);
                });
                Console.WriteLine("{0} -> [{1}]", groupDateTime, sb.ToString());
            }

            Console.ReadLine();
        }