public static Index CreateIndexObject(FGAContext db, IDictionary <string, string> data, ILog ExceptionLogger) { Index index; string isin = data["isin"]; CurrencyCode c = data["currency"] == null ? CurrencyCode.EUR : (CurrencyCode)data["currency"]; index = new Index(Name: data["name"], ISIN: isin, IndexCurrency: c); index.IndexFrequency = FrequencyCode.getFrequencyByLabel("DAILY"); index.Identification.OtherIdentification = data["id"]; index.Identification.RIC = (RICIdentifier)data["ric"]; index.Identification.Bloomberg = (BloombergIdentifier)data["bloomberg"]; index.FamilyKeyObject = new MSCIFamilyObject(); if (data["country"] != null) { try { index.Identification.DomesticIdentificationSource = (CountryCode)data["country"]; } catch (Exception e) { ExceptionLogger.Info("Country code :" + data["country"] + " Not recognized"); } } db.Indexes.Add(index); return(index); }
static void Main(string[] args) { using (var db = new FGABusinessComponent.BusinessComponent.FGAContext()) { #if DEBUG FGABusinessComponent.BusinessComponent.Util.EFCodeFirstMethods.DumpDbCreationScriptToFile(db); #endif IndexBasket ex = new IndexBasket(); ex.Identification = new SecuritiesIdentification(Isin: "FR1234567890"); ex.IndexFixingDate = new DateTime(2000, 1, 1, 14, 30, 0); // 14h30 ex.IndexFrequency = FrequencyCode.getFrequencyByLabel("MONTHLY"); ex.IndexCurrency = CurrencyCode.getCurrencyByLabel("Euro"); IndexAsset ia = new IndexAsset(); ia.MarketCapitalization = new CurrencyAndAmount(); ia.MarketCapitalization.Value = 12; ia.MarketCapitalization.Currency = (CurrencyCode)"EUR"; ia.InvestmentRate = new PercentageRate(); ia.InvestmentRate.Value = 10; ia.EffectiveDate = DateTime.Now; ia.HeldNumber = new SecuritiesQuantity(); ia.HeldNumber.SecurityIdentification = new ISINIdentifier(); ia.HeldNumber.SecurityIdentification.ISINCode = "XX0000000000"; ia.HeldNumber.Unit = 2; ia.HeldNumber.Rate = new PercentageRate(); ia.HeldNumber.Amount = new CurrencyAndAmount(); ia.HeldNumber.Amount.Currency = (CurrencyCode)"USD"; ia.HeldNumber.Amount.Value = 66; //ia.HeldNumber = new SecuritiesQuantity(); //ia.HeldNumber.SecurityIdentification = "10 EUR"; ex.Compo = new List <IndexAsset>(); ex.Compo.Add(ia); db.Indexes.Add(ex); ex = new IndexBasket(); ex.Identification = new SecuritiesIdentification(Isin: "FR0000000000"); ex.IndexFixingDate = new DateTime(2000, 1, 1, 14, 30, 0); // 14h30 ex.IndexFrequency = FrequencyCode.getFrequencyByLabel("MONTHLY"); ex.IndexCurrency = (CurrencyCode)"USD"; db.Indexes.Add(ex); db.SaveChanges(); Index ex1 = db.Indexes.FirstOrDefault <Index>(); Index ex2 = db.Indexes.Where <Index>(t => t.Identification.SecurityIdentification == "FR1114567890").FirstOrDefault <Index>(); List <Index> results2 = db.Indexes.Where <Index>(t => t.Identification.SecurityIdentification == "FR0000000000").ToList(); var q = from c in db.Indexes where c.Identification.SecurityIdentification == "FR0000000000" select c; List <Index> results = q.ToList(); Console.WriteLine(results); } }
public void IndexContructionTest() { Equity e; Debt s; InvestmentFund f; Rating r; AssetHolding ia; Index ex; try { using (var db = new FGABusinessComponent.BusinessComponent.FGAContext("PREPROD", compiledModel)) { #if DEBUG // xml seeder: le fichier xml est lu et est chargé comme valeurs par défaut db.SaveChanges(); // ecriture du fichier pour permettre d avoir un fichier FGABusinessComponent.BusinessComponent.Util.EFCodeFirstMethods.DumpDbCreationScriptToFile(db); #endif //Security_TEST stest = new Security_TEST(); //stest.ISIN = (ISINIdentifier)"TEST234567890"; //System.Console.WriteLine(stest.ISIN); ex = new Index(Name: "Exemple d indice 1", ISIN: "BTS1TREU", IndexCurrency: (CurrencyCode)"EUR"); ex.IndexFixingDate = new TimeSpan(15, 30, 0); // 15h30 ex.IndexFrequency = FrequencyCode.getFrequencyByLabel("MONTHLY"); s = new Debt(ISIN: "PP11110000", FinancialInstrumentName: "Debt 1-Index test", MaturityDate: new DateTime(2013, 1, 1), interestCoupon: new InterestCalculation(new PercentageRate(1.666), new FrequencyCode(1))); s.Identification = new SecuritiesIdentification(Isin: "PP11110000"); s.FinancialInstrumentName = "Security 1"; s.MaturityDate = new DateTime(2013, 1, 1); ia = new AssetHolding(Date: this.dateOfData, ISIN: s.ISINId, HoldAsset: s, Holder: ex); ia.MarketValue = new CurrencyAndAmount(); ia.MarketValue.Value = 12; ia.MarketValue.Currency = (CurrencyCode)"EUR"; ia.FaceAmount = new CurrencyAndAmount(); ia.FaceAmount.Value = 5; ia.FaceAmount.Currency = (CurrencyCode)"EUR"; ia.BookValue = new CurrencyAndAmount(); ia.BookValue.Value = 5; ia.BookValue.Currency = (CurrencyCode)"EUR"; ia.Quantity = 30; //SecuritiesQuantity held = new SecuritiesQuantity(); //held.Unit = 2; //held.Rate = new PercentageRate(); //held.Rate.Value = 2; //held.Amount = new CurrencyAndAmount(); //held.Amount.Currency = (CurrencyCode)"USD"; //held.Amount.Value = 666; db.AssetHoldings.Add(ia); db.Indexes.Add(ex); db.SaveChanges(); ex = new Index(ISIN: "FR0000000000", Date: new DateTime(9999, 12, 31)); ex.IndexFixingDate = new TimeSpan(16, 30, 0); // 16h30 ex.IndexFrequency = FrequencyCode.getFrequencyByLabel("MONTHLY"); ex.IndexCurrency = (CurrencyCode)"USD"; db.Indexes.Add(ex); db.SaveChanges(); // test sans ISIN (identification) s = new Debt(ISIN: "PP11110000", FinancialInstrumentName: "Debt 2-Index test", MaturityDate: new DateTime(2013, 1, 1), interestCoupon: new InterestCalculation(new PercentageRate(1.666), new FrequencyCode(1))); ia = new AssetHolding(Date: this.dateOfData, ISIN: s.ISINId, Holder: ex, HoldAsset: s); db.AssetHoldings.Add(ia); db.SaveChanges(); Index ex1 = db.Indexes.FirstOrDefault <Index>(); Index ex2 = db.Indexes.Where <Index>(t => t.Identification.SecurityIdentification.ISINCode == "BTS1TREU").FirstOrDefault <Index>(); Index ex3 = db.Indexes.FirstOrDefault <Index>(); foreach (Component a in ex3.Items) { Console.Out.WriteLine(a.ToString()); } Index ex4 = (Index)ex3; List <Index> results2 = db.Indexes.Where <Index>(t => t.Identification.SecurityIdentification.ISINCode == "FR0000000000").ToList(); var q = from c in db.Indexes where c.Identification.SecurityIdentification.ISINCode == "FR0000000000" select c; List <Index> results = q.ToList(); Console.WriteLine(results); Index ex5 = db.Indexes.Find(new object[] { 3, "FR0000000000", new DateTime(9999, 12, 31) }); } } catch (Exception exc) { System.Console.WriteLine(exc); throw exc; } }