Пример #1
0
 static void Main(string[] args)
 {
     string[] stocks = InvestingToolkit.GetEquityGroupAsync(EquityGroup.SP500).Result;
     foreach (string s in stocks)
     {
         HistoricalDataProvider hdp = new HistoricalDataProvider();
         Console.Write("Working on " + s + "... ");
         hdp.DownloadHistoricalDataAsync(s, new DateTime(2010, 1, 1), new DateTime(2011, 1, 1)).Wait();
         if (hdp.DownloadResult == HistoricalDataDownloadResult.Successful)
         {
             Console.WriteLine(hdp.HistoricalData.Length.ToString());
         }
         else if (hdp.DownloadResult == HistoricalDataDownloadResult.DataDoesNotExistForSpecifiedTimePeriod)
         {
             Console.WriteLine("Data did not exist at the time!");
         }
         else if (hdp.DownloadResult == HistoricalDataDownloadResult.Unauthorized)
         {
             Console.WriteLine("Unauthorized!!!!!");
         }
         else if (hdp.DownloadResult == HistoricalDataDownloadResult.NoDataFound)
         {
             Console.WriteLine("Stock symbol not found.");
         }
         else
         {
             Console.WriteLine("Idk... " + hdp.DownloadResult.ToString());
         }
     }
 }
Пример #2
0
        static void TestSp500()
        {
            string[]      sp500  = InvestingToolkit.GetEquityGroupAsync(EquityGroup.SP500).Result;
            List <string> Errors = new List <string>();
            int           t      = 0;

            foreach (string s in sp500)
            {
                Console.Write("Working on " + s + "... ");
                t = t + 1;
                try
                {
                    EquityStatisticalData esd = EquityStatisticalData.CreateAsync(s).Result;
                    float pdone = (float)t / (float)sp500.Length;
                    Console.WriteLine("success... " + pdone.ToString("#0.0%"));
                }
                catch (Exception e)
                {
                    Console.WriteLine("FAILURE! " + e.Message);
                    Errors.Add(s);
                }
            }


            Console.WriteLine("Done!");
            Console.WriteLine("Critical errors:");
            foreach (string s in Errors)
            {
                Console.WriteLine(s);
            }
        }
Пример #3
0
        public static void FullSp500Test()
        {
            Console.WriteLine("Getting sp500...");
            string[] sp500 = InvestingToolkit.GetEquityGroupAsync(EquityGroup.SP500).Result;

            HttpClient hc = new HttpClient();

            List <string> Failures = new List <string>();
            int           t        = 1;

            foreach (string s in sp500)
            {
                Console.Write("Tring " + s + " (" + t.ToString() + "/" + sp500.Length.ToString() + ")... ");
                try
                {
                    EdgarSearch es = EdgarSearch.CreateAsync(s, "4", null, EdgarSearchOwnershipFilter.only).Result;
                    foreach (EdgarSearchResult esr in es.Results)
                    {
                        if (esr.Filing == "4")
                        {
                            FilingDocument[] docs = esr.GetDocumentFormatFilesAsync().Result;
                            foreach (FilingDocument fd in docs)
                            {
                                if (fd.DocumentName.ToLower().Contains(".xml"))
                                {
                                    //Console.WriteLine("Tryng to get " + fd.Url + " ...");
                                    HttpResponseMessage hrm = hc.GetAsync(fd.Url).Result;
                                    string content          = hrm.Content.ReadAsStringAsync().Result;
                                    StatementOfBeneficialOwnership form4 = StatementOfBeneficialOwnership.ParseXml(content);
                                }
                            }
                        }
                    }
                    Console.WriteLine("Success");
                }
                catch
                {
                    Failures.Add(s);
                    Console.WriteLine("FAILURE!");
                }
                t = t + 1;
            }

            Console.WriteLine("DONE!");
            Console.WriteLine("Failures:");
            foreach (string s in Failures)
            {
                Console.WriteLine(s);
            }
        }