Beispiel #1
0
        public static Money CopyToMoney(MoneyBase original)
        {
            var cloned = new Money();

            if (original as Money != null)
            {
                cloned.amount = ((Money)original).amount;
            }
            else if (original as NonNegativeMoney != null)
            {
                cloned.amount = ((NonNegativeMoney)original).amount;
            }
            else if (original as PositiveMoney != null)
            {
                cloned.amount = ((PositiveMoney)original).amount;
            }
            if (null != original.currency)
            {
                cloned.currency = new Currency();
                if (null != original.currency.currencyScheme)
                {
                    cloned.currency.currencyScheme = original.currency.currencyScheme;
                }
                if (null != original.currency.Value)
                {
                    cloned.currency.Value = original.currency.Value;
                }
            }
            cloned.id = original.id;
            cloned.amountSpecified = true;
            return(cloned);
        }
Beispiel #2
0
        /// <summary>
        /// THis will only clone: Positivemmoney, NonNegativeMoney and Money types.
        /// </summary>
        /// <param name="original"></param>
        /// <param name="currencyToClone"></param>
        /// <returns></returns>
        public static Money CopyToMoney(MoneyBase original, Currency currencyToClone)
        {
            var amount = GetZeroAmount(currencyToClone.Value);

            // || original as PositiveMoney != null || original as NonNegativeMoney != null
            if (null != original.currency)
            {
                if (original.currency.Value == currencyToClone.Value)
                {
                    if (original as Money != null)
                    {
                        amount.amount = ((Money)original).amount;
                    }
                    else if (original as NonNegativeMoney != null)
                    {
                        amount.amount = ((NonNegativeMoney)original).amount;
                    }
                    else if (original as PositiveMoney != null)
                    {
                        amount.amount = ((PositiveMoney)original).amount;
                    }
                }
            }
            amount.id = original.id;
            amount.amountSpecified = true;
            return(amount);
        }
Beispiel #3
0
        /// <summary>
        /// お金クラスをインスタンス化して、手に持たせる。
        /// </summary>
        /// <param name="moneyType"></param>
        private void CreateMoney(MoneyType moneyType)
        {
            MoneyManager manager = MoneyManager.GetInstance();

            _moneyInHand = manager.CreateMoney(moneyType);

            this.moneyInHandDisplay.Text = "手に" + moneyType.ToString() + "を持っています。";
        }
Beispiel #4
0
        public static Money Normalise(MoneyBase originalMoney, bool isPayerBase)
        {
            var money = CopyToMoney(originalMoney);//TODO this does nothing

            //money.amount = System.Math.Abs(money.amount);
            if (isPayerBase)
            {
                money.amount = -1 * money.amount;
            }
            money.amountSpecified = true;
            return(money);
        }
Beispiel #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PriceableIRSwap"/> class.
        /// </summary>
        /// <param name="baseDate">The base date.</param>
        /// <param name="fixedLegSwap">The fixed leg details.</param>
        /// <param name="spotDate">the spot date.</param>
        /// <param name="notional">The notional amount.</param>
        /// <param name="paymentBusinessDayAdjustments">The business day adjustments.</param>
        /// <param name="floatingLegSwap">The floating leg details.</param>
        /// <param name="floatingLegcalculation">The floatingLegcalculation.</param>
        /// <param name="fixingDateOffset">The fixing date business day adjustments.</param>
        /// <param name="resetRates">The reset rates of the floating leg - if any.</param>
        /// <param name="fixingCalendar">The fixing calendar. If null, a new is constructed based on the business calendars.</param>
        /// <param name="paymentCalendar">The payment calendar. If null, a new is constructed based on the business calendars.</param>
        /// <param name="fixedRate">The fixed rate.</param>
        /// <param name="spread">The spread on the floating leg.</param>
        public PriceableIRSwap(DateTime baseDate, SimpleIRSwap fixedLegSwap, DateTime spotDate, MoneyBase notional,
                               BusinessDayAdjustments paymentBusinessDayAdjustments, SimpleIRSwap floatingLegSwap,
                               Calculation floatingLegcalculation, RelativeDateOffset fixingDateOffset, List <Decimal> resetRates,
                               IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, BasicQuotation fixedRate, BasicQuotation spread)
            : base(baseDate, fixedLegSwap, fixingDateOffset, floatingLegcalculation, paymentBusinessDayAdjustments, null, fixingCalendar, paymentCalendar, fixedRate)
        {
            ModelIdentifier     = DiscountingType == null ? "SwapAsset" : "DiscountSwapAsset";
            FloatingLegSpread   = GetSpread(spread);
            ForwardRates        = resetRates?.ToArray();
            UnderlyingRateIndex = RateIndexHelper.Parse(FloatingRateCalculation.floatingRateIndex.Value, notional.currency.Value, Calculation.dayCountFraction.Value);
            var unadjustedFloatingDates = DateScheduler.GetUnadjustedDateSchedule(spotDate, floatingLegSwap.term, floatingLegSwap.paymentFrequency);

            FloatingLegAdjustedPeriodDates = AdjustedDateScheduler.GetAdjustedDateSchedule(unadjustedFloatingDates, paymentBusinessDayAdjustments.businessDayConvention, paymentCalendar);
            FloatingLegWeightings          = CreateWeightings(CDefaultWeightingValue, FloatingLegAdjustedPeriodDates.Count - 1);
            FloatingLegYearFractions       = GetFloatingLegYearFractions();
        }