public static void RandomizeDataValues(PortfolioInfo item) { var priceChange = DataRandomizer.GetPriceChange(item.Price); item.Change = priceChange.ByAmount; item.Price = priceChange.New; item.ChangePercent = priceChange.Percentage; }
public static List <PortfolioInfo> Create(int count) { var dataItems = new List <PortfolioInfo>(); var defaultItem = GetDefaultData(); for (int i = 0; i < count; i++) { var rand = (int)Math.Floor(random.NextDouble() * DataItems.Count); var region = DataRandomizer.GetItem(Regions) as Region; var item = DataItems[rand].Clone(); item.Region = region.Name; // generating random values of properties item.Settlement = DataRandomizer.GetItem(Settlements).ToString(); item.Contract = DataRandomizer.GetItem(Contracts).ToString(); item.Country = DataRandomizer.GetItem(region.Countries).ToString(); item.Risk = DataRandomizer.GetItem(CountryRisks).ToString(); item.Sector = DataRandomizer.GetItem(SectorTypes).ToString(); item.Currency = DataRandomizer.GetItem(CurrencyTypes).ToString(); item.Security = DataRandomizer.GetItem(SecurityTypes).ToString(); item.Issuer = DataRandomizer.GetItem(IssuerNames).ToString(); item.Maturity = DataRandomizer.GetDate(); item.Rating = DataRandomizer.GetItem(RatingTypes).ToString(); // setting default properties item.IndGroup = defaultItem.IndGroup; item.IndSector = defaultItem.IndSector; item.IndCategory = defaultItem.IndCategory; item.Fitch = defaultItem.Fitch; item.Collateral = defaultItem.Collateral; item.Transactions = defaultItem.Transactions; item.Spread = defaultItem.Spread; item.KRD_1YR = defaultItem.KRD_1YR; item.KRD_3YR = defaultItem.KRD_3YR; item.KRD_5YR = defaultItem.KRD_5YR; item.ID = i; RandomizeDataValues(item); dataItems.Add(item); } Console.WriteLine("PortfolioData " + dataItems.Count); return(dataItems); }