/// <summary>
        /// Initializes a new instance of the <see cref="PriceableSimpleOptionAsset"/> class.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="logger">The logger.</param>
        /// <param name="nameSpace">The client namespace</param>
        /// <param name="baseDate">The base date.</param>
        /// <param name="expiryTenor">The expiry tenor.</param>
        /// <param name="underlyingAssetIdentifier">The underlying asset.</param>
        /// <param name="strike">The strike.</param>
        /// <param name="volatility">The volatility.</param>
        /// <param name="forecastCurve">The forecast rate curve.</param>
        /// <param name="discountCurve">The discount rate curve. Not used yet, as only the implied rate is caclulated.</param>
        /// <param name="fixingCalendar">The fixingCalendar.</param>
        /// <param name="rollCalendar">The rollCalendar.</param>
        public PriceableSimpleOptionAsset(ILogger logger, ICoreCache cache, string nameSpace, String underlyingAssetIdentifier, DateTime baseDate,
                                          Period expiryTenor, Decimal?strike, Decimal volatility, IRateCurve discountCurve, ICurve forecastCurve, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar)
        {
            UnderlyingAssetRef = underlyingAssetIdentifier;
            var expiryOffset = new Offset
            {
                period           = expiryTenor.period,
                periodMultiplier = expiryTenor.periodMultiplier,
                periodSpecified  = true,
                dayType          = DayTypeEnum.Calendar,
                dayTypeSpecified = true
            };
            var expiryDate      = expiryOffset.Add(baseDate);
            var assetProperties = PriceableAssetFactory.BuildPropertiesForAssets(nameSpace, underlyingAssetIdentifier, expiryDate);
            var instrument      = InstrumentDataHelper.GetInstrumentConfigurationData(cache, nameSpace, underlyingAssetIdentifier);
            var quotation       = BasicQuotationHelper.CreateRate(0.05m);
            var quote           = BasicAssetValuationHelper.Create(quotation);

            UnderlyingPriceableAsset = PriceableAssetFactory.Create(logger, cache, nameSpace, instrument, quote, assetProperties, fixingCalendar, rollCalendar);
            BaseDate     = baseDate;
            ForwardIndex = UnderlyingPriceableAsset.CalculateImpliedQuote(forecastCurve);
            if (strike != null)
            {
                Strike = (Decimal)strike;
            }
            else
            {
                Strike = ForwardIndex;
            }
            DayCounter   = new Actual365();
            ExpiryDate   = expiryDate;
            Volatility   = volatility;
            TimeToExpiry = DayCounter.DayCount(BaseDate, ExpiryDate);
        }
示例#2
0
        /// <summary>
        /// Parses the string info into an asset.
        /// </summary>
        /// <param name="instrumentId"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static Pair <Asset, BasicAssetValuation> ParseSurface(string instrumentId, decimal value)
        {
            const string rateQuotationType = PriceableCapRateAsset.VolatilityQuotationType;
            SimpleFra    underlyingAsset;
            var          results             = instrumentId.Split('-');
            var          instrument          = results[1];
            var          listBasicQuotations = new List <BasicQuotation>();
            var          asset = EnumHelper.Parse <AssetTypesEnum>(instrument);

            switch (asset)
            {
            case AssetTypesEnum.BillCaplet:
            case AssetTypesEnum.BillFloorlet:
            case AssetTypesEnum.Floorlet:
            case AssetTypesEnum.Caplet:
            {
                var index = results[3];
                underlyingAsset = new SimpleFra {
                    id = instrumentId, startTerm = PeriodHelper.Parse(results[2])
                };
                underlyingAsset.endTerm
                    = underlyingAsset.startTerm.Sum(PeriodHelper.Parse(index));
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalVolatility"));
                break;
            }

            default:
                throw new NotSupportedException($"Asset type {instrument} is not supported");
            }
            return(new Pair <Asset, BasicAssetValuation>(underlyingAsset, BasicAssetValuationHelper.Create(underlyingAsset.id, listBasicQuotations.ToArray())));
        }
        public DataTable GetDataTable()
        {
            if (null != _lastQuotedAssetSet)
            {
                foreach (DataRow dataRow in _dataTable.Rows)
                {
                    var instrumentId = (string)dataRow["InstrumentId"];
                    List <BasicAssetValuation> basicAssetValuations =
                        QuotedAssetSet.GetAssetQuote(_lastQuotedAssetSet, instrumentId);
                    if (basicAssetValuations.Count > 0)
                    {
                        BasicAssetValuation bav0 = basicAssetValuations[0];
                        foreach (DataColumn dataColumn in _dataTable.Columns)
                        {
                            string         columnName     = dataColumn.ColumnName;
                            BasicQuotation basicQuotation = BasicAssetValuationHelper.GetQuotationByTiming(bav0, columnName);
                            if (null != basicQuotation)
                            {
                                dataRow[columnName] = basicQuotation.value;
                            }
                        }
                    }
                }
            }
            _dataTable.AcceptChanges();
            DataTable copy = _dataTable.Copy();

            //  remove "InstrumentId" column
            //
            copy.Columns.Remove("InstrumentId");
            copy.AcceptChanges();
            return(copy);
        }
示例#4
0
        /////<summary>
        /////</summary>
        /////<returns></returns>
        //public decimal GetSpotRate()
        //{
        //    var fxVal = (FxCurveValuation)GetFpMLData().Second;
        //    BasicAssetValuation spotRateAsset = (from spotRateAssets in fxVal.spotRate.assetQuote
        //                                         where spotRateAssets.objectReference.href.EndsWith("-Equity-SP", StringComparison.InvariantCultureIgnoreCase)//TODO FIX This!
        //                                         select spotRateAssets).Single();
        //    decimal spotRate = spotRateAsset.quote[0].value;
        //    return spotRate;
        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="cache"></param>
        /// <param name="nameSpace">THe client namespace</param>
        /// <param name="equityId">THe curve asset.</param>
        /// <param name="fixingCalendar"></param>
        /// <param name="rollCalendar"></param>
        /// <param name="baseDate"></param>
        /// <returns></returns>
        protected static DateTime GetSettlementDate(ILogger logger, ICoreCache cache, string nameSpace,
                                                    EquityCurveIdentifier equityId, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar, DateTime baseDate)
        {
            BasicAssetValuation bav = BasicAssetValuationHelper.Create(BasicQuotationHelper.Create(0, "MarketQuote", PriceQuoteUnitsEnum.Price.ToString()));
            var assetId             = BuildSpotAssetId(equityId);
            var priceableAsset      = (IPriceableEquityAssetController)PriceableAssetFactory.Create(logger, cache, nameSpace, assetId, baseDate, bav, fixingCalendar, rollCalendar);

            return(priceableAsset.GetRiskMaturityDate());
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="cache"></param>
        /// <param name="nameSpace"></param>
        /// <param name="fixingCalendar"></param>
        /// <param name="rollCalendar"></param>
        /// <param name="baseDate"></param>
        /// <returns></returns>
        public DateTime GetSpotDate(ILogger logger, ICoreCache cache, string nameSpace,
                                    IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar, DateTime baseDate)
        {
            BasicAssetValuation bav = BasicAssetValuationHelper.Create(BasicQuotationHelper.Create(0, "MarketQuote"));
            string identifier       = Currency1 + Currency2 + "-FxSpot-SP";//Currency2 would normally be USD.
            var    priceableAsset   = (IPriceableFxAssetController)PriceableAssetFactory.Create(logger, cache, nameSpace, identifier, baseDate, bav, fixingCalendar, rollCalendar);

            if (priceableAsset != null)
            {
                return(priceableAsset.GetRiskMaturityDate());
            }
            return(FxCurve1.GetSpotDate());//TODO Default to the first curve. Should merge the two!
        }
示例#6
0
 /// <summary>
 /// Parses the string info into an asset.
 /// </summary>
 /// <param name="instrumentId"></param>
 /// <param name="value"></param>
 /// <param name="measureType"></param>
 /// <param name="priceQuoteUnits"></param>
 /// <returns></returns>
 public static Pair <Asset, BasicAssetValuation> CreateAssetPair(string instrumentId, decimal[] value, string[] measureType, string[] priceQuoteUnits)
 {
     if (value.Length == priceQuoteUnits.Length && value.Length == measureType.Length)
     {
         var underlyingAsset     = Parse(instrumentId);
         var listBasicQuotations = new List <BasicQuotation>();
         var counter             = 0;
         foreach (var val in value)
         {
             listBasicQuotations.Add(BasicQuotationHelper.Create(val, measureType[counter],
                                                                 priceQuoteUnits[counter]));
             counter++;
         }
         return(new Pair <Asset, BasicAssetValuation>(underlyingAsset,
                                                      BasicAssetValuationHelper.Create(underlyingAsset.id,
                                                                                       listBasicQuotations.ToArray
                                                                                           ())));
     }
     throw new System.Exception("Unequal number of values and priceQuoteUnits.");
 }
示例#7
0
        /// <summary>
        /// Parses the string info into an asset.
        /// </summary>
        /// <param name="bondTypeId">The type of bond.</param>
        /// <param name="coupon">The coupon rate</param>
        /// <param name="daycount">The daycount.</param>
        /// <param name="frequency">The frequency.</param>
        /// <param name="ytm">The ytm.</param>
        /// <param name="maturityDate">The maturity date.</param>
        /// <returns></returns>
        public static Pair <Asset, BasicAssetValuation> ParseBond(string bondTypeId, DateTime maturityDate, decimal coupon, string daycount, string frequency, decimal ytm)
        {
            const string rateQuotationType = "MarketQuote";
            var          bondId            = bondTypeId + '-' + coupon + '-' + maturityDate.ToShortDateString();
            var          underlyingAsset   = new Bond
            {
                id                  = bondId,
                maturity            = maturityDate,
                maturitySpecified   = true,
                couponRate          = coupon,
                couponRateSpecified = true,
                dayCountFraction    = DayCountFractionHelper.Parse(daycount),
                paymentFrequency    = PeriodHelper.Parse(frequency)
            };
            var listBasicQuotations = new List <BasicQuotation>
            {
                BasicQuotationHelper.Create(ytm, rateQuotationType, "DecimalRate")
            };

            return(new Pair <Asset, BasicAssetValuation>(underlyingAsset, BasicAssetValuationHelper.Create(underlyingAsset.id, listBasicQuotations.ToArray())));
        }
示例#8
0
        /// <summary>
        /// Gets the spot date relative to the date provided.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="cache">The cache.</param>
        /// <param name="nameSpace"></param>
        /// <param name="baseDate"></param>
        /// <param name="fixingCalendar"></param>
        /// <param name="rollCalendar"></param>
        /// <returns></returns>
        public DateTime GetSpotDate(ILogger logger, ICoreCache cache, string nameSpace, DateTime baseDate,
                                    IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar)
        {
            //var bq = BasicQuotationHelper.Create(.79m, "MarketQuote"); no magic constants in code
            var bq  = BasicQuotationHelper.Create(0, "MarketQuote");
            var bav = BasicAssetValuationHelper.Create(bq);
            //var quotedCurrencyPair = commodityCurveId.QuotedCurrencyPair;
            var quotedCurrencyPair = ((FpML.V5r10.Reporting.FxCurve)GetFpMLData().First).quotedCurrencyPair;
            var identifier         = quotedCurrencyPair.currency1.Value + quotedCurrencyPair.currency2.Value + "-CommoditySpot-SP";
            var fxspot             = new FxRateAsset
            {
                id       = identifier,
                currency = new IdentifiedCurrency {
                    Value = quotedCurrencyPair.currency1.Value
                },
                quotedCurrencyPair = quotedCurrencyPair
            };

            var priceableAsset = (IPriceableCommodityAssetController)PriceableAssetFactory.Create(logger, cache, nameSpace, fxspot.id, baseDate, bav, fixingCalendar, rollCalendar);
            var spot           = priceableAsset.GetRiskMaturityDate();

            return(spot);
        }
示例#9
0
        /// <summary>
        /// Parses the string info into an asset.
        /// </summary>
        /// <param name="instrumentId"></param>
        /// <param name="value"></param>
        /// <param name="adjustment"></param>
        /// <returns></returns>
        public static Pair <Asset, BasicAssetValuation> Parse(string instrumentId, decimal value, decimal?adjustment)
        {
            const string rateQuotationType       = PriceableSimpleRateAsset.RateQuotationType;
            const string volatilityQuotationType = PriceableCapRateAsset.VolatilityQuotationType;
            Asset        underlyingAsset;
            decimal      additional = 0.0m;

            if (adjustment != null)
            {
                additional = (decimal)adjustment;
            }
            var listBasicQuotations = new List <BasicQuotation>();
            var properties          = new PriceableAssetProperties(instrumentId);

            switch (properties.AssetType)
            {
            //This is in place to handle volatility curves where the tenor is the expiry.
            case AssetTypesEnum.Period:
            {
                //There is no underlying asset.
                underlyingAsset = null;
                listBasicQuotations.Add(BasicQuotationHelper.Create(instrumentId, value, volatilityQuotationType, "LognormalVolatility"));
                break;
            }

            case AssetTypesEnum.ZeroRate:
            {
                underlyingAsset = new Cash {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.Xibor:
            case AssetTypesEnum.OIS:
            {
                underlyingAsset = new RateIndex {
                    id = instrumentId, term = properties.TermTenor
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.IRSwap:
            case AssetTypesEnum.ClearedIRSwap:
            case AssetTypesEnum.OISSwap:
            case AssetTypesEnum.XccySwap:
            case AssetTypesEnum.SimpleIRSwap:
            case AssetTypesEnum.XccyBasisSwap:
            case AssetTypesEnum.BasisSwap:
            case AssetTypesEnum.ResettableXccyBasisSwap:
            {
                underlyingAsset = new SimpleIRSwap {
                    id = instrumentId, term = properties.TermTenor
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.Caplet:
            case AssetTypesEnum.Floorlet:
            case AssetTypesEnum.BillCaplet:
            case AssetTypesEnum.BillFloorlet:
            {
                underlyingAsset = new SimpleFra
                {
                    id        = instrumentId,
                    startTerm = properties.TermTenor,
                    endTerm   = properties.TermTenor.Sum(properties.ForwardIndex)
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, volatilityQuotationType, "LognormalVolatility"));
                if (adjustment != null)
                {
                    listBasicQuotations.Add(BasicQuotationHelper.Create(additional, "Strike", "DecimalRate"));
                }
                break;
            }

            case AssetTypesEnum.Deposit:
            case AssetTypesEnum.SpreadDeposit:
            case AssetTypesEnum.XccyDepo:
            case AssetTypesEnum.BankBill:
            case AssetTypesEnum.Repo:
            case AssetTypesEnum.RepoSpread:
            {
                underlyingAsset = new Deposit {
                    id = instrumentId, term = properties.TermTenor
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.SimpleFra:
            case AssetTypesEnum.Fra:
            case AssetTypesEnum.BillFra:
            case AssetTypesEnum.SpreadFra:
            {
                underlyingAsset = new SimpleFra
                {
                    id        = instrumentId,
                    startTerm = properties.TermTenor,
                    endTerm   = properties.TermTenor.Sum(properties.ForwardIndex)      //TODO this restricts the perios to be the same!!!
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.Swaption:
            {
                underlyingAsset = new SimpleIRSwap {
                    id = instrumentId, term = properties.TermTenor
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, volatilityQuotationType, "LognormalVolatility"));
                if (adjustment != null)
                {
                    listBasicQuotations.Add(BasicQuotationHelper.Create(additional, "Strike", "DecimalRate"));
                }
                break;
            }

            case AssetTypesEnum.IRFloor:
            case AssetTypesEnum.IRCap:
            {
                underlyingAsset = new SimpleIRSwap {
                    id = instrumentId, term = properties.TermTenor
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, volatilityQuotationType, "LognormalVolatility"));
                if (adjustment != null)
                {
                    listBasicQuotations.Add(BasicQuotationHelper.Create(additional, "Strike", "DecimalRate"));
                }
                break;
            }

            case AssetTypesEnum.IRFutureOption:
            case AssetTypesEnum.IRCallFutureOption:
            case AssetTypesEnum.IRPutFutureOption:
            {
                underlyingAsset = new Future {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, volatilityQuotationType, "LognormalVolatility"));
                if (adjustment != null)
                {
                    listBasicQuotations.Add(BasicQuotationHelper.Create(additional, "Strike", "DecimalRate"));
                }
                break;
            }

            case AssetTypesEnum.IRFuture:
            {
                underlyingAsset = new Future {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalRate"));
                if (adjustment != null)
                {
                    listBasicQuotations.Add(BasicQuotationHelper.Create(additional, "Volatility", "LognormalVolatility"));
                }
                break;
            }

            case AssetTypesEnum.CommodityFuture:
            case AssetTypesEnum.CommodityFutureSpread:
            {
                underlyingAsset = new Future {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.CPIndex:
            {
                underlyingAsset = new RateIndex {
                    id = instrumentId, term = properties.TermTenor
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.SimpleCPISwap:
            case AssetTypesEnum.CPISwap:
            case AssetTypesEnum.ZCCPISwap:
            {
                underlyingAsset = new SimpleIRSwap {
                    id = instrumentId, term = properties.TermTenor
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "DecimalRate"));
                break;
            }

            case AssetTypesEnum.FxSpot:
            case AssetTypesEnum.FxForward:
            {
                underlyingAsset = new FxRateAsset {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "FxRate"));
                break;
            }

            case AssetTypesEnum.Equity:
            case AssetTypesEnum.EquityForward:
            {
                underlyingAsset = new EquityAsset {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "Price"));
                break;
            }

            case AssetTypesEnum.CommoditySpot:
            case AssetTypesEnum.CommodityForward:
            case AssetTypesEnum.CommodityAverageForward:
            case AssetTypesEnum.CommoditySpread:
            {
                underlyingAsset = new Commodity {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "Price"));
                break;
            }

            case AssetTypesEnum.Bond:
            case AssetTypesEnum.BondSpot:
            case AssetTypesEnum.BondForward:
            {
                underlyingAsset = new Bond {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalRate"));        //Changed from DirtyPrice.
                break;
            }

            case AssetTypesEnum.Lease:
            {
                underlyingAsset = new Lease {
                    id = instrumentId
                };
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + additional, rateQuotationType, "Price"));
                break;
            }

            default:
                throw new NotSupportedException($"Asset type {properties.AssetType} is not supported");
            }
            var id = underlyingAsset?.id;

            if (underlyingAsset == null)
            {
                id = listBasicQuotations[0].id;
            }
            return(new Pair <Asset, BasicAssetValuation>(underlyingAsset, BasicAssetValuationHelper.Create(id, listBasicQuotations.ToArray())));
        }
示例#10
0
        /// <summary>
        /// Parses the data.
        /// </summary>
        /// <param name="instrumentIds"></param>
        /// <returns></returns>
        public static QuotedAssetSet Parse(string[] instrumentIds)
        {
            var quotedAssetSetFactory = new QuotedAssetSetFactory();

            const string rateQuotationType = "MarketQuote";

            for (var i = 0; i < instrumentIds.Length; i++)
            {
                Asset underlyingAsset;

                var instrumentId = instrumentIds[i];
                var results      = instrumentIds[i].Split('-');
                var instrument   = results[1];

                var listBasicQuotations = new List <BasicQuotation>();

                const string priceUnitDecimalRate = "DecimalRate";

                switch (instrument)
                {
                case "ZeroRate":
                {
                    underlyingAsset = new Cash {
                        id = instrumentId
                    };
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    break;
                }

                case "Xibor":
                case "OIS":
                {
                    var tenor = results[2];
                    underlyingAsset = new RateIndex {
                        id = instrumentId, term = Period.Parse(tenor)
                    };
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    break;
                }

                case "IRSwap":
                case "XccySwap":
                case "SimpleIRSwap":
                {
                    underlyingAsset = new SimpleIRSwap {
                        id = instrumentId, term = Period.Parse(results[2])
                    };
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    break;
                }

                case "Deposit":
                case "XccyDepo":
                case "BankBill":
                {
                    underlyingAsset = new Deposit {
                        id = instrumentId, term = Period.Parse(results[2])
                    };
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    break;
                }

                case "SimpleFra":
                case "Fra":
                case "BillFra":
                {
                    var index = results[3];
                    var asset = new SimpleFra {
                        id = instrumentId, startTerm = Period.Parse(results[2])
                    };

                    asset.endTerm   = asset.startTerm.Sum(Period.Parse(index));
                    underlyingAsset = asset;
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    break;
                }

                case "IRFuture":
                {
                    underlyingAsset = new Future {
                        id = instrumentId
                    };
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    listBasicQuotations.Add(BasicQuotationHelper.Create("Volatility", "LognormalVolatility"));
                    break;
                }

                case "CPIndex":
                {
                    var tenor = results[2];
                    underlyingAsset = new RateIndex {
                        id = instrumentId, term = Period.Parse(tenor)
                    };
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    break;
                }

                case "SimpleCPISwap":
                case "CPISwap":
                case "ZCCPISwap":
                {
                    underlyingAsset = new SimpleIRSwap {
                        id = instrumentId, term = Period.Parse(results[2])
                    };
                    listBasicQuotations.Add(BasicQuotationHelper.Create(rateQuotationType, priceUnitDecimalRate));
                    break;
                }

                default:
                    throw new NotSupportedException(string.Format("Asset type {0} is not supported", instrument));
                }

                quotedAssetSetFactory.AddAssetAndQuotes(underlyingAsset, BasicAssetValuationHelper.Create(underlyingAsset.id, listBasicQuotations.ToArray()));
            }
            return(quotedAssetSetFactory.Create());
        }
示例#11
0
        /// <summary>
        /// Parses the string info into an asset.
        /// </summary>
        /// <param name="instrumentId"></param>
        /// <param name="value"></param>
        /// <param name="adjustment"></param>
        /// <returns></returns>
        public static Pair <Asset, BasicAssetValuation> Parse(string instrumentId, decimal value, decimal adjustment)
        {
            const string rateQuotationType = "MarketQuote";
            Asset        underlyingAsset;
            var          results             = instrumentId.Split('-');
            var          instrument          = results[1];
            var          listBasicQuotations = new List <BasicQuotation>();

            switch (instrument)
            {
            case "ZeroRate":
            {
                var zeroRate = new Cash {
                    id = instrumentId
                };
                underlyingAsset = zeroRate;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalRate"));
                break;
            }

            case "Xibor":
            case "OIS":
            {
                var tenor     = results[2];
                var rateIndex = new RateIndex {
                    id = instrumentId, term = Period.Parse(tenor)
                };
                underlyingAsset = rateIndex;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + adjustment, rateQuotationType, "DecimalRate"));
                break;
            }

            case "IRSwap":
            case "XccySwap":
            case "SimpleIRSwap":
            {
                var simpleIRSwap = new SimpleIRSwap {
                    id = instrumentId, term = Period.Parse(results[2])
                };
                underlyingAsset = simpleIRSwap;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + adjustment, rateQuotationType, "DecimalRate"));
                break;
            }

            case "Deposit":
            case "XccyDepo":
            case "BankBill":
            {
                var deposit = new Deposit {
                    id = instrumentId, term = Period.Parse(results[2])
                };
                underlyingAsset = deposit;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + adjustment, rateQuotationType, "DecimalRate"));
                break;
            }

            case "SimpleFra":
            case "Fra":
            case "BillFra":
            case "SpreadFra":
            {
                var index = results[3];
                var asset = new SimpleFra {
                    id = instrumentId, startTerm = Period.Parse(results[2])
                };

                asset.endTerm   = asset.startTerm.Sum(Period.Parse(index));
                underlyingAsset = asset;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + adjustment, rateQuotationType, "DecimalRate"));
                break;
            }

            case "IRCap":
            {
                var simpleIRCap = new SimpleIRSwap {
                    id = instrumentId, term = Period.Parse(results[2])
                };
                underlyingAsset = simpleIRCap;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, "Premium", "Amount"));
                break;
            }

            case "IRFuture":
            {
                var future = new Future {
                    id = instrumentId
                };

                underlyingAsset = future;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalRate"));
                listBasicQuotations.Add(BasicQuotationHelper.Create(adjustment, "Volatility", "LognormalVolatility"));
                break;
            }

            case "CommodityFuture":
            {
                var future = new Future {
                    id = instrumentId
                };

                underlyingAsset = future;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DecimalRate"));
                break;
            }

            case "CPIndex":
            {
                var tenor     = results[2];
                var rateIndex = new RateIndex {
                    id = instrumentId, term = Period.Parse(tenor)
                };
                underlyingAsset = rateIndex;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + adjustment, rateQuotationType, "DecimalRate"));
                break;
            }

            case "SimpleCPISwap":
            case "CPISwap":
            case "ZCCPISwap":
            {
                var simpleIRSwap = new SimpleIRSwap {
                    id = instrumentId, term = Period.Parse(results[2])
                };
                underlyingAsset = simpleIRSwap;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + adjustment, rateQuotationType, "DecimalRate"));
                break;
            }

            case "FxSpot":
            case "FxForward":
            {
                //  var tenor = results[2];
                var fxRateAsset = new FxRateAsset {
                    id = instrumentId
                };
                underlyingAsset = fxRateAsset;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value + adjustment, rateQuotationType, "FxRate"));
                break;
            }

            case "CommoditySpot":
            case "CommodityForward":
            {
                var commodityAsset = new FxRateAsset {
                    id = instrumentId
                };
                underlyingAsset = commodityAsset;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "Price"));
                break;
            }

            case "Bond":
            {
                var asset = new Bond {
                    id = instrumentId
                };
                underlyingAsset = asset;
                listBasicQuotations.Add(BasicQuotationHelper.Create(value, rateQuotationType, "DirtyPrice"));
                break;
            }

            default:
                throw new NotSupportedException(string.Format("Asset type {0} is not supported", instrument));
            }

            return(new Pair <Asset, BasicAssetValuation>(underlyingAsset, BasicAssetValuationHelper.Create(underlyingAsset.id, listBasicQuotations.ToArray())));
        }