Exemplo n.º 1
0
        public void HoldingContructionTest()
        {
            Debt         s;
            Equity       e;
            Rating       r;
            AssetHolding ia;
            Portfolio    p;

            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

                    s = new Debt(ISIN: "XX11110000", FinancialInstrumentName: "Debt 1-Holding test", MaturityDate: new DateTime(2013, 1, 1), interestCoupon: new InterestCalculation(new PercentageRate(1.666), new FrequencyCode(1)));
                    db.Debts.Add(s);
                    e = new Equity(ISIN: "ZZ11110000", FinancialInstrumentName: "Equity 1-Holding test");
                    db.Equities.Add(e);
                    s = new Debt(ISIN: "ZZ22220000", FinancialInstrumentName: "Debt 2-Holding test", MaturityDate: new DateTime(2013, 1, 1), interestCoupon: new InterestCalculation(new PercentageRate(1.666), new FrequencyCode(1)));
                    db.Debts.Add(s);
                    db.SaveChanges();


                    db.Debts.Add(s);
                    db.SaveChanges();


                    ia = new AssetHolding(Date: dateOfData, ISIN: e.ISINId, HoldAsset: e, Quantity: 1000);
                    db.AssetHoldings.Add(ia);
                    db.SaveChanges();

                    ia = new AssetHolding(Date: dateOfData, ISIN: s.ISINId, HoldAsset: s, Quantity: 1000);
                    db.AssetHoldings.Add(ia);
                    db.SaveChanges();
                }
            }
            catch (Exception exc)
            {
                System.Console.WriteLine(exc);
                throw exc;
            }
        }
Exemplo n.º 2
0
        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;
            }
        }
Exemplo n.º 3
0
        public void PortfolioContructionTest()
        {
            Equity         e;
            Debt           s;
            InvestmentFund f;
            Rating         r;
            AssetHolding   ia;
            Portfolio      p;

            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

                    f = new InvestmentFund(ISIN: "ZZ11110000", FinancialInstrumentName: "Equity 1-Holding test", FinancialAssetTypeCategoryCode: FinancialAssetTypeCategoryCode.DEBT);
                    db.InvestmentFunds.Add(f);
                    p = new Portfolio(ISIN: "ZZ11110000", Date: new DateTime(9999, 12, 31), Name: "ExempleFonds1");
                    db.Portfolios.Add(p);
                    db.SaveChanges();

                    AssetPortfolioAssociation assoc = new AssetPortfolioAssociation(p, f);

                    f.UnderlyingPortfolio           = assoc;
                    assoc.InvestmentAmount          = new CurrencyAndAmount();
                    assoc.InvestmentAmount.Value    = 5;
                    assoc.InvestmentAmount.Currency = (CurrencyCode)"EUR";
                    db.AssetPortfolioAssociations.Add(assoc);
                    db.SaveChanges();

                    s = new Debt(ISIN: "PP11110000", FinancialInstrumentName: "Debt 1-Portfolio test", MaturityDate: new DateTime(2013, 1, 1), interestCoupon: new InterestCalculation(new PercentageRate(1.666), new FrequencyCode(1)));
                    db.Debts.Add(s);

                    ia = new AssetHolding(Date: this.dateOfData, ISIN: s.ISINId, HoldAsset: s, Holder: p, Quantity: 100);
                    db.AssetHoldings.Add(ia);
                    p.Add(ia);

                    e = new Equity(ISIN: "PP11110000", FinancialInstrumentName: "Equity 1-Portfolio test");
                    db.Equities.Add(e);
                    ia = new AssetHolding(Date: this.dateOfData, ISIN: e.ISINId, Holder: p, HoldAsset: e, Quantity: 200);
                    db.AssetHoldings.Add(ia);
                    p.Add(ia);

                    s = new Debt(ISIN: "PP22220000", FinancialInstrumentName: "Debt 2-Portfolio test", MaturityDate: new DateTime(2013, 1, 1), interestCoupon: new InterestCalculation(new PercentageRate(1.666), new FrequencyCode(1)));
                    db.Debts.Add(s);
                    ia = new AssetHolding(Date: this.dateOfData, ISIN: s.ISINId, Holder: p, HoldAsset: s, Quantity: 300);
                    db.AssetHoldings.Add(ia);
                    p.Add(ia);

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex);
                throw ex;
            }
        }
Exemplo n.º 4
0
        public static AssetHolding LookupAssetHolding(FGAContext db, Index index, Asset security, DateTime dateOfData)
        {
            AssetHolding holding = db.AssetHoldings.Where <AssetHolding>(t => t.Asset.Id == security.Id && t.Parent.Id == index.Id && t.Date == dateOfData).FirstOrDefault <AssetHolding>();

            return(holding);
        }
Exemplo n.º 5
0
 public void Remove(ref AssetHolding c)
 {
     this.AssetValue.Remove(c);
 }
Exemplo n.º 6
0
 // different holdings of the asset
 public void Add(AssetHolding c)
 {
     this.AssetValue.Add(c);
 }