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);
        }
        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 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 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;
        }