private static ErrorCode QuickFundbotWeightReportOperation(string portfolioName) { var dataDir = Path.GetFullPath(Environment.ExpandEnvironmentVariables(Configuration.DataDirectoryPath)); if (!Directory.Exists(dataDir)) { Console.Error.WriteLine("Data directory at {0} does not exist.", dataDir); return ErrorCode.DirectoryMissing; } var fundbotBuysFile = Path.Combine(dataDir, "buys.csv"); if (!File.Exists(fundbotBuysFile)) { Console.Error.WriteLine("Fundbot file at {0} does not exist.", fundbotBuysFile); return ErrorCode.FileMissing; } var fundbotCategoriesFile = Path.Combine(dataDir, "categories.csv"); if (!File.Exists(fundbotCategoriesFile)) { Console.Error.WriteLine("Fundbot file at {0} does not exist.", fundbotCategoriesFile); return ErrorCode.FileMissing; } var factory = new DataImporterFactory(); var transactionReader = factory.GetFundbotTransactions(fundbotBuysFile); var transactions = transactionReader.GetTransactions(); var account = new Account { Name = portfolioName }; var portfolio = new Portfolio { Name = portfolioName, Accounts = new List<Account> { account } }; account.Portfolio = portfolio; foreach (var transaction in transactions) { transaction.Account = account; } var portfolioService = new PortfolioService(portfolio); portfolioService.UpdateWith(transactions); var categoryReader = factory.GetFundbotCategories(fundbotCategoriesFile); IEnumerable<Category> categories; IEnumerable<CategoryWeight> weights; categoryReader.GetCategoriesAndWeights(out categories, out weights); var quoter = new YahooStockService(new YahooServiceFactory()); StringWeightReporter reporter = new StringWeightReporter(quoter); var report = reporter.GetReport(portfolio, categories, weights); Console.Write(report); return ErrorCode.NoError; }
private static ErrorCode ImportFundbotOperation(string portfolioName) { var dataDir = Path.GetFullPath(Environment.ExpandEnvironmentVariables(Configuration.DataDirectoryPath)); if (!Directory.Exists(dataDir)) { Console.Error.WriteLine("Data directory at {0} does not exist.", dataDir); return ErrorCode.DirectoryMissing; } var fundbotBuysFile = Path.Combine(dataDir, "buys.csv"); if (!File.Exists(fundbotBuysFile)) { Console.Error.WriteLine("Fundbot file at {0} does not exist.", fundbotBuysFile); return ErrorCode.FileMissing; } var factory = new DataImporterFactory(); var fundBotImporter = factory.GetFundbotTransactions(fundbotBuysFile); var transactions = fundBotImporter.GetTransactions(); // which portfolio? account? var account = new Account { Name = portfolioName }; var portfolio = new Portfolio { Name = portfolioName, Accounts = new List<Account> { account } }; account.Portfolio = portfolio; foreach (var transaction in transactions) { transaction.Account = account; } var portfolioService = new PortfolioService(portfolio); portfolioService.UpdateWith(transactions); var quoter = new YahooStockService(new YahooServiceFactory()); var reporter = new StringValueReporter(quoter); var report = reporter.GetReport(portfolio); Console.Write(report); //foreach (var transaction in transactions) //{ // // need to see if security already exists // // need to see if transaction already exists // // key = symbol & date & shares //} return ErrorCode.NoError; }