コード例 #1
0
        public void RequestWithMoreThan10KMinuteObservationIsCorrectlySaved()
        {
            // Arrange
            var resolution = Resolution.Minute;
            var startDate  = new DateTime(year: 2013, month: 04, day: 01);
            var endDate    = startDate.AddMonths(months: 1);

            // Act
            _downloader.Run(_eurusd, resolution, startDate, endDate);
            // Assert
            var outputFolder = Path.Combine(_dataDirectory, "forex/fxcm/minute");
            var files        = Directory.GetFiles(outputFolder, "*_volume.zip", SearchOption.AllDirectories);

            Assert.AreEqual(expected: 27, actual: files.Length);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            if (args.Length != 4)
            {
                Console.WriteLine("Usage: FxcmVolumeDownloader SYMBOLS RESOLUTION FROMDATE TODATE");
                Console.WriteLine("SYMBOLS = eg EURUSD,USDJPY\n" +
                                  "\tAvailable pairs:\n" +
                                  "\tEURUSD, USDJPY, GBPUSD, USDCHF, EURCHF, AUDUSD, USDCAD,\n" +
                                  "\tNZDUSD, EURGBP, EURJPY, GBPJPY, EURAUD, EURCAD, AUDJPY");
                Console.WriteLine("RESOLUTION = Minute/Hour/Daily/All");
                Console.WriteLine("FROMDATE = yyyymmdd");
                Console.WriteLine("TODATE = yyyymmdd");
                Environment.Exit(exitCode: 1);
            }

            try
            {
                Log.DebuggingEnabled = true;
                Log.LogHandler       = new CompositeLogHandler(new ConsoleLogHandler(), new FileLogHandler("FxcmFxVolumeDownloader.log", useTimestampPrefix: false));

                // Load settings from command line
                var tickers     = args[0].Split(',');
                var resolutions = new[] { Resolution.Daily };

                if (args[1].ToLower() == "all")
                {
                    resolutions = new[] { Resolution.Daily, Resolution.Hour, Resolution.Minute };
                }
                else
                {
                    resolutions[0] = (Resolution)Enum.Parse(typeof(Resolution), args[1]);
                }

                var startDate = DateTime.ParseExact(args[2], "yyyyMMdd", CultureInfo.InvariantCulture);
                var endDate   = DateTime.ParseExact(args[3], "yyyyMMdd", CultureInfo.InvariantCulture);

                // Load settings from config.json

                var dataDirectory = Config.Get("data-directory", "../../../Data");
                var downloader    = new FxcmVolumeDownloader(dataDirectory);
                foreach (var ticker in tickers)
                {
                    var symbol = Symbol.Create(ticker, SecurityType.Base, Market.FXCM);
                    foreach (var resolution in resolutions)
                    {
                        downloader.Run(symbol, resolution, startDate, endDate);
                    }
                }
            }
            catch (Exception err)
            {
                Log.Error(err);
            }
        }
コード例 #3
0
        public static void FxcmVolumeDownload(IList <string> tickers, string resolution, DateTime startDate, DateTime endDate)
        {
            var isUpdate = false;

            if (resolution.IsNullOrEmpty())
            {
                if (!tickers.IsNullOrEmpty())
                {
                    var _tickers = tickers.First().ToLower();
                    if (_tickers == "all" || _tickers == "update")
                    {
                        if (_tickers == "update")
                        {
                            isUpdate = true;
                        }

                        tickers = new List <string> {
                            "EURUSD", "USDJPY", "GBPUSD", "USDCHF", "EURCHF", "AUDUSD", "USDCAD",
                            "NZDUSD", "EURGBP", "EURJPY", "GBPJPY", "EURAUD", "EURCAD", "AUDJPY"
                        };
                        resolution = "all";
                    }
                }
                else
                {
                    Console.WriteLine("Usage:\n\t" +
                                      "FxcmVolumeDownloader all\t will download data for all available pair for the three resolutions.\n\t" +
                                      "FxcmVolumeDownloader update\t will download just last day data for all pair and resolutions already downloaded.");
                    Console.WriteLine("Usage: FxcmVolumeDownloader --tickers= --resolution= --from-date= --to-date=");
                    Console.WriteLine("--tickers=eg EURUSD,USDJPY\n" +
                                      "\tAvailable pairs:\n" +
                                      "\tEURUSD, USDJPY, GBPUSD, USDCHF, EURCHF, AUDUSD, USDCAD,\n" +
                                      "\tNZDUSD, EURGBP, EURJPY, GBPJPY, EURAUD, EURCAD, AUDJPY");
                    Console.WriteLine("--resolution=Minute/Hour/Daily/All");
                    Environment.Exit(exitCode: 1);
                }
            }

            try
            {
                Log.DebuggingEnabled = true;
                Log.LogHandler       = new CompositeLogHandler(new ConsoleLogHandler(), new FileLogHandler("FxcmFxVolumeDownloader.log", useTimestampPrefix: false));

                var resolutions = new[] { Resolution.Daily };
                if (resolution.ToLower() == "all")
                {
                    resolutions = new[] { Resolution.Daily, Resolution.Hour, Resolution.Minute };
                }
                else
                {
                    resolutions[0] = (Resolution)Enum.Parse(typeof(Resolution), resolution);
                }

                // Load settings from config.json
                var dataDirectory = Config.Get("data-directory", "../../../Data");

                var downloader = new FxcmVolumeDownloader(dataDirectory);
                foreach (var ticker in tickers)
                {
                    var symbol = Symbol.Create(ticker, SecurityType.Base, Market.FXCM);
                    foreach (var _resolution in resolutions)
                    {
                        downloader.Run(symbol, _resolution, startDate, endDate, isUpdate);
                    }
                }
            }
            catch (Exception err)
            {
                Log.Error(err);
            }
        }