Example #1
0
        public bool BuildReadValues()
        {
            if (this.has_csv_file == true)
            {
                try
                {
                    this.readvalues = new CSVValues(this.csv_filepath);

                    File.Delete(this.csv_filepath);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return(false);
                }
            }
            else
            {
                Console.WriteLine("\n\nNo CSV file was found, building portfolio values from database.");
                this.readvalues = MYSQLEngine.ReadSource(this.eq);
            }

            return(true);
        }
        public void add(string stock, string tpstr)
        {
            ManifestValue[] newvalues = new ManifestValue[this.values.Length];

            short ii = 0;

            foreach (ManifestValue old in this.values)
            {
                newvalues[ii] = new ManifestValue(old.stock, old.targetpercentage);
                ii++;
            }

            this.values = new ManifestValue[this.values.Length + 1];

            ii = 0;

            foreach (ManifestValue newv in newvalues)
            {
                this.values[ii] = new ManifestValue(newv.stock, newv.targetpercentage);
                ii++;
            }

            this.values[ii] = new ManifestValue(stock, CSVValues.parse_decimal_str(stock, tpstr));
        }
Example #3
0
        private File_Status_Is ProcessYCAValue()  //   BUY LIST IS INITIALLY CONSTRUCTED HERE, BUT NOT POPULATED
        {
            short ii = 0;

            if (this.has_yca_file == true)
            {
                foreach (string line in File.ReadLines(this.yearly_contribution_filepath))
                {
                    if (ii == 0)
                    {
                        string instr = CSVValues.parse_decimal_str(line), parsedstr = "";

                        int sii = (instr.Length - 2);

                        foreach (char c in instr)
                        {
                            if (sii > 0)
                            {
                                parsedstr = parsedstr + c;
                            }

                            sii--;
                        }

                        try
                        {
                            int ycaint = Int32.Parse(parsedstr);

                            this.buylist = new BuyList(ycaint);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Failed to construct buylist from file " + this.yearly_contribution_filepath + " exception message: " + ex.Message);
                            return(File_Status_Is.File_Found_but_Parse_Failed);
                        }

                        try
                        {
                            MYSQLEngine.WriteYCA(this.eq, parsedstr);

                            return(File_Status_Is.File_Found_and_Parsed);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);

                            return(File_Status_Is.Failed);
                        }
                    }

                    ii++;
                }

                return(File_Status_Is.Failed);
            }
            else
            {
                this.buylist = new BuyList(Int32.Parse(MYSQLEngine.ReadYCA(this.eq)));

                return(File_Status_Is.No_File_Found);
            }
        }