コード例 #1
0
ファイル: ExchangeRate.cs プロジェクト: zhangz/Highlander.Net
        /// <summary>
        ///
        /// </summary>
        /// <param name="currency1"></param>
        /// <param name="currency2"></param>
        /// <param name="quoteBasis"></param>
        /// <param name="spotRate"></param>
        /// <param name="forwardRate"></param>
        /// <param name="forwardPoints"></param>
        /// <returns></returns>
        public static ExchangeRate Create(string currency1, string currency2, QuoteBasisEnum quoteBasis,
                                          Decimal spotRate, Decimal forwardRate, Decimal?forwardPoints)
        {
            var exchangeRate = new ExchangeRate
            {
                quotedCurrencyPair = QuotedCurrencyPair.Create(currency1, currency2, quoteBasis),
                rate              = forwardRate,
                rateSpecified     = true,
                spotRate          = spotRate,
                spotRateSpecified = true
            };

            if (forwardPoints != null)
            {
                exchangeRate.forwardPointsField = (decimal)forwardPoints;
            }
            return(exchangeRate);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="hasExpired"></param>
        /// <param name="putCurrencyPayPartyReference"></param>
        /// <param name="callCurrencyPayPartyReference"></param>
        /// <param name="putCurrencyAmount"></param>
        /// <param name="putCurrency"></param>
        /// <param name="callCurrencyAmount"></param>
        /// <param name="callCurrency"></param>
        /// <param name="strikeQuoteBasis"></param>
        /// <param name="valueDate"></param>
        /// <param name="fxRate"></param>
        /// <returns></returns>
        public static FxSingleLeg CreateFxSingleLeg(bool hasExpired, string putCurrencyPayPartyReference, string callCurrencyPayPartyReference, decimal putCurrencyAmount,
                                                    string putCurrency, decimal callCurrencyAmount, string callCurrency, StrikeQuoteBasisEnum strikeQuoteBasis, DateTime valueDate, Decimal fxRate)
        {
            QuoteBasisEnum quoteBasis   = strikeQuoteBasis == StrikeQuoteBasisEnum.CallCurrencyPerPutCurrency ? QuoteBasisEnum.Currency2PerCurrency1 : QuoteBasisEnum.Currency1PerCurrency2;
            ExchangeRate   exchangeRate = hasExpired ? ExchangeRate.Create(putCurrency, callCurrency, quoteBasis, fxRate)
                                            : ExchangeRate.Create(putCurrency, callCurrency, quoteBasis, fxRate, fxRate, null);
            var fxForward = new FxSingleLeg
            {
                exchangedCurrency1 =
                    PaymentHelper.Create(putCurrencyPayPartyReference, callCurrencyPayPartyReference,
                                         putCurrency, putCurrencyAmount),
                exchangedCurrency2 =
                    PaymentHelper.Create(callCurrencyPayPartyReference, putCurrencyPayPartyReference,
                                         callCurrency, callCurrencyAmount),
                Items            = new[] { valueDate },
                ItemsElementName = new[] { ItemsChoiceType31.valueDate },
                exchangeRate     = exchangeRate,
            };

            return(fxForward);
        }
コード例 #3
0
        /// <summary>
        /// Builds an  fx trade from the current vanilla fx option class.
        /// </summary>
        /// <param name="hasExpired"></param>
        /// <returns></returns>
        public FxSingleLeg CreateFxSingleLeg(bool hasExpired)
        {
            QuoteBasisEnum quoteBasis   = strike.strikeQuoteBasis == StrikeQuoteBasisEnum.CallCurrencyPerPutCurrency ? QuoteBasisEnum.Currency2PerCurrency1 : QuoteBasisEnum.Currency1PerCurrency2;
            ExchangeRate   exchangeRate = hasExpired ? ExchangeRate.Create(putCurrencyAmount.currency.Value, putCurrencyAmount.currency.Value, quoteBasis, strike.rate)
                                            : ExchangeRate.Create(putCurrencyAmount.currency.Value, putCurrencyAmount.currency.Value, quoteBasis, strike.rate, strike.rate, null);
            var fxForward = new FxSingleLeg
            {
                //exchangedCurrency1 =
                //    PaymentHelper.Create(this.putCurrencyPayPartyReference, callCurrencyPayPartyReference,
                //                         putCurrency, putCurrencyAmount),
                //exchangedCurrency2 =
                //    PaymentHelper.Create(callCurrencyPayPartyReference, putCurrencyPayPartyReference,
                //                         callCurrency, callCurrencyAmount),
                exchangeRate     = exchangeRate,
                ItemsElementName = new[] { ItemsChoiceType31.valueDate }
            };

            if (Item is FxEuropeanExercise exercise && exercise.expiryDateSpecified)
            {
                fxForward.Items = new[] { exercise.expiryDate };
            }
            return(fxForward);
        }