示例#1
0
        private static List <Listings> ParseGoogleListings(List <Listings> listings, string csvData, string symbol, string companyName)
        {
            string path = HostingEnvironment.MapPath("~/Error Log File/Error.txt");

            char[]          delimiter  = { ',', '\t', '\r', '\n', '"', '/', '{', '}' };
            string[]        rows       = csvData.Replace("\r", "").Split('\n');
            Listings        list       = null;
            SailiRepository repository = new SailiRepository();
            bool            pass       = false;
            int             count      = 0;

            foreach (string row in rows)
            {
                if (!pass)
                {
                    pass = true;
                    continue;
                }

                if (string.IsNullOrEmpty(row))
                {
                    continue;
                }

                string[] cols = row.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);

                decimal convert = 0;

                bool result = Decimal.TryParse(cols[1].ToString(), out convert);

                if (!result)
                {
                    SaveErrorInRequest(path, cols);
                    continue;
                }
                result = Decimal.TryParse(cols[4].ToString(), out convert);
                if (!result)
                {
                    SaveErrorInRequest(path, cols);
                    continue;
                }
                count++;
                if (count == 2)
                {
                    break;
                }
                list             = new Listings();
                list.Symbol      = symbol;
                list.CompanyName = companyName;
                list.Open        = Convert.ToDecimal(cols[1].ToString());
                list.Close       = Convert.ToDecimal(cols[4].ToString());
                list.Change      = list.Close - list.Open;
                listings.Add(list);
            }
            return(listings);
        }
示例#2
0
        private static Historical ParseHistoryListings(Historical historical, string csvData)
        {
            string path = HostingEnvironment.MapPath("~/Error Log File/Error.txt");

            char[]           delimiter  = { ',', '\t', '\r', '\n', '"', '/', '{', '}' };
            string[]         rows       = csvData.Replace("\r", "").Split('\n');
            HistoricalPrices price      = null;
            SailiRepository  repository = new SailiRepository();
            bool             pass       = false;


            foreach (string row in rows)
            {
                if (!pass)
                {
                    pass = true;
                    continue;
                }

                if (string.IsNullOrEmpty(row))
                {
                    continue;
                }

                string[] cols = row.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);

                decimal convert = 0;

                bool result = Decimal.TryParse(cols[1].ToString(), out convert);

                if (!result)
                {
                    SaveErrorInRequest(path, cols);
                    continue;
                }
                result = Decimal.TryParse(cols[2].ToString(), out convert);
                if (!result)
                {
                    SaveErrorInRequest(path, cols);
                    continue;
                }
                price       = new HistoricalPrices();
                price.Date  = cols[0].ToString();
                price.Open  = Convert.ToDecimal(cols[1].ToString());
                price.Close = Convert.ToDecimal(cols[4].ToString());
                historical.historicalPrices.Add(price);
            }
            return(historical);
        }
示例#3
0
        private static decimal[] CompletePortfolioPerformance(PortfolioViewModel portfolio, string csvData, string symbol)
        {
            string path = HostingEnvironment.MapPath("~/Error Log File/Error.txt");

            char[]          delimiter  = { ',', '\t', '\r', '\n', '"', '/', '{', '}', '!', '<', '>' };
            string[]        rows       = csvData.Replace("\r", "").Split('\n');
            SailiRepository repository = new SailiRepository();
            bool            pass       = false;

            decimal[] stats = new decimal[2];

            foreach (string row in rows)
            {
                if (!pass)
                {
                    pass = true;
                    continue;
                }

                if (string.IsNullOrEmpty(row))
                {
                    continue;
                }

                string[] cols = row.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);

                decimal convert = 0;

                bool result = Decimal.TryParse(cols[1].ToString(), out convert);

                if (!result)
                {
                    SaveErrorInRequest(path, cols);
                    continue;
                }
                result = Decimal.TryParse(cols[4].ToString(), out convert);
                if (!result)
                {
                    SaveErrorInRequest(path, cols);
                    continue;
                }

                stats[0] = Convert.ToDecimal(cols[1].ToString());
                stats[1] = Convert.ToDecimal(cols[4].ToString());
                break;
            }
            return(stats);
        }
示例#4
0
        private static List <Listings> ParseScoreListings(List <Listings> listings, string csvData, string symbol)
        {
            string path = HostingEnvironment.MapPath("~/Error Log File/Error.txt");

            char[]          delimiter  = { ',', '\t', '\r', '\n', '"', '/', '{', '}' };
            string[]        rows       = csvData.Replace("\r", "").Split('\n');
            SailiRepository repository = new SailiRepository();
            bool            check      = false;
            Listings        listing    = null;


            foreach (string row in rows)
            {
                if (string.IsNullOrEmpty(row))
                {
                    continue;
                }

                string[] cols = row.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);

                decimal convert = 0;

                bool result = Decimal.TryParse(cols[1].ToString(), out convert);

                if (!result)
                {
                    result = Decimal.TryParse(cols[2].ToString(), out convert);
                    if (result)
                    {
                        cols[1] = cols[2];
                    }
                    else
                    {
                        SaveErrorInRequest(path, cols);
                        continue;
                    }
                }
                result = Decimal.TryParse(cols[2].ToString(), out convert);
                if (!result)
                {
                    SaveErrorInRequest(path, cols);
                    continue;
                }
                if (!check)
                {
                    listing        = new Listings();
                    listing.Symbol = cols[0];
                    listing.Open   = Convert.ToDecimal(cols[1]);
                    listing.Close  = Convert.ToDecimal(cols[2]);
                    listing.Change = listing.Close - listing.Open;
                }
                else
                {
                    listing        = new Listings();
                    listing.Symbol = cols[0];
                    listing.Open   = Convert.ToDecimal(cols[1]);
                    listing.Close  = Convert.ToDecimal(cols[2]);
                    listing.Change = listing.Close - listing.Open;
                }
            }
            return(listings);
        }
示例#5
0
        internal static void SeedIdentities(ApplicationDbContext DefaultConnection)
        {
            string           databaseConnection = ConfigurationManager.ConnectionStrings["SailiDbContext"].ConnectionString;
            var              userManager        = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(DefaultConnection));
            var              roleManager        = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(DefaultConnection));
            SailiRepository  repository         = new SailiRepository();
            Vector <Company> Companies          = new Vector <Company>();



            string userName = "******";
            string Email    = "*****@*****.**";
            string password = "******";

            if (!roleManager.RoleExists(RoleNames.ROLE_ADMINISTRATOR))
            {
                var roleresult = roleManager.Create(new IdentityRole(RoleNames.ROLE_ADMINISTRATOR));
            }

            if (!roleManager.RoleExists(RoleNames.ROLE_Trader))
            {
                var roleresult = roleManager.Create(new IdentityRole(RoleNames.ROLE_Trader));
            }

            ApplicationUser user = userManager.FindByName(userName);

            if (user == null)
            {
                user = new ApplicationUser()
                {
                    UserName       = userName,
                    Email          = Email,
                    EmailConfirmed = true
                };

                IdentityResult userResult = userManager.Create(user, password);

                if (userResult.Succeeded)
                {
                    var result = userManager.AddToRole(user.Id, RoleNames.ROLE_ADMINISTRATOR);

                    DefaultConnection.SaveChanges();
                }

                DefaultConnection.Sectors.Add(new Sector
                {
                    IsDeleted   = false,
                    SectorName  = "Information Technology",
                    Description = "Information technology (IT) is the application of computers to store, study, retrieve, transmit, and manipulate data, or information, often in the context of a business or other enterprise. IT is considered a subset of information and communications technology (ICT).",
                    ImageUrl    = "../Content/Images/MarketSectors/IT.png"
                });

                DefaultConnection.SaveChanges();

                DefaultConnection.Sectors.Add(new Sector
                {
                    IsDeleted   = false,
                    SectorName  = "Financial",
                    Description = "The financial sector is a category of stocks containing firms that provide financial services to commercial and retail customers; this sector includes banks, investment funds, insurance companies and real estate.",
                    ImageUrl    = "../Content/Images/MarketSectors/financials.png"
                });

                DefaultConnection.SaveChanges();

                DefaultConnection.Sectors.Add(new Sector
                {
                    IsDeleted   = false,
                    SectorName  = "Healthcare",
                    Description = "The healthcare sector is the category of stocks relating to medical and healthcare goods or services. The healthcare sector includes hospital management firms, health maintenance organizations (HMOs), biotechnology and a variety of medical products.",
                    ImageUrl    = "../Content/Images/MarketSectors/healthcare.png"
                });

                DefaultConnection.SaveChanges();

                DefaultConnection.Sectors.Add(new Sector
                {
                    IsDeleted   = false,
                    SectorName  = "Energy",
                    Description = "The energy sector is a category of stocks that relate to producing or supplying energy. This sector includes companies involved in the exploration and development of oil or gas reserves, oil and gas drilling, or integrated power firms.",
                    ImageUrl    = "../Content/Images/MarketSectors/energy.png"
                });

                DefaultConnection.SaveChanges();

                DefaultConnection.Sectors.Add(new Sector
                {
                    IsDeleted   = false,
                    SectorName  = "Industrial",
                    Description = "Goods-producing segment of an economy, including agriculture, construction, fisheries, forestry, and manufacturing.",
                    ImageUrl    = "../Content/Images/MarketSectors/industrial.png"
                });

                DefaultConnection.SaveChanges();

                DefaultConnection.Sectors.Add(new Sector
                {
                    IsDeleted   = false,
                    SectorName  = "Materials",
                    Description = "Materials sector is a category of stocks that accounts for companies involved with the discovery, development and processing of raw materials. The sector includes the mining and refining of metals, chemical producers and forestry products.",
                    ImageUrl    = "../Content/Images/MarketSectors/materials.jpg"
                });

                DefaultConnection.SaveChanges();

                DefaultConnection.Sectors.Add(new Sector
                {
                    IsDeleted   = false,
                    SectorName  = "Consumer Discretionary",
                    Description = "Consumer discretionary is the term given to goods and services that are considered non-essential by consumers, but desirable if their available income is sufficient to purchase them. Consumer discretionary goods include durable goods, apparel, entertainment and leisure, and automobiles.",
                    ImageUrl    = "../Content/Images/MarketSectors/ConsumerDiscretionary.png"
                });

                DefaultConnection.SaveChanges();

                DefaultConnection.Sectors.Add(new Sector
                {
                    IsDeleted   = false,
                    SectorName  = "Consumer Staples",
                    Description = "The consumer staples sector is characterized by its global industry classification sector (GICS). The sector is composed of companies whose primary lines of business are food, beverages, tobacco and other household items.",
                    ImageUrl    = "../Content/Images/MarketSectors/Consumerstaples.png"
                });

                DefaultConnection.SaveChanges();

                DefaultConnection.Sectors.Add(new Sector
                {
                    IsDeleted   = false,
                    SectorName  = "Telecommunication",
                    Description = "The Telecommunication Services comprises companies that make communication possible on a global scale whether through the phone or Internet. These companies created the infrastructure that allows data to be sent anywhere in the world. The largest companies in the sector are wireless operators, satellite companies, cable companies and Internet service providers.",
                    ImageUrl    = "../Content/Images/MarketSectors/telecommunication.png"
                });

                DefaultConnection.SaveChanges();

                DefaultConnection.Sectors.Add(new Sector
                {
                    IsDeleted   = false,
                    SectorName  = "Utilities",
                    Description = "The utilities sector is a category of stocks for utilities such as gas and power. The sector contains companies such as electric, gas and water firms, and integrated providers.",
                    ImageUrl    = "../Content/Images/MarketSectors/utilities.png"
                });

                DefaultConnection.SaveChanges();

                DefaultConnection.Sectors.Add(new Sector
                {
                    IsDeleted   = false,
                    SectorName  = "Real Estate",
                    Description = "The main segments of the real estate sector are residential real estate, commercial real estate and industrial real estate. The residential sector focuses on the buying and selling of properties used for nonbusiness purposes.",
                    ImageUrl    = "../Content/Images/MarketSectors/realEstate.png"
                });

                DefaultConnection.SaveChanges();

                DefaultConnection.Homes.Add(new Home
                {
                    About           = "Have you ever wondered what it may mean if a machine can answer questions like, Which company has the lowest debt but outperformed a sector that outperformed their own?  Or which company has a low P/E rating but grow more than higher P/E rating companies whose sector outperformed theirs? If questions like these returned some findings, wouldn't that be interesting? Interesting still is how it may be answered by economics. After all, we have to try to find an explanation - the data is free from individual interpretation",
                    HelpName        = "Kiet Lam",
                    HelpEmail       = "*****@*****.**",
                    HelpPhoneNumber = "0412 509 235"
                });

                DefaultConnection.SaveChanges();
            }
        }