//public static Market CreateYieldCurveConfiguration(string curveId, string[] assetIdentifiers)
        //{
        //    var market = new Market {id = curveId};

        //    //Create the quotedAssetSet.
        //    var qas = QuotedAssetSetFactory.Parse(assetIdentifiers);

        //    //Create the curve information.
        //    var curve = new YieldCurve {id = curveId};

        //    //reate the valuation structure that contains qas.
        //    var curveValuation = new YieldCurveValuation {id = curveId, inputs = qas};

        //    //Set the market.
        //    market.Items = new[] { (PricingStructure)curve };
        //    market.Items1 = new[] { (PricingStructureValuation)curveValuation };

        //    return market;
        //}

        public static Market CreateFxCurveConfiguration(string curveId, string currency1, string currency2, string quoteBasis, FxRateSet quotedAssetSet)
        {
            //<QuoteBasisEnum>
            var basis = EnumHelper.Parse <QuoteBasisEnum>(quoteBasis, true);
            var quotedCurrencyPair = QuotedCurrencyPair.Create(currency1, currency2, basis);
            var currency           = CurrencyHelper.Parse(currency1);
            var market             = new Market {
                id = curveId
            };

            //Create the curve information.
            var curve = new FxCurve {
                id = curveId, name = curveId, currency = currency, quotedCurrencyPair = quotedCurrencyPair
            };

            //reate the valuation structure that contains qas.
            var curveValuation = new FxCurveValuation {
                id = curveId, spotRate = quotedAssetSet
            };

            //Set the market.
            market.Items  = new[] { (PricingStructure)curve };
            market.Items1 = new[] { (PricingStructureValuation)curveValuation };

            return(market);
        }
        public static AssetValuation Copy(AssetValuation baseValuation)
        {
            AssetValuation result = null;

            if (baseValuation != null)
            {
                result = new AssetValuation();
                if (baseValuation.quote != null)
                {
                    result.quote = QuotationHelper.Copy(baseValuation.quote).ToArray();
                }
                if (baseValuation.fxRate != null)
                {
                    var fxRate = new List <FxRate>();
                    //result.fxRate
                    //if (baseValuation.fxRate!=null)
                    //{
                    foreach (var rate in baseValuation.fxRate)
                    {
                        var newRate = new FxRate
                        {
                            quotedCurrencyPair = new QuotedCurrencyPair
                            {
                                currency1 =
                                    CurrencyHelper.Copy(
                                        rate.quotedCurrencyPair.
                                        currency1),
                                currency2 =
                                    CurrencyHelper.Copy(
                                        rate.quotedCurrencyPair.
                                        currency2),
                                quoteBasis =
                                    rate.quotedCurrencyPair.
                                    quoteBasis
                            }
                        };
                        fxRate.Add(newRate);
                    }
                    result.fxRate = fxRate.ToArray();
                }
                if (baseValuation.valuationScenarioReference != null)
                {
                    result.valuationScenarioReference = new ValuationScenarioReference
                    {
                        href = baseValuation.valuationScenarioReference.href
                    };
                }
                if (baseValuation.id != null)
                {
                    result.id = baseValuation.id;
                }
                if (baseValuation.objectReference != null)
                {
                    result.objectReference = new AnyAssetReference {
                        href = baseValuation.objectReference.href
                    };
                }
            }
            return(result);
        }
Exemple #3
0
        public static Money Normalise(string currency, decimal amount, bool isPayerBase)
        {
            var money = new Money {
                currency = CurrencyHelper.Parse(currency)
            };

            money.amount = System.Math.Abs(money.amount);
            if (isPayerBase)
            {
                money.amount = -1 * money.amount;
            }
            money.amountSpecified = true;
            return(money);
        }
Exemple #4
0
        public static Quotation Create(decimal value, DateTime valuationDate,
                                       string businessCenter, string currency,
                                       string rateSourceProvider, string rateSource, string rateSourcePage,
                                       string assetMeasureType, string quoteUnits)
        {
            var quotation = new Quotation
            {
                businessCenter    = BusinessCentersHelper.Parse(businessCenter).businessCenter[0],
                currency          = CurrencyHelper.Parse(currency),
                informationSource =
                    InformationSourceHelper.Create(
                        InformationSourceHelper.Create(rateSourceProvider, rateSource,
                                                       rateSourcePage)),
                measureType            = AssetMeasureTypeHelper.Parse(assetMeasureType),
                quoteUnits             = PriceQuoteUnitsHelper.Create(quoteUnits),
                valuationDate          = valuationDate,
                valuationDateSpecified = true,
                value          = value,
                valueSpecified = true
            };

            return(quotation);
        }
Exemple #5
0
        public static Quotation Copy(Quotation baseQuotation)
        {
            Quotation quotation = null;

            if (baseQuotation != null)
            {
                quotation = new Quotation();
                if (baseQuotation.businessCenter != null)
                {
                    quotation.businessCenter = BusinessCentersHelper.Parse(baseQuotation.businessCenter.Value).businessCenter[0];
                }
                if (baseQuotation.currency != null)
                {
                    quotation.currency = CurrencyHelper.Parse(baseQuotation.currency.Value);
                }
                if (baseQuotation.valueSpecified)
                {
                    quotation.value          = baseQuotation.value;
                    quotation.valueSpecified = true;
                }
                if (baseQuotation.valuationDateSpecified)
                {
                    quotation.valuationDate          = baseQuotation.valuationDate;
                    quotation.valuationDateSpecified = true;
                }
                if (baseQuotation.expiryTimeSpecified)
                {
                    quotation.expiryTime          = baseQuotation.expiryTime;
                    quotation.expiryTimeSpecified = true;
                }
                if (baseQuotation.sideSpecified)
                {
                    quotation.side          = baseQuotation.side;
                    quotation.sideSpecified = true;
                }
                if (baseQuotation.timeSpecified)
                {
                    quotation.time          = baseQuotation.time;
                    quotation.timeSpecified = true;
                }
                if (baseQuotation.sensitivitySet != null)
                {
                    quotation.sensitivitySet = SensitivitySetHelper.Copy(baseQuotation.sensitivitySet);
                }
                if (baseQuotation.measureType != null)
                {
                    quotation.measureType = AssetMeasureTypeHelper.Copy(baseQuotation.measureType);
                }
                if (baseQuotation.quoteUnits != null)
                {
                    quotation.quoteUnits = PriceQuoteUnitsHelper.Copy(baseQuotation.quoteUnits);
                }
                if (baseQuotation.informationSource != null)
                {
                    quotation.informationSource = InformationSourceHelper.Copy(baseQuotation.informationSource).ToArray();
                }
                if (baseQuotation.exchangeId != null)
                {
                    quotation.exchangeId = ProductTypeHelper.ExchangeIdHelper.Copy(baseQuotation.exchangeId);
                }
            }
            return(quotation);
        }