public Add_Investment(ref Portfolio p) { InitializeComponent(); ThisPortfolio = p; this.Icon = Properties.Resources.Stocks; }
public Add_Investment(ref Portfolio p, QueryResult qr) { InitializeComponent(); ThisPortfolio = p; tbCompanyName.Text = qr.Company; }
public static void FillPortfolioDatatable(ref DataGridView dgv, Portfolio pr) { foreach (Investment inv in pr.ListOfInvestments) { dgv.Rows.Add(inv.Stock.StockName, inv.Quantity, inv.UnitStockValue, inv.BuyTime, inv.Quantity * inv.UnitStockValue, new DataGridViewButtonCell()); } }
public DataStorageTests() { p = new Portfolio("TestPortfolio", "EUR"); date = new DateTime(2015, 12, 05, 16, 08, 20); p.addInvestment(new Investment(new Stock("GOOGL", "USD"), 1000, date, 600.6m)); }
private void compareToolStripMenuItem_Click(object sender, EventArgs e) { CompareStocks_Search css = new CompareStocks_Search(mainPortfolio); css.ShowDialog(); mainPortfolio = css.ThisPortfolio; UpdateGraph(); }
private void addStockToolStripMenuItem_Click(object sender, EventArgs e) { Search_Stock_Prices ssp = new Search_Stock_Prices(ref mainPortfolio); ssp.ShowDialog(); mainPortfolio = ssp.ThisPortfolio; UpdateGraph(); }
public CompareStocks_Search(Portfolio p) { InitializeComponent(); this.Icon = Properties.Resources.Stocks; ThisPortfolio = p; dateTimePicker1.Value = DateTime.Now.AddMonths(-1); dateTimePicker2.Value = DateTime.Now; }
private void addInvestmentToolStripMenuItem_Click(object sender, System.EventArgs e) { Add_Investment addStock = new Add_Investment(ref thisPortfolio); addStock.ShowDialog(); thisPortfolio = addStock.ThisPortfolio; updateGrid(thisPortfolio); }
public Search_Stock_Prices(ref Portfolio pt) { InitializeComponent(); this.Icon = Properties.Resources.Stocks; thisPortfolio = pt; dateTimePicker1.Value = DateTime.Now.AddMonths(-1); dateTimePicker2.Value = DateTime.Now; dateTimePicker2.MaxDate = dateTimePicker2.Value; }
/// <summary> /// Renders the graph on the Main Menu /// </summary> /// <param name="c">Reference to the chart to be Rendered</param> /// <param name="p">Portfolio Object to be Rendered in the graph</param> public static void renderMainMenuGraph(ref Chart c, Portfolio p, CurrencyExchanger ce, Dictionary<Investment, string> data) { c.Series["Profit"].Points.Clear(); List<ProfitDay> points = p.calculateProfit(ce, data); foreach(ProfitDay pd in points) { if (((pd.Day.DayOfWeek == DayOfWeek.Saturday || pd.Day.DayOfWeek == DayOfWeek.Sunday ) && pd.Profit == 0)) { //empty days, what to do? } else c.Series["Profit"].Points.AddXY(pd.Day, pd.Profit); } }
public Search_Results(QueryResult qr, ref Portfolio pt) { InitializeComponent(); label3.Text = qr.Company; label4.Text = qr.StockDays[0].Date.ToShortDateString(); label5.Text = qr.StockDays[qr.StockDays.Count - 1].Date.ToShortDateString(); thisPortfolio = pt; this.queryResult = qr; RenderGraph.renderSearchResultGraph(ref chart1, qr); DataDisplay.FillSearchResultsDatatable(ref dataGridView1, qr); lblAnalysis.Text = DataAnalysis.AnalyseQueryResults(qr); }
public PortfolioUI(ref Portfolio portfolio, ref CurrencyExchanger ce) { InitializeComponent(); this.Icon = Properties.Resources.Stocks; this.thisPortfolio = portfolio; UpdateGraph(); updateGrid(thisPortfolio); tbName.Text = thisPortfolio.Name; cbCurrency.DataSource = ce.GetCurrenciesRetrieved(); cbCurrency.SelectedItem = thisPortfolio.PreferredCurrency; }
public static void AnalysePortfolio(ref Chart c, Dictionary<Investment, string> invData, Portfolio p) { c.Series.Clear(); CurrencyExchanger ce = new CurrencyExchanger(); Dictionary<string, int> times = new Dictionary<string, int>(); c.Series.Add("Profits up to latest Information"); c.Series[0].ChartType = SeriesChartType.Bar; foreach (KeyValuePair<Investment, string> i in invData) { if (!times.ContainsKey(i.Key.Stock.StockName)) times.Add(i.Key.Stock.StockName, 0); List<ProfitDay> l = p.calculateProfits(ce, i.Key, i.Value); c.Series[0].Points.AddXY(i.Key.Stock.StockName, l[l.Count-1].Profit); } }
public CompareStocks(ref Portfolio p, QueryResult qr1, QueryResult qr2) { InitializeComponent(); this.Icon = Properties.Resources.Stocks; tbCompany1.Text = qr1.Company; tbCompany2.Text = qr2.Company; Graph_Rendering.RenderGraph.renderCompareStocksGraph(ref chartCompare, qr1, qr2); Graph_Rendering.RenderGraph.renderCompareAnalysisGraph(ref chart1, qr1, qr2); DataDisplay.FillSearchResultsDatatable(ref dataGridView1, qr1); DataDisplay.FillSearchResultsDatatable(ref dataGridView2, qr2); this.qr1 = qr1; this.qr2 = qr2; ThisPortfolio = p; addStock1ToolStripMenuItem.Text = "Add " + qr1.Company + " to Portfolio"; addStock2ToolStripMenuItem.Text = "Add " + qr2.Company + " to Portfolio"; }
public Main_Menu(ref Portfolio portfolio) { InitializeComponent(); this.Icon = Properties.Resources.Stocks; try { ce = new CurrencyExchanger(); } catch(WebException) { MessageBox.Show("Could not connect to the Internet!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } if(portfolio != null) this.mainPortfolio = portfolio; else { newPortfolio(); } }
/// <summary> /// Renders the graph on the Portfolio UI /// </summary> /// <param name="c">Reference to the chart to be Rendered</param> /// <param name="p">Portfolio Object to be Rendered in the graph</param> public static void renderPortfolioGraph(ref Chart c, Portfolio p, CurrencyExchanger ce, Dictionary<Investment, string> data) { renderMainMenuGraph(ref c, p, ce, data); }
private void myPortfolioToolStripMenuItem1_Click(object sender, EventArgs e) { PortfolioUI pUI = new PortfolioUI(ref mainPortfolio, ref ce); pUI.FormClosed += UpdateGraph; pUI.ShowDialog(); mainPortfolio = pUI.ThisPortfolio;//recover the portfolio object, that could have been changed saveMainPortfolio(); }
private void QueryFinished(object sender, RunWorkerCompletedEventArgs e) { int erros = 0; DownloaderResult[] dr = e.Result as DownloaderResult[]; for (int i = 0; i < 2; i++) if (dr[i].Error != null) { erros++; if (dr[i].ControlCausedError != null) errorProvider1.SetError(dr[i].ControlCausedError, dr[i].Error); else MessageBox.Show(dr[i].Error, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); bSearch.Text = "Search"; bSearch.Enabled = true; } if(erros == 0) { CompareStocks cs = new CompareStocks(ref thisPortfolio, dr[0].Result, dr[1].Result); cs.ShowDialog(); ThisPortfolio = cs.ThisPortfolio; this.Close(); } }
private void newPortfolio() { NewPortfolio np = new NewPortfolio(ce); var result2 = np.ShowDialog(); if (result2 == DialogResult.OK) { mainPortfolio = new Portfolio(np.PortfolioName, np.Currency); saveMainPortfolio(); } }
private void QueryFinished(object sender, RunWorkerCompletedEventArgs e) { DownloaderResult dr = e.Result as DownloaderResult; if(dr.Error != null) { if (dr.ControlCausedError != null) errorProvider1.SetError(dr.ControlCausedError, dr.Error); else MessageBox.Show(dr.Error, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); bSearch.Text = "Search"; bSearch.Enabled = true; } else { Search_Results sr = new Search_Results(dr.Result, ref thisPortfolio); sr.ShowDialog(); thisPortfolio = sr.ThisPortfolio; this.Close(); } }
/// <summary> /// Read Portfolio Object from file /// </summary> /// <param name="fileDirectory">Path and filename to where the file will be read</param> /// <returns></returns> public static Portfolio loadPortfolio(string file) { Portfolio portfolio = new Portfolio(); try { string fullPath = file; if (!file.EndsWith(".json")) fullPath += ".json"; TextReader stream = new StreamReader(fullPath); string json = stream.ReadToEnd(); JsonConvert.PopulateObject(json, portfolio); stream.Close(); } catch { throw new CouldNotLoadPortfolioException("Error while loading the new portfolio"); } return portfolio; }
private void updateGrid(Portfolio pt) { dataGridViewPortfolio.Rows.Clear(); dataGridViewPortfolio.Refresh(); DataDisplay.FillPortfolioDatatable(ref dataGridViewPortfolio, pt); UpdateGraph(); //If grid needs updating then chart does too }
private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e) { Portfolio newPortfolio; try { newPortfolio = Portfolio.loadPortfolio(openPortfolioDialog.FileName.Trim()); mainPortfolio = newPortfolio; } catch (CouldNotLoadPortfolioException ex) { MessageBox.Show(ex.Message, "Critical Warning", MessageBoxButtons.OK); } }
private void searchStocksToolStripMenuItem_Click(object sender, System.EventArgs e) { Search_Stock_Prices ssp = new Search_Stock_Prices(ref thisPortfolio); ssp.ShowDialog(); thisPortfolio = ssp.ThisPortfolio; UpdateGraph(); }