Beispiel #1
0
 public void RefreshBindings()
 {
     dataGridView1.DataSource = null;
        // dataGridView1.DataSource = fund.FundHistory;
     Fund ReverseFund = new Fund();
     for (int i = 0; i < fund.FundHistory.Count; i++)
     {
         ReverseFund.AddProc(fund.FundHistory[fund.FundHistory.Count - i - 1]);
     }
     dataGridView1.DataSource = ReverseFund.FundHistory;
 }
Beispiel #2
0
        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;
            }
        }
Beispiel #3
0
        public FundForm(Fund fundTemp)
        {
            fund = fundTemp;

            this.Text = fund.Name;
            InitializeComponent();
            dataGridView1.AutoGenerateColumns = false;
            RefreshBindings();
            DataGridViewTextBoxColumn  col = new DataGridViewTextBoxColumn();
            col.DataPropertyName = "WeeklyDate";
            col.Name = "Date";
            dataGridView1.Columns.Add(col);

            col = new DataGridViewTextBoxColumn();
            col.DataPropertyName = "StockPick";
            col.Name = "Pick";
            dataGridView1.Columns.Add(col);

            col = new DataGridViewTextBoxColumn();
            col.DataPropertyName = "PortfolioValue";
            col.Name = "Value";
            dataGridView1.Columns.Add(col);
        }