Exemplo n.º 1
0
        public void Load_Securities()
        {
            if (IsLoaded)
            {
                // The household's securities are already loaded, don't do anything
                return;
            }

            // The securities have not already been loaded for this household
            const string positionPath = FormStart.PositionPath;

            positionCSVData = CSVMethods.Get_CSV_Data(positionPath);

            // Get a list of every security in the accounts, but only one instance of each
            foreach (Account account in Accounts)
            {
                // Get the account's securities from the CSV data
                Account.Parse_Securities_From_CSV(positionCSVData, account);

                foreach (Security security in account.Securities)
                {
                    // See if the security is on the master list already
                    if (!FormHousehold.MasterTickerList.Contains(security.Ticker))
                    {
                        // The security's not on the master list, add it
                        FormHousehold.MasterTickerList.Add(security.Ticker);
                    }
                }
            }

            // The household's securities have been loaded
            IsLoaded = true;
        }
Exemplo n.º 2
0
        public static List <Household> Load_List_From_CSV(string path)
        {
            // Get the data from the csv file
            List <string[]> csvData = CSVMethods.Get_CSV_Data(path);

            // Get the household list from the csv data
            List <Household> householdList = Parse_Households_From_CSV_Data(csvData);

            // Combine households with the same ID
            Combine_Households(householdList);

            // Return the household list
            return(householdList);
        }
Exemplo n.º 3
0
        public static List <Security> Parse_Securities_From_CSV(List <string[]> csvData, Account account)
        {
            // Get the column headers from the csv data
            List <string> headerValues = CSVMethods.Get_Header_Values(csvData);

            // Load the information for positions in an account
            for (int csvRow = 1; csvRow < csvData.Count; csvRow++)
            {
                if (csvData[csvRow].Contains(account.ID))
                {
                    account.Securities.Add(Get_Position_From_CSV_Row(csvData[csvRow], headerValues));
                }
            }

            return(account.Securities);
        }
Exemplo n.º 4
0
        private static List <Household> Parse_Households_From_CSV_Data(List <string[]> csvData)
        {
            // Get the column headers from the csv data
            List <string> headerValues = CSVMethods.Get_Header_Values(csvData);

            // Instantiate the household list to return
            List <Household> householdList = new List <Household>();

            // Parse the account data from each row, starting from index 1, since 0 is the header line
            for (int csvRow = 1; csvRow < csvData.Count; csvRow++)
            {
                householdList.Add(Get_Account_From_Row(csvData[csvRow], headerValues));
            }

            // Return the list
            return(householdList);
        }