Example #1
0
        public void B3ProviderMustDownloadHistoricQuoteFiles()
        {
            var config = new B3Provider.B3ProviderConfig();

            config.ReplaceExistingFiles = true;

            var client = new B3Provider.B3ProviderClient(config);

            client.LoadHistoricQuotes(2018);

            var quotesPETR4 = client.GetHistoricMarketData().Where(e => e.Ticker.Equals("PETR4")).OrderByDescending(e => e.TradeDate).ToList();
        }
Example #2
0
        public void B3ProviderMustDownloadInstrumentFiles()
        {
            var config = new B3Provider.B3ProviderConfig();

            config.ReplaceExistingFiles = true;

            var client = new B3Provider.B3ProviderClient(config);

            client.LoadInstruments();

            Assert.IsNotNull(client.EquityInstruments);
            Assert.IsNotNull(client.OptionInstruments);

            Assert.AreNotEqual(0, client.EquityInstruments.Count);
            Assert.AreNotEqual(0, client.OptionInstruments.Count);
        }
Example #3
0
        public void B3ProviderMustDownloadQuoteFiles()
        {
            var config = new B3Provider.B3ProviderConfig();

            config.ReplaceExistingFiles = true;

            var client = new B3Provider.B3ProviderClient(config);

            client.LoadQuotes();

            // get information about PETR4 stock (the most popular in B3)
            var petr4 = client.CurrentMarketData.Where(e =>
                                                       e.Ticker.Equals("PETR4", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

            var usim5 = client.CurrentMarketData.Where(e =>
                                                       e.Ticker.Equals("USIM5", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

            var bbdc4 = client.CurrentMarketData.Where(e =>
                                                       e.Ticker.Equals("BBDC4", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
        }
Example #4
0
        public void B3ProviderMustDownloadHistoricQuoteFilesGetUtilDates()
        {
            Logger logger = TestLogManager.Instance.GetLogger("B3ProviderTester");

            logger.Info("teste");


            var config = new B3Provider.B3ProviderConfig();

            config.ReplaceExistingFiles = true;

            var client = new B3Provider.B3ProviderClient(config);

            logger.Info("inicio 2018");
            client.LoadHistoricQuotes(2018);
            logger.Info("fim 2018");
            client.LoadHistoricQuotes(2017);

            DateTime?utilDatesStart = null;
            var      utilDates      = utilDatesStart.UtilDates(null);
            var      quotesPETR4    = client.GetHistoricMarketData().Where(e => e.Ticker.Equals("PETR4")).OrderByDescending(e => e.TradeDate).ToList();

            var currentQuote   = quotesPETR4.Where(e => e.TradeDate == utilDates.CurrentDate).FirstOrDefault();
            var oneDayQuote    = quotesPETR4.Where(e => e.TradeDate == utilDates.OneDayDate).FirstOrDefault();
            var oneWeekQuote   = quotesPETR4.Where(e => e.TradeDate == utilDates.OneWeekDate).FirstOrDefault();
            var oneMonthQuote  = quotesPETR4.Where(e => e.TradeDate == utilDates.OneMonthDate).FirstOrDefault();
            var oneQuarteQuote = quotesPETR4.Where(e => e.TradeDate == utilDates.OneQuarterDate).FirstOrDefault();
            var oneYearQuote   = quotesPETR4.Where(e => e.TradeDate == utilDates.OneYearDate).FirstOrDefault();

            var varDiaria     = ((currentQuote?.Last ?? 1) / (oneDayQuote?.Last ?? 1)) - 1;
            var varSemanal    = ((currentQuote?.Last ?? 1) / (oneWeekQuote?.Last ?? 1)) - 1;
            var varMensal     = ((currentQuote?.Last ?? 1) / (oneMonthQuote?.Last ?? 1)) - 1;
            var varTrimestral = ((currentQuote?.Last ?? 1) / (oneQuarteQuote?.Last ?? 1)) - 1;
            var varAnual      = ((currentQuote?.Last ?? 1) / (oneYearQuote?.Last ?? 1)) - 1;

            var WTDQuote = quotesPETR4.Where(e => e.TradeDate == utilDates.WTDDate).FirstOrDefault();
            var MTDQuote = quotesPETR4.Where(e => e.TradeDate == utilDates.MTDDate).FirstOrDefault();
            var QTDQuote = quotesPETR4.Where(e => e.TradeDate == utilDates.QTDDate).FirstOrDefault();
            var YTDQuote = quotesPETR4.Where(e => e.TradeDate == utilDates.YTDDate).FirstOrDefault();
        }