Esempio n. 1
0
        private static FileArray DelimitFile(string line, string fileType)
        {
            FileArray fileArray = new FileArray();

            if (fileType == "Open")
            {
                fileArray.fileDate  = line.Substring(0, 8);
                fileArray.Cusip     = line.Substring(9, 9);
                fileArray.ISIN      = line.Substring(19, 12);
                fileArray.Ticker    = line.Substring(32, 7).Trim();
                fileArray.Exchange  = line.Substring(41, 12).Trim();
                fileArray.Return    = Double.Parse(line.Substring(54, 7));
                fileArray.MTDReturn = Double.Parse(line.Substring(62, 10));
                fileArray.MktValue  = Double.Parse(line.Substring(73, 13));
                try
                {
                    fileArray.CashDividend = Double.Parse(line.Substring(87, 13));
                }
                catch (FormatException)
                {
                    fileArray.CashDividend = 0D;
                }
                fileArray.Shares           = Convert.ToInt32(line.Substring(101, 9));
                fileArray.ValShares        = Convert.ToInt32(line.Substring(111, 9));
                fileArray.GroShares        = Convert.ToInt32(line.Substring(121, 9));
                fileArray.Russell1000Flag  = Convert.ToChar(line.Substring(131, 1));
                fileArray.Russell2000Flag  = Convert.ToChar(line.Substring(133, 1));
                fileArray.Russell2500Flag  = Convert.ToChar(line.Substring(135, 1));
                fileArray.RussellMidFlag   = Convert.ToChar(line.Substring(137, 1));
                fileArray.RussellTop2Flag  = Convert.ToChar(line.Substring(139, 1));
                fileArray.RSCCFlag         = Convert.ToChar(line.Substring(141, 1));
                fileArray.Russell3000Flag  = Convert.ToChar(line.Substring(143, 1));
                fileArray.RussellMicroFlag = Convert.ToChar(line.Substring(145, 5).Trim());
                fileArray.ShareChg         = Convert.ToInt32(line.Substring(152, 10));
                fileArray.CompanyName      = line.Substring(163, 25).Trim();
                fileArray.ES             = line.Substring(189, 2);
                fileArray.EconomicSector = line.Substring(192, 30).Trim();
                fileArray.SubS           = line.Substring(223, 4);
                fileArray.SubSector      = line.Substring(228, 48).Trim();
                fileArray.IND            = line.Substring(277, 6);
                fileArray.Industry       = line.Substring(284, 49).Trim();
                //eventually import weights for evaluation
                return(fileArray);
            }
            else if (fileType == "Close")
            {
                fileArray.fileDate  = line.Substring(0, 8);
                fileArray.Cusip     = line.Substring(9, 9);
                fileArray.ISIN      = line.Substring(19, 12);
                fileArray.Ticker    = line.Substring(32, 7).Trim();
                fileArray.Exchange  = line.Substring(41, 12).Trim();
                fileArray.Return    = Double.Parse(line.Substring(54, 7));
                fileArray.MTDReturn = Double.Parse(line.Substring(62, 10));
                fileArray.MktValue  = Double.Parse(line.Substring(73, 13));

                fileArray.Shares           = Convert.ToInt32(line.Substring(87, 9));
                fileArray.ValShares        = Convert.ToInt32(line.Substring(97, 9));
                fileArray.GroShares        = Convert.ToInt32(line.Substring(107, 9));
                fileArray.Russell1000Flag  = Convert.ToChar(line.Substring(117, 1));
                fileArray.Russell2000Flag  = Convert.ToChar(line.Substring(119, 1));
                fileArray.Russell2500Flag  = Convert.ToChar(line.Substring(121, 1));
                fileArray.RussellMidFlag   = Convert.ToChar(line.Substring(123, 1));
                fileArray.RussellTop2Flag  = Convert.ToChar(line.Substring(125, 1));
                fileArray.RSCCFlag         = Convert.ToChar(line.Substring(127, 1));
                fileArray.Russell3000Flag  = Convert.ToChar(line.Substring(129, 1));
                fileArray.RussellMicroFlag = Convert.ToChar(line.Substring(131, 5).Trim());
                fileArray.ShareChg         = Convert.ToInt32(line.Substring(138, 10));
                fileArray.CompanyName      = line.Substring(149, 25).Trim();
                fileArray.ES             = line.Substring(175, 2);
                fileArray.EconomicSector = line.Substring(178, 30).Trim();
                fileArray.SubS           = line.Substring(209, 4);
                fileArray.SubSector      = line.Substring(214, 48).Trim();
                fileArray.IND            = line.Substring(263, 6);
                fileArray.Industry       = line.Substring(270, 49).Trim();
                //eventually import weights for evaluation
                return(fileArray);
            }
            else
            {
                MessageBox.Show("Invalid FileType");
                fileArray = null;
                return(fileArray);
            }
        }
Esempio n. 2
0
        static List <DiffArray> CompareSecurity(FileArray openSecurity, FileArray closeSecurity)
        {
            List <DiffArray> Diffs = new List <DiffArray>();

            if (openSecurity.fileDate == closeSecurity.fileDate)
            {
                //dates match
            }
            else
            {
                //dates don't match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "fileDate", OpenValue = openSecurity.fileDate.ToString(), CloseValue = closeSecurity.fileDate.ToString()
                });
            }
            if (openSecurity.ISIN == closeSecurity.ISIN)
            {
                //ISIN Matches
            }
            else
            {
                //ISIN does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "ISIN", OpenValue = openSecurity.ISIN.ToString(), CloseValue = closeSecurity.ISIN.ToString()
                });
            }
            if (openSecurity.Ticker == closeSecurity.Ticker)
            {
                //Ticker matches
            }
            else
            {
                //Ticker does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "Ticker", OpenValue = openSecurity.Ticker.ToString(), CloseValue = closeSecurity.Ticker.ToString()
                });
            }
            if (openSecurity.Exchange == closeSecurity.Exchange)
            {
                //Exchange match
            }
            else
            {
                //Exchange does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "Exchange", OpenValue = openSecurity.Exchange.ToString(), CloseValue = closeSecurity.Exchange.ToString()
                });
            }
            if (openSecurity.Shares == closeSecurity.Shares)
            {
                //Shares match
            }
            else
            {
                //Shares does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "Shares", OpenValue = openSecurity.Shares.ToString(), CloseValue = closeSecurity.Shares.ToString()
                });
            }
            if (openSecurity.GroShares == closeSecurity.GroShares)
            {
                //Growth shares match
            }
            else
            {
                //Growth shares does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "GroShares", OpenValue = openSecurity.GroShares.ToString(), CloseValue = closeSecurity.GroShares.ToString()
                });
            }
            if (openSecurity.ValShares == closeSecurity.ValShares)
            {
                //Value shares match
            }
            else
            {
                //Value shares does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "ValShares", OpenValue = openSecurity.ValShares.ToString(), CloseValue = closeSecurity.ValShares.ToString()
                });
            }
            if (openSecurity.Russell1000Flag == closeSecurity.Russell1000Flag)
            {
                //R1 flag match
            }
            else
            {
                //R1 Flag does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "Russell1000Flag", OpenValue = openSecurity.Russell1000Flag.ToString(), CloseValue = closeSecurity.Russell1000Flag.ToString()
                });
            }
            if (openSecurity.Russell2000Flag == closeSecurity.Russell2000Flag)
            {
                //R2 flag match
            }
            else
            {
                //R2 Flag does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "Russell2000Flag", OpenValue = openSecurity.Russell2000Flag.ToString(), CloseValue = closeSecurity.Russell2000Flag.ToString()
                });
            }
            if (openSecurity.Russell2500Flag == closeSecurity.Russell2500Flag)
            {
                //R25 flag match
            }
            else
            {
                //R25 Flag does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "Russell2500Flag", OpenValue = openSecurity.Russell2500Flag.ToString(), CloseValue = closeSecurity.Russell2500Flag.ToString()
                });
            }
            if (openSecurity.RussellMidFlag == closeSecurity.RussellMidFlag)
            {
                //Rmidcap flag match
            }
            else
            {
                //Rmidcap Flag does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "RussellMidFlag", OpenValue = openSecurity.RussellMidFlag.ToString(), CloseValue = closeSecurity.RussellMidFlag.ToString()
                });
            }
            if (openSecurity.RussellTop2Flag == closeSecurity.RussellTop2Flag)
            {
                //T2 flag match
            }
            else
            {
                //T2 Flag does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "RussellTop2Flag", OpenValue = openSecurity.RussellTop2Flag.ToString(), CloseValue = closeSecurity.RussellTop2Flag.ToString()
                });
            }
            if (openSecurity.RSCCFlag == closeSecurity.RSCCFlag)
            {
                //RSCCFlag flag match
            }
            else
            {
                //RSCCFlag Flag does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "RSCCFlag", OpenValue = openSecurity.RSCCFlag.ToString(), CloseValue = closeSecurity.RSCCFlag.ToString()
                });
            }
            if (openSecurity.Russell3000Flag == closeSecurity.Russell3000Flag)
            {
                //R3 flag match
            }
            else
            {
                //R3 Flag does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "Russell3000Flag", OpenValue = openSecurity.Russell3000Flag.ToString(), CloseValue = closeSecurity.Russell3000Flag.ToString()
                });
            }
            if (openSecurity.RussellMicroFlag == closeSecurity.RussellMicroFlag)
            {
                //Micro flag match
            }
            else
            {
                //Micro Flag does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "RussellMicroFlag", OpenValue = openSecurity.RussellMicroFlag.ToString(), CloseValue = closeSecurity.RussellMicroFlag.ToString()
                });
            }
            if (openSecurity.ShareChg == closeSecurity.ShareChg)
            {
                //ShareChg match
            }
            else
            {
                //ShareChg does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "ShareChg", OpenValue = openSecurity.ShareChg.ToString(), CloseValue = closeSecurity.ShareChg.ToString()
                });
            }
            if (openSecurity.CompanyName == closeSecurity.CompanyName)
            {
                //Names match
            }
            else
            {
                //Name does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "CompanyName", OpenValue = openSecurity.CompanyName.ToString(), CloseValue = closeSecurity.CompanyName.ToString()
                });
            }
            if (openSecurity.IND == closeSecurity.IND)
            {
                //RGS match
            }
            else
            {
                //RGS does not match
                Diffs.Add(new DiffArray()
                {
                    CUSIP = openSecurity.Cusip, Field = "IND", OpenValue = openSecurity.IND.ToString(), CloseValue = closeSecurity.IND.ToString()
                });
            }
            return(Diffs);
        }