Esempio n. 1
0
        public void GetCompanyTest()
        {
            IEXClientHandler response = new IEXClientHandler();
            var data = this._clientHandler.GetCompany(this._testSymbol);

            Assert.NotNull(data);
            Assert.IsTrue(!string.IsNullOrEmpty(data.companyName));
        }
Esempio n. 2
0
        public void GetHistoricDataTest()
        {
            IEXClientHandler response = new IEXClientHandler();
            List <Chart>     data     = this._clientHandler.GetHistoricData(this._testSymbol, ChartOption._1m);

            Assert.NotNull(data);
            Assert.True(data.Count >= 1);
        }
Esempio n. 3
0
        public void GetQuoteTest()
        {
            IEXClientHandler response = new IEXClientHandler();
            var data = this._clientHandler.GetQuote(this._testSymbol);

            Assert.NotNull(data);
            Assert.IsTrue(data.latestPrice > 0);
        }
Esempio n. 4
0
        public void GetKeyStatTest()
        {
            IEXClientHandler response = new IEXClientHandler();
            var data = this._clientHandler.GetKeyStats(this._testSymbol);

            Assert.NotNull(data);
            Assert.IsTrue(data.SharesOutstanding > 10_000);
        }
Esempio n. 5
0
        internal static void InsertBatch(IEnumerable <CIKInfo> cikInfos, List <IEXDataType> listIexDataTypes, ChartOption chartOption, int itemCount, Period period)
        {
            int total      = cikInfos.Count();
            int count      = 0;
            int batchCount = 50;
            CompanyCollection companyRepo = new CompanyCollection();

            do
            {
                var symbols = cikInfos.Select(x => x.Ticker).Skip(count).Take(batchCount).ToArray();
                count += symbols.Count();

                var dictSymbolComp = companyRepo.GetCompanyId(symbols.ToList());
                //get data
                IEXClientHandler response = new IEXClientHandler();
                var results = response.GetBatchReport(symbols, listIexDataTypes, ChartOption._1d, itemCount, period);


                //insert to db
                var comp  = new MongoDBRepository <Company>(nameof(Company));
                var stat  = new MongoDBRepository <Stat>("IEXStat");
                var fin   = new MongoDBRepository <Financial>(nameof(Financial));
                var quote = new MongoDBRepository <Quote>("Quote");


                foreach (string symbol in results.Keys)
                {
                    ObjectId compId = ObjectId.GenerateNewId(); //ObjectId.GenerateNewId().ToString();
                    results[symbol].Company._id = compId;
                    if (results[symbol].Company != null)
                    {
                        comp.MongoInsert(results[symbol].Company).Wait();
                    }

                    if (results[symbol].Stat != null)
                    {
                        results[symbol].Stat.companyId = compId;
                        stat.MongoInsert(results[symbol].Stat).Wait();
                    }

                    if (results[symbol].Financials.financials != null)
                    {
                        Parallel.For(0, results[symbol].Financials.financials.Count, (i) =>
                        {
                            results[symbol].Financials.financials[i].companyId = compId;
                        });

                        fin.MongoInsertMany(results[symbol].Financials.financials).Wait();
                    }

                    if (results[symbol].Quote != null)
                    {
                        results[symbol].Quote.companyId = compId;
                        quote.MongoInsert(results[symbol].Quote).Wait();
                    }
                }
            } while (count < total);
        }
Esempio n. 6
0
        public void GetBatchReportMultiSymbolsTest()
        {
            IEXClientHandler response = new IEXClientHandler();
            var tickers = new string[] { "ipar", "ge", "docu" };
            var data    = this._clientHandler.GetBatchReport(tickers,
                                                             new List <IEXDataType> {
                IEXDataType.quote, IEXDataType.news, IEXDataType.chart
            },
                                                             ChartOption._1m,
                                                             1);

            Assert.NotNull(data);
            Assert.AreEqual(data.Count, tickers.Length);
        }
Esempio n. 7
0
        public void GetBatchReportTest()
        {
            IEXClientHandler response = new IEXClientHandler();
            var data = this._clientHandler.GetBatchReport(this._testSymbol,
                                                          new List <IEXDataType> {
                IEXDataType.quote, IEXDataType.news, IEXDataType.chart
            },
                                                          ChartOption._1m,
                                                          1);

            Assert.NotNull(data);
            Assert.NotNull(data.Quote);
            Assert.NotNull(data.NewsList);
            Assert.NotNull(data.Charts);
        }
Esempio n. 8
0
        public void BatchProcessSymbolsTest()
        {
            //getting list of company
            string[] symbols = new string[] { "ge", "appl", "msft", "ipar", "gntx" };
            //get data
            IEXClientHandler response = new IEXClientHandler();
            var results = response.GetBatchReport(symbols, new List <IEXDataType> {
                IEXDataType.company
            }, IEXApiHandler.IEXData.Stock.ChartOption._1d, 1);

            Assert.NotNull(results);
            //insert to db
            CompanyCollection repo = new CompanyCollection();

            repo.MongoInsertMany(results.Values.Select(x => x.Company).Distinct().ToList()).Wait();
        }
Esempio n. 9
0
        internal static void InsertChartData(IEnumerable <CIKInfo> cikInfos)
        {
            IEXClientHandler  response = new IEXClientHandler();
            CompanyCollection compColl = new CompanyCollection();

            //symbols from list
            var symbols = cikInfos.Select(x => x.Ticker).ToList();

            //checking for company exists in db
            var dictComp = compColl.GetCompanyId(symbols);

            //insert to db
            var chartCollection = new MongoDBRepository <Chart>("Charts");

            foreach (string symbol in dictComp.Keys)
            {
                try
                {
                    var results = response.GetBatchReport(symbol, new List <IEXDataType> {
                        IEXDataType.chart
                    }, ChartOption._5y, 100);

                    if (!dictComp.ContainsKey(symbol))
                    {
                        Console.WriteLine($"Not data for symbol {symbol}.");
                        continue;
                    }

                    //update charts with companyId
                    Parallel.For(0, results.Charts.Count, (i) =>
                    {
                        results.Charts[i].companyId = dictComp[symbol];
                    });

                    chartCollection.MongoInsertMany(results.Charts).Wait();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
        }
Esempio n. 10
0
        internal static void InsertCompanyData(IEnumerable <CIKInfo> cikInfos)
        {
            int total      = cikInfos.Count();
            int count      = 0;
            int batchCount = 50;

            do
            {
                var symbols = cikInfos.Select(x => x.Ticker).Skip(count).Take(batchCount).ToArray();
                count += symbols.Count();

                //get data
                IEXClientHandler response = new IEXClientHandler();
                var results = response.GetBatchReport(symbols, new List <IEXDataType> {
                    IEXDataType.company
                }, IEXApiHandler.IEXData.Stock.ChartOption._1d, 1);

                //insert to db
                var comp = new MongoDBRepository <Company>("Company");
                //repo.MongoInsert(results.Values.Select(x => x.Company).Distinct().ToList()).Wait();
                comp.MongoInsertMany(results.Values.Select(x => x.Company).Distinct().ToList()).Wait();
            } while (count < total);
        }
Esempio n. 11
0
 public IEXApiTests()
 {
     _clientHandler = new IEXClientHandler();
 }