public void SymbolTest()
        {
            var symbols = new List<Security>
            {
                new Security {Symbol = "XCS.TO"},
                new Security {Symbol = "XIU.TO"},
                new Security {Symbol = "GOOG"},
            };
            using (var tokenManager = new QuestradeApiTokenManager(new Configuration()))
            {
                var api = new QuestradeService(tokenManager, new InMemorySecurityRepository(), new InMemoryCategoryRepository());

                var quotes = api.GetSymbols(symbols);
            }
        }
        public void Test()
        {
            var portfolio = new Portfolio
            {
                Name = "Test Portfolio"
            };
            using (var tokenManager = new QuestradeApiTokenManager(new Configuration()))
            {
                var api = new QuestradeService(tokenManager, new InMemorySecurityRepository(), new InMemoryCategoryRepository());
                portfolio.Accounts = api.GetAccounts();

                foreach (var account in portfolio.Accounts)
                {
                    account.Positions = api.GetPositions(account);
                    account.Transactions = api.GetTransactions(account, new DateTime(2008, 1, 1), DateTime.Now);
                }
            }

            var quoter = new YahooStockService(new YahooServiceFactory());
            var reporter = new StringValueReporter(quoter);
            var report = reporter.GetReport(portfolio);

            Console.Out.Write(report);
        }
        public void WeightTest()
        {
            var categoryRepository = new InMemoryCategoryRepository();
            var category = categoryRepository.GetCategory("Security");
            var category2 = categoryRepository.GetCategory("Currency");
            var securityRepository = new InMemorySecurityRepository();
            var security = securityRepository.GetBySymbol("XSB.TO");
            var security2 = securityRepository.GetBySymbol("MSFT");

            using (var tokenManager = new QuestradeApiTokenManager(new Configuration()))
            {
                var api = new QuestradeService(tokenManager, securityRepository, categoryRepository);

                var weights = api.GetWeights(category, security);
                weights = api.GetWeights(category, security);
                weights = api.GetWeights(category, security2);
                weights = api.GetWeights(category2, security);
                weights = api.GetWeights(category2, security2);
            }
        }
        private static ErrorCode QuickQuestradeWeightReportOperation(string portfolioName)
        {
            var portfolio = new Portfolio
            {
                Name = portfolioName
            };
            var categoryRepository = new InMemoryCategoryRepository();
            var securityCategory = categoryRepository.GetCategory("Security");
            var currencyCategory = categoryRepository.GetCategory("Currency");
            using (var tokenManager = new QuestradeApiTokenManager(Configuration))
            {
                var api = new QuestradeService(tokenManager, new InMemorySecurityRepository(), categoryRepository);
                portfolio.Accounts = api.GetAccounts();
                var weights = new List<CategoryWeight>();

                foreach (var account in portfolio.Accounts)
                {
                    account.Positions = api.GetPositions(account);
                    foreach (var position in account.Positions)
                    {
                        weights.AddRange(api.GetWeights(securityCategory, position.Security));
                        weights.AddRange(api.GetWeights(currencyCategory, position.Security));
                    }
                }

                var reporter = new StringWeightReporter(api);
                var report = reporter.GetReport(portfolio, new[] {securityCategory, currencyCategory}, weights.Distinct());

                Console.Write(report);
            }

            return ErrorCode.NoError;
        }
        private static ErrorCode QuickQuestradeValueReportOperation(string portfolioName)
        {
            var portfolio = new Portfolio
            {
                Name = portfolioName
            };
            using (var tokenManager = new QuestradeApiTokenManager(Configuration))
            {
                var api = new QuestradeService(tokenManager, new InMemorySecurityRepository(), new InMemoryCategoryRepository());
                portfolio.Accounts = api.GetAccounts();

                foreach (var account in portfolio.Accounts)
                {
                    account.Positions = api.GetPositions(account);
                    account.Transactions = api.GetTransactions(account, new DateTime(2008, 1, 1), DateTime.Now);
                }

                var reporter = new StringValueReporter(api);
                var report = reporter.GetReport(portfolio);

                Console.Write(report);
            }

            return ErrorCode.NoError;
        }
        private static ErrorCode QuestradeMonthReportOperation(string portfolioName)
        {
            var portfolio = new Portfolio
            {
                Name = portfolioName
            };
            using (var tokenManager = new QuestradeApiTokenManager(Configuration))
            {
                var api = new QuestradeService(tokenManager, new InMemorySecurityRepository(), new InMemoryCategoryRepository());
                portfolio.Accounts = api.GetAccounts();

                foreach (var account in portfolio.Accounts)
                {
                    account.Positions = api.GetPositions(account);
                }

                var service = new YahooStockService(new YahooServiceFactory());
                var reporter = new StringHistoricalReporter(service);
                var startDate = GetStartOfMarketWeek(DateTime.Now);
                var report = reporter.GetReport(portfolio, startDate.AddMonths(-1), startDate, Period.Weekly);

                Console.Write(report);
            }

            return ErrorCode.NoError;
        }