コード例 #1
0
ファイル: Robot.cs プロジェクト: RomanS2N/trading
        public void Start()
        {
            new List <TimeSpan> {
                FinancialTimeSpans.M1
            }.ForEach(timeFrame => {
                IBarsCreator creator = new BarsCreator(null, null, timeFrame, @"C:\quotes\EURUSD\Dukascopy\");
                string path          = new SeriesDescriptor()
                                       .InstrumentDescriptors.Single(x => x.Name == "EURUSD")
                                       .ProviderDescriptors.Single(x => x.Name == "Dukascopy")
                                       .Path;
                SeriesReader reader = new SeriesReader(path);
                DateTime dateTime;
                decimal ask, bid;
                int lastMonth = -1;
                while (reader.Next(out dateTime, out ask, out bid))
                {
                    creator.AddQuote(dateTime, ask);
#if _VERBOSE
                    if (dateTime.Month != lastMonth)
                    {
                        Console.WriteLine("{0} -> {1}/{2} -> {3}", dateTime, ask, bid, creator.BarsCount);
                        lastMonth = dateTime.Month;
                    }
#endif
                }
                creator.Finish();
            });
        }
コード例 #2
0
ファイル: Robot.cs プロジェクト: RomanS2N/trading
        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();
                }
            });
        }
コード例 #3
0
        static void Main(string[] args)
        {
            //string rootFolder = @"C:\quotes\EURUSD\Dukascopy\";
            //DateTime begin = new DateTime(2003, 06, 01, 15, 31, 49);
            //DateTime end = new DateTime(2013, 06, 15, 18, 55, 16);
            //ISeriesReader reader = new SeriesReader(rootFolder, begin, end);
            //DateTime dateTime;
            //decimal ask, bid;
            //while (reader.Next(out dateTime, out ask, out bid)) {
            //  Console.WriteLine("{0} -> {1}/{2}", dateTime, ask, bid);
            //}

            string path = new SeriesDescriptor()
                          .InstrumentDescriptors.Single(x => x.Name == "EURUSD")
                          .ProviderDescriptors.Single(x => x.Name == "Dukascopy")
                          .Path;
            SeriesReader reader = new SeriesReader(path);
            DateTime     dateTime;
            decimal      ask, bid;
            int          lastMonth = -1;

            while (reader.Next(out dateTime, out ask, out bid))
            {
                if (dateTime.Month != lastMonth)
                {
                    Console.WriteLine("{0} -> {1}/{2}", dateTime, ask, bid);
                    lastMonth = dateTime.Month;
                }
            }
            Console.ReadLine();
        }
コード例 #4
0
ファイル: Robot.cs プロジェクト: RomanS2N/trading
 private void ConvertSeries(SeriesDescriptor seriesDescriptor)
 {
     seriesDescriptor.InstrumentDescriptors.ForEach(instrumentDescriptor => {
         instrumentDescriptor.ProviderDescriptors.ForEach(providerDescriptor => {
             Convert(providerDescriptor.Path);
         });
     });
 }
コード例 #5
0
ファイル: Robot.cs プロジェクト: RomanS2N/trading
 private void SubscribeWatchers(SeriesDescriptor seriesDescriptor)
 {
     // un watcher por cada carpeta de proveedor de cada instrumento (porque no me anda el watcher con subdirectorios)
     seriesDescriptor.InstrumentDescriptors.ForEach(instrumentDescriptor => {
         instrumentDescriptor.ProviderDescriptors.ForEach(providerDescriptor => {
             // me quedo monitoreando el directorio
             _watchers.Add(CreateWatcher(providerDescriptor.Path));
         });
     });
 }
コード例 #6
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);
        }
コード例 #7
0
ファイル: UnitTest.cs プロジェクト: RomanS2N/trading
        public void TestMethod()
        {
            IBarsCreator creator = new BarsCreator(null, null, TimeSpan.FromMinutes(1), null);
            string       path    = new SeriesDescriptor()
                                   .InstrumentDescriptors.Single(x => x.Name == "EURUSD")
                                   .ProviderDescriptors.Single(x => x.Name == "Dukascopy")
                                   .Path;
            SeriesReader reader = new SeriesReader(path);
            DateTime     dateTime;
            decimal      ask, bid;

            while (reader.Next(out dateTime, out ask, out bid))
            {
                creator.AddQuote(dateTime, ask);
            }
        }
コード例 #8
0
ファイル: Robot.cs プロジェクト: RomanS2N/trading
 private void VerifyOldFiles(SeriesDescriptor seriesDescriptor)
 {
     seriesDescriptor.InstrumentDescriptors.ForEach(instrumentDescriptor => {
         instrumentDescriptor.ProviderDescriptors.ForEach(providerDescriptor => {
             // si no tiene VerificationReport, lo verifico
             Directory.GetFiles(providerDescriptor.Path, "*.csv").ToList().ForEach(csvFileName => {
                 string reportFileName     = csvFileName.Replace(".csv", ".xml");
                 VerificationReport report = VerificationReport.LoadFromFile(reportFileName);
                 if (report == null || !report.Verified)
                 {
                     Verify(csvFileName);
                 }
             });
         });
     });
 }
コード例 #9
0
ファイル: Program.cs プロジェクト: RomanS2N/trading
        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();
        }
コード例 #10
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);
        }
コード例 #11
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();
        }
コード例 #12
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var seriesDescriptor = new SeriesDescriptor();

            this.InstrumentsPanel.ItemsSource = seriesDescriptor.ChildDescriptors;
        }