示例#1
0
        public static AssetMarket CreateAssetMarket(FXMarket populate_fx = null)
        {
            AssetMarket aMkt = new AssetMarket();

            aMkt.AddQuote(new AssetCcyPair(Asset3(), Ccy1()), 48.5);
            aMkt.AddQuote(new AssetCcyPair(Asset1(), Ccy1()), 15000.0);
            if (populate_fx != null)
            {
                aMkt.PopulateWithFXMarket(populate_fx);
            }
            return(aMkt);
        }
示例#2
0
        //public void AddNewCcy(string ccyName, CurrencyStatics ccyStatics, CurrencyPair cp, double cpValue)
        //{
        //    bool testAdd = _CcyDB.AddCcy(ccyName, ccyStatics);
        //    if (!testAdd)
        //        MessageBox.Show($"The new Currency [{ccyName}] does already exist.");
        //    else
        //    {
        //        _FXMarket.AddQuote(cp, cpValue);
        //    }
        //}

        //public void AddRefCcy(string ccyName, CurrencyStatics ccyStatics)
        //{
        //    bool testAdd = _CcyDB.AddCcy(ccyName, ccyStatics);
        //    if (!testAdd)
        //        throw new Exception($"Add Ref Ccy Error {ccyName}");
        //    _Ccy = new Currency(ccyName);
        //    _FXMarket.SetCcyRef(_Ccy);
        //}

        public void AddNewAsset(string assetName, AssetStatics aSt, double acpValue)
        {
            bool testAdd = _CcyDB.AddAsset(assetName, aSt);

            if (!testAdd)
            {
                MessageBox.Show($"The new Asset [{assetName}] does already exist.");
            }
            else
            {
                AssetCcyPair acp = new AssetCcyPair(new Asset(assetName), aSt.Ccy);
                _AssetMarket.AddQuote(acp, acpValue);
            }
        }
示例#3
0
        public void HistoricalAccountingData()
        {
            HistoricalAccountingData had = new HistoricalAccountingData();

            had.SetCcyDB(GetCcyDB());

            // Create AccData 1
            FXMarket fx1 = Init.CreateFXMarket();

            fx1.CcyRef = had.CcyDB.RefCcy;
            fx1.AddQuote(new CurrencyPair("GBP", "EUR"), 1.1);
            fx1.AddQuote(new CurrencyPair("GBP", "JPY"), 130);
            AssetMarket amkt1 = Init.CreateAssetMarket();

            amkt1.AddQuote(new AssetCcyPair(new Asset("AAPL"), new Currency("USD")), 1234.56);
            amkt1.PopulateWithFXMarket(fx1);
            List <Category> list = new List <Category> {
                Init.CreateCategory1(), Init.CreateCategory2()
            };
            AccountingData ad1 = new AccountingData(list, fx1, amkt1);

            had.AddData(new DateTime(2020, 1, 1), ad1);

            // Create AccData2
            FXMarket fx2 = new FXMarket();

            fx2.Copy(fx1);
            fx2.AddQuote(new CurrencyPair("EUR", "USD"), 1.2);
            fx2.AddQuote(new CurrencyPair("GBP", "EUR"), 1.15);
            AssetMarket amkt2 = new AssetMarket();

            amkt2.Copy(amkt1);
            amkt2.AddQuote(new AssetCcyPair(new Asset("BNP"), new Currency("EUR")), 50.0);
            amkt2.PopulateWithFXMarket(fx2);
            AccountingData ad2 = new AccountingData(list, fx2, amkt2);

            had.AddData(new DateTime(2020, 2, 3), ad2);

            // Test
            string fileName = SerializeObject(had, "HistoricalAccountingData");
            HistoricalAccountingData desHad = DeserializeObject <HistoricalAccountingData>(fileName);

            Assert.IsTrue(had == desHad);
        }