Exemple #1
0
        /// <summary>
        /// Yahoo Downloader Toolbox Project For LEAN Algorithmic Trading Engine.
        /// Original by @chrisdk2015, tidied by @jaredbroad
        /// </summary>
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage: YahooDownloader SYMBOL");
                Console.WriteLine("Usage: Place the data into your LEAN Data directory: /data/equity/usa/daily/SYMBOL.zip");
                Console.WriteLine("SYMBOL = eg SPY");
                Environment.Exit(1);
            }

            //Command line inputs: symbol
            var symbol = args[0];
            var dataDirectory = Config.Get("data-directory", "../../../Data");

            try
            {
                //Get Yahoo Downloader:
                var yahooDownloader = new YahooDataDownloader();
                var enumerableYahoo = yahooDownloader.Get(new Symbol(symbol), SecurityType.Equity, Resolution.Daily, DateTime.MinValue, DateTime.UtcNow);

                //Get LEAN Data Writer:
                var writer = new LeanDataWriter(SecurityType.Equity, Resolution.Daily, symbol, dataDirectory, "usa");
                writer.Write(enumerableYahoo);
            }
            catch (Exception err)
            {
                Log.Error("YahooDownloader(): Error: " + err.Message);
            }
        }
Exemple #2
0
        /// <summary>
        /// Yahoo Downloader Toolbox Project For LEAN Algorithmic Trading Engine.
        /// Original by @chrisdk2015, tidied by @jaredbroad
        /// </summary>
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage: YahooDownloader SYMBOL");
                Console.WriteLine("Usage: Place the data into your LEAN Data directory: /data/equity/usa/daily/SYMBOL.zip");
                Console.WriteLine("SYMBOL = eg SPY");
                Environment.Exit(1);
            }

            //Command line inputs: symbol
            var symbol        = args[0];
            var dataDirectory = Config.Get("data-directory", "../../../Data");

            try
            {
                //Get Yahoo Downloader:
                var yahooDownloader = new YahooDataDownloader();
                var enumerableYahoo = yahooDownloader.Get(new Symbol(symbol), SecurityType.Equity, Resolution.Daily, DateTime.MinValue, DateTime.UtcNow);

                //Get LEAN Data Writer:
                var writer = new LeanDataWriter(SecurityType.Equity, Resolution.Daily, symbol, dataDirectory, "usa");
                writer.Write(enumerableYahoo);
            }
            catch (Exception err)
            {
                Log.Error("YahooDownloader(): Error: " + err.Message);
            }
        }
Exemple #3
0
        /// <summary>
        /// Yahoo Downloader Toolbox Project For LEAN Algorithmic Trading Engine.
        /// Original by @chrisdk2015, tidied by @jaredbroad
        /// </summary>
        static void Main(string[] args)
        {
            if (args.Length != 4)
            {
                Console.WriteLine("Usage: YahooDownloader SYMBOLS RESOLUTION FROMDATE TODATE");
                Console.WriteLine("SYMBOLS = eg SPY,AAPL");
                Console.WriteLine("RESOLUTION = Daily");
                Console.WriteLine("FROMDATE = yyyymmdd");
                Console.WriteLine("TODATE = yyyymmdd");
                Environment.Exit(1);
            }

            try
            {
                // Load settings from command line
                var symbols    = args[0].Split(',');
                var resolution = (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");

                // Create an instance of the downloader
                const string market     = Market.USA;
                var          downloader = new YahooDataDownloader();

                foreach (var symbol in symbols)
                {
                    // Download the data
                    var sid          = SecurityIdentifier.GenerateEquity(symbol, market);
                    var symbolObject = new Symbol(sid, symbol);
                    var data         = downloader.Get(symbolObject, SecurityType.Equity, resolution, startDate, endDate);

                    // Save the data
                    var writer = new LeanDataWriter(SecurityType.Equity, resolution, symbolObject, dataDirectory, market);
                    writer.Write(data);
                }
            }
            catch (Exception err)
            {
                Log.Error("YahooDownloader(): Error: " + err.Message);
            }
        }
Exemple #4
0
        /// <summary>
        /// Yahoo Downloader Toolbox Project For LEAN Algorithmic Trading Engine.
        /// Original by @chrisdk2015, tidied by @jaredbroad
        /// </summary>
        static void Main(string[] args)
        {
            if (args.Length != 4)
            {
                Console.WriteLine("Usage: YahooDownloader SYMBOLS RESOLUTION FROMDATE TODATE");
                Console.WriteLine("SYMBOLS = eg SPY,AAPL");
                Console.WriteLine("RESOLUTION = Daily");
                Console.WriteLine("FROMDATE = yyyymmdd");
                Console.WriteLine("TODATE = yyyymmdd");
                Environment.Exit(1);
            }

            try
            {
                // Load settings from command line
                var symbols = args[0].Split(',');
                var resolution = (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");

                // Create an instance of the downloader
                const string market = Market.USA;
                var downloader = new YahooDataDownloader();

                foreach (var symbol in symbols)
                {
                    // Download the data
                    var sid = SecurityIdentifier.GenerateEquity(symbol, market);
                    var symbolObject = new Symbol(sid, symbol);
                    var data = downloader.Get(symbolObject, SecurityType.Equity, resolution, startDate, endDate);

                    // Save the data
                    var writer = new LeanDataWriter(SecurityType.Equity, resolution, symbolObject, dataDirectory, market);
                    writer.Write(data);
                }
            }
            catch (Exception err)
            {
                Log.Error(err);
            }
        }
Exemple #5
0
        /// <summary>
        /// Yahoo Downloader Toolbox Project For LEAN Algorithmic Trading Engine.
        /// Original by @chrisdk2015, tidied by @jaredbroad
        /// </summary>
        static void Main(string[] args)
        {
            //if (args.Length != 4)
            //{
            //    Console.WriteLine("Usage: YahooDownloader SYMBOLS RESOLUTION FROMDATE TODATE");
            //    Console.WriteLine("SYMBOLS = eg SPY,AAPL");
            //    Console.WriteLine("RESOLUTION = Daily");
            //    Console.WriteLine("FROMDATE = yyyymmdd");
            //    Console.WriteLine("TODATE = yyyymmdd");
            //    Environment.Exit(1);
            //}

            try
            {
                // Load settings from command line
                var symbols    = "GARAN,AKBNK".Split(',');
                var resolution = (Resolution)Enum.Parse(typeof(Resolution), "Daily");
                var startDate  = DateTime.ParseExact("20150101", "yyyyMMdd", CultureInfo.InvariantCulture);
                var endDate    = DateTime.ParseExact("20160101", "yyyyMMdd", CultureInfo.InvariantCulture);

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

                // Create an instance of the downloader
                const string market     = Market.USA;
                var          downloader = new YahooDataDownloader();

                foreach (var symbol in symbols)
                {
                    // Download the data
                    var symbolObject = Symbol.Create(symbol, SecurityType.Equity, market);
                    var data         = downloader.Get(symbolObject, resolution, startDate, endDate);

                    // Save the data
                    var writer = new LeanDataWriter(resolution, symbolObject, dataDirectory);
                    writer.Write(data);
                }
            }
            catch (Exception err)
            {
                Log.Error(err);
            }
        }
Exemple #6
0
        /// <summary>
        /// Yahoo Downloader Toolbox Project For LEAN Algorithmic Trading Engine.
        /// Original by @chrisdk2015, tidied by @jaredbroad
        /// </summary>
        public static void YahooDownloader(IList <string> tickers, string resolution, DateTime startDate, DateTime endDate)
        {
            if (resolution.IsNullOrEmpty() || tickers.IsNullOrEmpty())
            {
                Console.WriteLine("YahooDownloader ERROR: '--tickers=' or '--resolution=' parameter is missing");
                Console.WriteLine("--tickers=eg SPY,AAPL");
                Console.WriteLine("--resolution=Daily");
                Environment.Exit(1);
            }
            try
            {
                // Load settings from command line
                var castResolution = (Resolution)Enum.Parse(typeof(Resolution), resolution);

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

                // Create an instance of the downloader
                const string market     = Market.USA;
                var          downloader = new YahooDataDownloader();

                foreach (var ticker in tickers)
                {
                    // Download the data
                    var symbolObject = Symbol.Create(ticker, SecurityType.Equity, market);
                    var data         = downloader.Get(symbolObject, castResolution, startDate, endDate);

                    // Save the data
                    var writer = new LeanDataWriter(castResolution, symbolObject, dataDirectory);
                    writer.Write(data);
                }
            }
            catch (Exception err)
            {
                Log.Error(err);
            }
        }