public UniverseAdjuster(TrendUniverse UniverseAdjusterCollection) { InitializeComponent(); DataGridViewColumn col = new DataGridViewTextBoxColumn(); Universe.CopyContents(UniverseAdjusterCollection); UniBindSource.DataSource = Universe.TrendsUniverseContents; dgv_Universe.AutoGenerateColumns = false; dgv_Universe.DataSource = UniBindSource; col.DataPropertyName = "Symbol"; dgv_Universe.Columns.Add(col); StocksToAdd.TrendsUniverseContents.AllowNew = true; dgv_StocksToAdd.AutoGenerateColumns = false; AddSource.DataSource = StocksToAdd.TrendsUniverseContents; dgv_StocksToAdd.DataSource = AddSource; col = new DataGridViewTextBoxColumn(); col.DataPropertyName = "Symbol"; dgv_StocksToAdd.Columns.Add(col); StocksToDelete.TrendsUniverseContents.AllowNew = true; dgv_StocksToDelete.AutoGenerateColumns = false; DeleteSource.DataSource = StocksToDelete.TrendsUniverseContents; dgv_StocksToDelete.DataSource = DeleteSource; col = new DataGridViewTextBoxColumn(); col.DataPropertyName = "Symbol"; dgv_StocksToDelete.Columns.Add(col); label_Count.Text = Universe.TrendsUniverseContents.Count.ToString(); Universe.TrendsUniverseContents.ListChanged += new ListChangedEventHandler(StockUniverseContents_ListChanged); }
public StockPickerForm()//Loads form independently from program allowing it to be used as a separate entity. { TrendUni = new TrendUniverse(); bs.DataSource = TrendUni.TrendsUniverseContents; InitializeComponent(); mostRecentFriday(); dataGridView1.DataSource = bs; label_Date.Text = monthCalendar1.SelectionStart.ToShortDateString(); button_Return.Enabled = false; }
public static Fund NewFundFromPortfolio(string openLocation, DateTime date) { Fund fund = new Fund(); Portfolio port = new Portfolio(); Processor proc = new Processor(); TrendUniverse SU = new TrendUniverse(); proc.Portfolio = port; proc.WeeklyDate = Convert.ToDateTime(date.ToShortDateString()); proc.StockPick = "Stock Pick"; proc.Universe = SU; fund.AddProc(proc); using (System.IO.StreamReader sr = new StreamReader(openLocation)) { string unparsedCSV = sr.ReadToEnd(); //Stock name, Lot, Holdings, purchase price, date, high alert, low alert. 6 items looping string[] parsedCSV = unparsedCSV.Replace("\n", " ").Replace(" ", ",").Split(','); int LotCounter = 0; while (LotCounter < parsedCSV.Length) { string stockName = parsedCSV[LotCounter + 0]; if (stockName == "ZZZCASH") { port.Cash = Convert.ToDecimal(parsedCSV[LotCounter + 2]); break; } int lotNumber = Convert.ToInt16(parsedCSV[LotCounter + 1]); decimal holdings = Convert.ToDecimal(parsedCSV[LotCounter + 2]); parsedCSV[LotCounter +3] = parsedCSV[LotCounter + 3].Replace("$", ""); decimal purchasePrice = Convert.ToDecimal(parsedCSV[LotCounter + 3]); DateTime purchaseDate = Convert.ToDateTime(parsedCSV[LotCounter + 4]); decimal highAlert = Convert.ToDecimal(parsedCSV[LotCounter + 5]); decimal lowAlert = Convert.ToDecimal(parsedCSV[LotCounter + 6]); Lot lot = new Lot(stockName, Trends.PriceBySymbol(stockName, date),lotNumber,holdings,purchasePrice,purchaseDate,highAlert,lowAlert); fund.FundHistory[0].Portfolio.Add(lot); LotCounter = LotCounter + 7; } port.CalcPortfolioValue(); return fund; } }
public StockPickerForm(TrendUniverse StockUni, WeeklyProcessor parent) { FormParent = parent; TrendUni = FormParent.weeksProcessData.Universe; bs.DataSource = TrendUni.TrendsUniverseContents; InitializeComponent(); dataGridView2.AutoGenerateColumns = false; dataGridView2.DataSource = TrendUni.TrendsUniverseContents; DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); col.DataPropertyName = "Symbol"; dataGridView2.Columns.Add(col); dataGridView1.DataSource = TrendUni.TrendsUniverseContents; monthCalendar1.SelectionEnd = FormParent.weeksProcessData.WeeklyDate; label_Date.Text = FormParent.weeksProcessData.WeeklyDate.ToShortDateString(); monthCalendar1.Enabled = false; }
public void CopyContents(TrendUniverse TrendsUniverse) //Use this to make two portfolios contain the same items. Avoid using TrendsUniverse A = B as this changes bindingSource target. { _TrendsUniverseContents.Clear(); foreach (Trends stock in TrendsUniverse.TrendsUniverseContents) { this.Add(stock.Symbol); } }
public static TrendUniverse OpenTrendsUniverse(string openLocation) { string extension = Path.GetExtension(openLocation); TrendUniverse temp = new TrendUniverse(); if (extension == ".pfo") { using (System.IO.StreamReader sr = new StreamReader(openLocation)) { String line; while ((line = sr.ReadLine()) != null) { Trends stock = new Trends(line); temp.Add(stock); } return temp; } } else if (extension == ".csv") { using (System.IO.StreamReader sr = new StreamReader(openLocation)) { string unparsedCSV = sr.ReadToEnd(); string[] parsedCSV = unparsedCSV.Replace("\n", " ").Replace(" ", ",").Split(','); foreach (string parsedCSVstockMember in parsedCSV) { string tempString = parsedCSVstockMember; tempString = parsedCSVstockMember.Replace("\r", ""); if (parsedCSVstockMember != "") { Trends stock = new Trends(parsedCSVstockMember); temp.Add(tempString); } } return temp; } } else { throw new FileLoadException("Only accepts file types of *.pfo or *.csv"); } }
private void button_InputChanges_Click(object sender, EventArgs e) { bool errorTriggered = false; List<string> errorMessage = new List<string>(); TrendUniverse AddBuffer = new TrendUniverse(); TrendUniverse DeleteBuffer = new TrendUniverse(); AddBuffer.CopyContents(StocksToAdd);// Use buffers to store add and delete data DeleteBuffer.CopyContents(StocksToDelete); foreach (Trends stock in StocksToAdd.TrendsUniverseContents) // Checks to see if added stock is already in list { if (Universe.Contains(stock.Symbol)) { errorTriggered = true; errorMessage.Add(stock.Symbol); } } foreach (Trends stock in StocksToDelete.TrendsUniverseContents) //Checks to see if deleted stock is not in list { if (!(Universe.Contains(stock.Symbol))) { errorTriggered = true; errorMessage.Add(stock.Symbol); } } if (errorTriggered) { string errors = string.Join(", ", errorMessage.ToArray()); MessageBox.Show("Error: The following stocks you are attempting to add/remove are either already in the universe, or not in it to be removed \n" + errors); return; } foreach (Trends stock in StocksToAdd.TrendsUniverseContents) { if(!(string.IsNullOrEmpty(stock.Symbol))) Universe.Add(stock); } foreach (Trends stock in StocksToDelete.TrendsUniverseContents) { Universe.Remove(stock.Symbol); } AddSource.Clear(); DeleteSource.Clear(); }
private void button_Finish_Click(object sender, EventArgs e) { if (FormType == 1) { if (DoneProcessing) { TrendUniverse stockTemp = new TrendUniverse(); stockTemp.CopyContents(weeksProcessData.Universe); weeksProcessData.Universe = stockTemp; FormParent.fund.AddProc(weeksProcessData); FormParent.RefreshBindings(); this.Close(); } else { MessageBox.Show("Complete the processing before finalizing"); } } else { this.Close(); } }