Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceableIRSwap"/> class.
 /// </summary>
 /// <param name="amount">The ammount.</param>
 /// <param name="discountingType">The discounting type.</param>
 /// <param name="effectiveDate">The base date.</param>
 /// <param name="tenor">The maturity tenor.</param>
 /// <param name="fxdDayFraction">The fixed leg day fraction.</param>
 /// <param name="businessCenters">The payment business centers.</param>
 /// <param name="businessDayConvention">The payment business day convention.</param>
 /// <param name="fxdFrequency">The business day adjustments.</param>
 /// <param name="underlyingRateIndex">Index of the rate.</param>
 /// <param name="fixedRate">The fixed rate.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="baseDate">The base date.</param>
 /// <param name="currency">THe currency.</param>
 /// <param name="fixingCalendar">The fixingCalendar.</param>
 /// <param name="paymentCalendar">The paymentCalendar.</param>
 public PriceableIRSwap(string id, DateTime baseDate, string currency,
                        decimal amount, DiscountingTypeEnum?discountingType,
                        DateTime effectiveDate, string tenor, string fxdDayFraction,
                        string businessCenters, string businessDayConvention, string fxdFrequency,
                        RateIndex underlyingRateIndex, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar,
                        BasicQuotation fixedRate)
     : base(baseDate, SimpleIrsHelper.Parse(id, currency, fxdDayFraction, tenor, fxdFrequency, id),
            effectiveDate,
            CalculationFactory.CreateFixed(fixedRate.value, MoneyHelper.GetAmount(amount, currency),
                                           DayCountFractionHelper.Parse(fxdDayFraction), discountingType),
            BusinessDayAdjustmentsHelper.Create(businessDayConvention, businessCenters), underlyingRateIndex,
            fixingCalendar, paymentCalendar, fixedRate)
 {
     ModelIdentifier = DiscountingType == null ? "SwapAsset" : "DiscountSwapAsset";
 }
Exemple #2
0
    void OnClickBet(GameObject obj)
    {
        int index = int.Parse(obj.name);

        current_bet += GameControl.instance.ListBetTaiXiu[index];
        if (current_bet >= ClientConfig.UserInfo.CASH_FREE)
        {
            current_bet = ClientConfig.UserInfo.CASH_FREE;
        }
        txt_money.text = MoneyHelper.FormatMoneyNormal(current_bet);
        if (!obj_arrow.activeSelf)
        {
            obj_arrow.SetActive(true);
        }
    }
 void EffectRunMoney(Text txt_target, long oldMoney, long newMoney)
 {
     if (oldMoney == newMoney)
     {
         return;
     }
     if (isActiveAndEnabled)
     {
         StartCoroutine(RunEffectText(txt_target, oldMoney, newMoney));
     }
     else
     {
         txt_target.text = MoneyHelper.FormatMoneyNormal(newMoney);
     }
 }
Exemple #4
0
        private void AddCashFlows(ILogger logger, ICoreCache cache,
                                  IBusinessCalendar fixingCalendar,
                                  IBusinessCalendar paymentCalendar,
                                  Fra fraFpML, bool isBuyer, String nameSpace)
        {
            EffectiveDate   = fraFpML.adjustedEffectiveDate.Value;
            TerminationDate = fraFpML.adjustedTerminationDate;
            if (paymentCalendar == null)
            {
                paymentCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, fraFpML.paymentDate.dateAdjustments.businessCenters, nameSpace);
            }
            if (fixingCalendar == null)
            {
                fixingCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, fraFpML.fixingDateOffset.businessCenters, nameSpace);
            }
            DateTime unadjustedPaymentDate = fraFpML.paymentDate.unadjustedDate.Value;
            var      notional = MoneyHelper.GetAmount(fraFpML.notional.amount, fraFpML.notional.currency);

            PaymentDate = paymentCalendar.Roll(unadjustedPaymentDate, BusinessDayConventionHelper.Parse(fraFpML.paymentDate.dateAdjustments.businessDayConvention.ToString()));
            DateTime adjustedFixingDate = GetResetDate(logger, cache, fixingCalendar, fraFpML, nameSpace);
            var      interval           = fraFpML.indexTenor[0];
            var      floatingInterest   = new PriceableFloatingRateCoupon(fraFpML.id + "FloatingCoupon_1"
                                                                          , isBuyer
                                                                          , EffectiveDate
                                                                          , TerminationDate
                                                                          , adjustedFixingDate
                                                                          , fraFpML.dayCountFraction
                                                                          , 0.0m
                                                                          , FixedRate
                                                                          , null
                                                                          , isBuyer ? MoneyHelper.Neg(notional) : notional
                                                                          , PaymentDate
                                                                          , new ForecastRateIndex {
                floatingRateIndex = fraFpML.floatingRateIndex, indexTenor = interval
            }
                                                                          , null
                                                                          , null
                                                                          , fraFpML.fraDiscounting
                                                                          , paymentCalendar
                                                                          , fixingCalendar)
            {
                ForecastRateInterpolation = ForecastRateInterpolation
            };

            // Combine two cashflows into one leg
            //
            FloatingCoupon = floatingInterest;//fraFpML.fraDiscounting,
        }
        /// <summary>
        /// Builds the calculation period.
        /// </summary>
        /// <returns></returns>
        override protected CalculationPeriod BuildCalculationPeriod()
        {
            CalculationPeriod cp = base.BuildCalculationPeriod();

            FloatingRateDefinition floatingRateDefinition = FloatingRateDefinitionHelper.CreateSimple(ForecastRateIndex.floatingRateIndex, ForecastRateIndex.indexTenor, AdjustedFixingDate, GetRate(), Margin);

            cp.Item1 = floatingRateDefinition;

            if (floatingRateDefinition.calculatedRateSpecified)
            {
                cp.forecastRate          = floatingRateDefinition.calculatedRate;
                cp.forecastRateSpecified = true;
            }
            cp.forecastAmount = MoneyHelper.GetAmount(CalculationResults.ExpectedValue, NotionalAmount.currency.Value);
            return(cp);
        }
Exemple #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fraInputRange"></param>
        /// <returns></returns>
        public static Fra GetFpMLFra(FraInputRange fraInputRange)
        {
            var fra = new Fra
            {
                adjustedEffectiveDate =
                    DateTypesHelper.ToRequiredIdentifierDate(fraInputRange.AdjustedEffectiveDate),
                adjustedTerminationDate = fraInputRange.AdjustedTerminationDate,
                paymentDate             =
                    DateTypesHelper.ToAdjustableDate(fraInputRange.UnadjustedPaymentDate,
                                                     fraInputRange.PaymentDateBusinessDayConvention,
                                                     fraInputRange.PaymentDateBusinessCenters)
            };

            if ("resetDate" != fraInputRange.FixingDayOffsetDateRelativeTo)
            {
                throw new ArgumentException("The fixing date must be specified as 'resetDate'-relative!", nameof(fraInputRange));
            }
            var fixingDayType = EnumHelper.Parse <DayTypeEnum>(fraInputRange.FixingDayOffsetDayType);

            fra.fixingDateOffset = RelativeDateOffsetHelper.Create(fraInputRange.FixingDayOffsetPeriod, fixingDayType,
                                                                   fraInputRange.FixingDayOffsetBusinessDayConvention,
                                                                   fraInputRange.FixingDayOffsetBusinessCenters,
                                                                   fraInputRange.FixingDayOffsetDateRelativeTo);
            fra.dayCountFraction = DayCountFractionHelper.Parse(fraInputRange.DayCountFraction);
            IDayCounter dayCounter = DayCounterHelper.Parse(fra.dayCountFraction.Value);

            fra.calculationPeriodNumberOfDays = dayCounter.DayCount(fra.adjustedEffectiveDate.Value, fra.adjustedTerminationDate).ToString();
            fra.notional          = MoneyHelper.GetAmount(fraInputRange.NotionalAmount, fraInputRange.NotionalCurrency);
            fra.fixedRate         = (decimal)fraInputRange.FixedRate;
            fra.floatingRateIndex = FloatingRateIndexHelper.Parse(fraInputRange.FloatingRateIndex);
            fra.indexTenor        = new[] { PeriodHelper.Parse(fraInputRange.IndexTenor) };
            fra.fraDiscounting    = fraInputRange.FraDiscounting;
            PartyReference nabParty     = PartyReferenceFactory.Create("NAB");
            PartyReference counterParty = PartyReferenceFactory.Create("COUNTERPARTY");

            if (bool.Parse(fraInputRange.Sell))
            {
                fra.sellerPartyReference = nabParty;
                fra.buyerPartyReference  = counterParty;
            }
            else
            {
                fra.sellerPartyReference = counterParty;
                fra.buyerPartyReference  = nabParty;
            }
            return(fra);
        }
 public static void UpdatePaymentsAmounts(IBusinessCalendar paymentCalendar,
                                          CapFloor capFloor,
                                          CapFloorLegParametersRange capFloorLeg,
                                          IRateCurve discountCurve,
                                          DateTime valuationDate)
 {
     foreach (Payment payment in capFloor.additionalPayment)
     {
         var date = AdjustedDateHelper.GetAdjustedDate(paymentCalendar, payment.paymentDate);
         if (date != null)
         {
             payment.discountFactor          = (decimal)discountCurve.GetDiscountFactor(valuationDate, (DateTime)date);
             payment.discountFactorSpecified = true;
             payment.presentValueAmount      = MoneyHelper.Mul(payment.paymentAmount, payment.discountFactor);
         }
     }
 }
Exemple #8
0
    IEnumerator Init()
    {
        yield return(new WaitForEndOfFrame());

        txt_name.text     = ClientConfig.UserInfo.UNAME;
        txt_money.text    = MoneyHelper.FormatMoneyNormal(ClientConfig.UserInfo.CASH_FREE) + " " + GameConfig.MONEY_UNIT_VIP;
        txt_id.text       = "ID: " + ClientConfig.UserInfo.USER_ID;
        txt_sdt.text      = "SĐT:" + ClientConfig.UserInfo.PHONE;
        txt_gold_max.text = string.Format(ClientConfig.Language.GetText("info_player_sogoldmax"), ClientConfig.UserInfo.SO_TIEN_MAX);
        txt_cap_nhat.text = string.Format(ClientConfig.Language.GetText("info_player_capnhat"), ClientConfig.UserInfo.LOGIN_END);
        //		LoadAssetBundle.LoadTexture(raw_avata, BundleName.AVATAS, ClientConfig.UserInfo.AVATAR_ID + "");

        yield return(new WaitForEndOfFrame());

        LoadAssetBundle.LoadSprite(img_avata, BundleName.AVATAS, ClientConfig.UserInfo.AVATAR_ID + "");
        SetThangThua();
    }
        /// <summary>
        ///
        /// </summary>
        /// <param name="couponId"></param>
        /// <param name="bondAsset"></param>
        /// <param name="notionalAmount"></param>
        /// <param name="bondCouponType"></param>
        /// <param name="paymentDate"></param>
        /// <param name="unadjustedStartDate"></param>
        /// <param name="unadjustedEndDate"></param>
        /// <param name="paymentCalendar"></param>
        /// <returns></returns>
        public static PriceableRateCoupon CreatePriceableBondCoupon(string couponId, Bond bondAsset, decimal notionalAmount, CouponStreamType bondCouponType, DateTime unadjustedStartDate,
                                                                    DateTime unadjustedEndDate, DateTime paymentDate, IBusinessCalendar paymentCalendar)//bool fOCalculationMethod, IBusinessCalendar fixingCalendar,
        {
            var currency         = bondAsset.currency;
            var dayCountFraction = bondAsset.dayCountFraction;
            var money            = MoneyHelper.GetAmount(notionalAmount, currency);

            //  If has a fixed rate (fixed rate coupon)
            if (bondCouponType == CouponStreamType.GenericFixedRate)
            {
                PriceableRateCoupon rateCoupon = new PriceableFixedRateCoupon(couponId, false, unadjustedStartDate, unadjustedEndDate,
                                                                              dayCountFraction, bondAsset.couponRate, money, null, paymentDate, null, null,
                                                                              null, paymentCalendar);
                return(rateCoupon);
            }
            throw new System.Exception("CalculationPeriod has neither fixedRate nor floatingRateDefinition.");
        }
        private void AddCashFlow(TermDeposit depositFpML, bool isLenderBase)
        {
            var fixedInterest = new PriceableFixedRateCoupon(depositFpML.id + "FixedCoupon_1"
                                                             , BasePartyPayingFixed
                                                             , EffectiveDate
                                                             , TerminationDate
                                                             , depositFpML.dayCountFraction
                                                             , depositFpML.fixedRate
                                                             , isLenderBase ? MoneyHelper.GetMoney(depositFpML.principal) : MoneyHelper.Neg(depositFpML.principal)
                                                             , null
                                                             , PaymentDate
                                                             , null
                                                             , null
                                                             , null
                                                             , null);

            InterestAmount = fixedInterest;
        }
Exemple #11
0
 void baseSetTurn()
 {
     SetActiveButton();
     if (MoneyCuoc <= 0)
     {
         SetEnableButton(true, true, false, true);
     }
     else if (MoneyCuoc < ((LiengPlayer)playerMe).MoneyFollow)
     {
         SetEnableButton(true, false, true, false);
         txt_theo.text = "Theo " + MoneyHelper.FormatMoneyNormal(MoneyCuoc);
     }
     else
     {
         SetEnableButton(true, false, true, false);
         txt_theo.text = "Theo " + MoneyHelper.FormatMoneyNormal(((LiengPlayer)playerMe).MoneyFollow);
     }
 }
Exemple #12
0
        /// <summary>
        /// Builds this instance.
        /// </summary>
        /// <returns></returns>
        public PrincipalExchange Build()
        {
            var money = MoneyHelper.Mul(PaymentAmount, PayerIsBaseParty);
            var px    = PrincipalExchangeHelper.Create(PaymentDate, money.amount);

            px.id = Id;
            //px.
            px.adjustedPrincipalExchangeDate          = PaymentDate;
            px.adjustedPrincipalExchangeDateSpecified = true;
            if (CalculationPerfomedIndicator)
            {
                px.discountFactor = PaymentDiscountFactor;
                var npv = System.Math.Abs(ForecastAmount.amount) * PaymentDiscountFactor;
                px.discountFactorSpecified             = true;
                px.presentValuePrincipalExchangeAmount = MoneyHelper.Mul(npv, PaymentAmount.currency.Value, PayerIsBaseParty);
            }
            return(px);
        }
        /// <summary>
        /// Builds this instance.
        /// </summary>
        /// <returns></returns>
        public BulletPayment Build()
        {
            var px = new BulletPayment
            {
                payment =
                    new Payment
                {
                    paymentAmount =
                        MoneyHelper.GetNonNegativeAmount(PaymentAmount.amount,
                                                         PaymentAmount.currency.Value)
                },
                Items            = new object[] { ProductTypeHelper.Create(ProductTypeSimpleEnum.BulletPayment.ToString()) },
                ItemsElementName = new[] { ItemsChoiceType2.productType }
            };

            //Setting the items array which contains product type and product is information.
            //payment type information
            px.payment.paymentType = PaymentTypeHelper.Create("Payment");
            //Set the party information
            px.payment.payerPartyReference = new PartyReference {
                href = "Party2"
            };
            px.payment.receiverPartyReference = new PartyReference {
                href = "Party1"
            };
            if (PayerIsBaseParty)
            {
                px.payment.payerPartyReference = new PartyReference {
                    href = "Party1"
                };
                px.payment.receiverPartyReference = new PartyReference {
                    href = "Party2"
                };
            }
            //The payment date
            px.payment.paymentDate = AdjustableOrAdjustedDateHelper.Create(null, PaymentDate, PaymentDateAdjustments);
            if (CalculationPerformedIndicator)
            {
                px.payment.discountFactor          = PaymentDiscountFactor;
                px.payment.discountFactorSpecified = true;
                px.payment.presentValueAmount      = MoneyHelper.GetAmount(CalculationResults.NPV, PaymentAmount.currency.Value);
            }
            return(px);
        }
Exemple #14
0
 public static void UpdatePaymentsAmounts(ILogger logger, ICoreCache cache,
                                          String nameSpace, Swap swap,
                                          SwapLegParametersRange leg1Parameters,
                                          SwapLegParametersRange leg2Parameters,
                                          IRateCurve leg1DiscountCurve,
                                          IRateCurve leg2DiscountCurve,
                                          DateTime valuationDate, IBusinessCalendar paymentCalendar)
 {
     foreach (Payment payment in swap.additionalPayment)
     {
         //  choose correct discount curve
         //
         IRateCurve discountCurve;
         if (payment.payerPartyReference.href == leg1Parameters.Payer)
         {
             discountCurve = leg1DiscountCurve;
         }
         else if (payment.payerPartyReference.href == leg2Parameters.Payer)
         {
             discountCurve = leg2DiscountCurve;
         }
         else
         {
             throw new NotImplementedException();
         }
         if (paymentCalendar == null)
         {
             var containsPaymentDateAdjustments = AdjustableOrAdjustedDateHelper.Contains(payment.paymentDate, ItemsChoiceType.dateAdjustments, out var dateAdjustments);
             if (containsPaymentDateAdjustments && dateAdjustments != null)
             {
                 paymentCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, ((BusinessDayAdjustments)dateAdjustments).
                                                                           businessCenters, nameSpace);
             }
         }
         var date = AdjustedDateHelper.GetAdjustedDate(paymentCalendar, payment.paymentDate);
         if (date == null)
         {
             continue;
         }
         payment.discountFactor          = (decimal)discountCurve.GetDiscountFactor(valuationDate, (DateTime)date);
         payment.discountFactorSpecified = true;
         payment.presentValueAmount      = MoneyHelper.Mul(payment.paymentAmount, payment.discountFactor);
     }
 }
Exemple #15
0
 internal void OnNhanCacMucCuocXD(Message message)
 {
     try {
         for (int i = 0; i < 4; i++)
         {
             long mucc = message.reader().ReadLong();
             SelectBetMoney[i]     = mucc;
             txt_bet_money[i].text = MoneyHelper.FormatRelativelyWithoutUnit(mucc);
         }
         img_effect_bet[0].SetActive(true);
         for (int i = 1; i < img_effect_bet.Length; i++)
         {
             img_effect_bet[i].SetActive(false);
         }
         CurrentBetMoney = SelectBetMoney[0];
     } catch (Exception ex) {
         Debug.LogException(ex);
     }
 }
Exemple #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceablePayment"/> class.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <param name="receiverPartyReference">The receiver.</param>
 /// <param name="payerIsBase">The flag determining if the payer is the base party.</param>
 /// <param name="amount">The amount.</param>
 /// <param name="currency">The currency.</param>
 /// <param name="adjustedPaymentDate">The adjusted payment date.</param>
 /// <param name="payerPartyReference">The payer.</param>
 /// <param name="paymentCalendar">Type paymentCalendar.</param>
 public PriceablePayment
 (
     string id
     , string payerPartyReference
     , string receiverPartyReference
     , bool payerIsBase
     , Decimal amount
     , string currency
     , DateTime adjustedPaymentDate
     , IBusinessCalendar paymentCalendar) :
     base(id, "DiscountedCashflow", payerIsBase, MoneyHelper.GetAmount(amount, currency),
          AdjustableOrAdjustedDateHelper.CreateAdjustedDate(adjustedPaymentDate),
          PaymentTypeHelper.Create("Certain"), CashflowTypeHelper.Create(CashflowTypeEnum.PrincipalExchange.ToString()), false, paymentCalendar)
 {
     PayerPartyReference    = PartyReferenceFactory.Create(payerPartyReference);
     ReceiverPartyReference = PartyReferenceFactory.Create(receiverPartyReference);
     OrderedPartyNames.Add(PayerPartyReference.href);
     OrderedPartyNames.Add(ReceiverPartyReference.href);
 }
Exemple #17
0
        /// <summary>
        /// Builds this instance.
        /// </summary>
        /// <returns></returns>
        public Payment Build()
        {
            var px = PaymentHelper.Create(PayerPartyReference.href, ReceiverPartyReference.href, PaymentAmount.currency.Value, Math.Abs(PaymentAmount.amount), PaymentDate);

            px.id = Id;
            //px.paymentAmount = PaymentAmount;//this is the raw amount without the multiplier effect.
            px.paymentDate = AdjustableOrAdjustedDateHelper.CreateAdjustedDate(AdjustedPaymentDate.Value, PaymentDateAdjustments);
            if (CalculationPerformedIndicator)
            {
                var payment = Math.Abs(ForecastAmount.amount);
                px.paymentAmount = MoneyHelper.GetNonNegativeAmount(payment, ForecastAmount.currency.Value);
                var npv   = Math.Abs(NPV.amount);
                var money = MoneyHelper.GetAmount(npv, PaymentAmount.currency.Value);
                px.discountFactor          = PaymentDiscountFactor;
                px.discountFactorSpecified = true;
                px.presentValueAmount      = money;
            }
            return(px);
        }
        /// <summary>
        /// Builds this instance and returns the underlying instrument associated with the controller
        /// </summary>
        /// <returns></returns>
        public TermDeposit Build()
        {
            var deposit = new TermDeposit
            {
                Items = new object[] { new ProductType {
                                           Value = ProductType.ToString()
                                       } },
                ItemsElementName      = new[] { ItemsChoiceType2.productType },
                dayCountFraction      = DayCountFraction,
                principal             = MoneyHelper.GetPositiveMoney(Principal),
                maturityDate          = TerminationDate,
                maturityDateSpecified = true,
                startDate             = EffectiveDate,
                startDateSpecified    = true,
                fixedRate             = FixedRate,
                fixedRateSpecified    = true
            };

            if (BasePartyPayingFixed)//From the viewpoint of the counterparty!
            {
                deposit.receiverPartyReference = PartyReferenceHelper.Parse(BaseParty);
                deposit.payerPartyReference    = PartyReferenceHelper.Parse(CounterParty);
            }
            else
            {
                deposit.payerPartyReference    = PartyReferenceHelper.Parse(BaseParty);
                deposit.receiverPartyReference = PartyReferenceHelper.Parse(CounterParty);
            }
            //deposit payments.
            if (deposit.payment?.Length == 3)
            {
                var initialDate  = AdjustableOrAdjustedDateHelper.Create(null, EffectiveDate, null);
                var maturityDate = AdjustableOrAdjustedDateHelper.Create(null, PaymentDate, null);
                deposit.payment[0].paymentDate = initialDate;
                deposit.payment[1].paymentDate = maturityDate;
                deposit.payment[2].paymentDate = maturityDate;
            }
            var interest = System.Math.Abs(InterestAmount.AccruedInterest);

            deposit.interest = MoneyHelper.GetAmount(interest, deposit.principal.currency.Value);
            return(deposit);
        }
Exemple #19
0
        public static Trade CreateFraTrade(string tradeId, RequiredIdentifierDate adjustedEffectiveDate, DateTime adjustedTerminationDate,
                                           AdjustableDate paymentDate, RelativeDateOffset fixingDayOffset, DayCountFraction dayCountFraction, decimal notionalAmount,
                                           string notionalCurrency, decimal fixedRate, string floatingRateIndex, string indexTenor, FraDiscountingEnum fraDiscounting)
        {
            var trade = new Trade();
            var fra   = new Fra
            {
                adjustedEffectiveDate            = adjustedEffectiveDate,
                adjustedTerminationDate          = adjustedTerminationDate,
                adjustedTerminationDateSpecified = true,
                paymentDate = paymentDate,
                Items       = new object[] { new ProductType {
                                                 Value = ProductTypeSimpleEnum.FRA.ToString()
                                             } },
                ItemsElementName = new[] { ItemsChoiceType2.productType }
            };

            if ("resetDate" != fixingDayOffset.dateRelativeTo.href)
            {
                throw new ArgumentException("The fixing date must be specified as 'resetDate'-relative!", nameof(fixingDayOffset));
            }
            fra.fixingDateOffset = fixingDayOffset;
            fra.dayCountFraction = dayCountFraction;
            IDayCounter dayCounter = DayCounterHelper.Parse(fra.dayCountFraction.Value);

            fra.calculationPeriodNumberOfDays = dayCounter.DayCount(fra.adjustedEffectiveDate.Value, fra.adjustedTerminationDate).ToString(CultureInfo.InvariantCulture);
            fra.notional                = MoneyHelper.GetAmount(notionalAmount, notionalCurrency);
            fra.fixedRate               = fixedRate;
            fra.fixedRateSpecified      = true;
            fra.floatingRateIndex       = FloatingRateIndexHelper.Parse(floatingRateIndex);
            fra.indexTenor              = new[] { PeriodHelper.Parse(indexTenor) };
            fra.fraDiscounting          = fraDiscounting;
            fra.fraDiscountingSpecified = true;
            PartyReference party1 = PartyReferenceFactory.Create("party1");
            PartyReference party2 = PartyReferenceFactory.Create("party2");

            fra.sellerPartyReference = party2;
            fra.buyerPartyReference  = party1;
            XsdClassesFieldResolver.TradeSetFra(trade, fra);
            trade.id = tradeId;
            return(trade);
        }
        public static Swaption GenerateSwaptionDefiniton(SwapLegParametersRange_Old leg1Parameters,
                                                         IBusinessCalendar leg1PaymentCalendar,
                                                         SwapLegParametersRange_Old leg2Parameters,
                                                         IBusinessCalendar leg2PaymentCalendar,
                                                         SwaptionParametersRange swaptionParameters)
        {
            Swap                     swap           = SwapGenerator.GenerateDefiniton(leg1Parameters, leg2Parameters);
            NonNegativeMoney         premium        = MoneyHelper.GetNonNegativeAmount(swaptionParameters.Premium, swaptionParameters.PremiumCurrency);
            AdjustableDate           expirationDate = DateTypesHelper.ToAdjustableDate(swaptionParameters.ExpirationDate, swaptionParameters.ExpirationDateBusinessDayAdjustments, swaptionParameters.ExpirationDateCalendar);
            AdjustableOrAdjustedDate paymentDate    = DateTypesHelper.ToAdjustableOrAdjustedDate(swaptionParameters.PaymentDate, swaptionParameters.PaymentDateBusinessDayAdjustments, swaptionParameters.PaymentDateCalendar);
            TimeSpan                 earliestExerciseTimeAsTimeSpan = TimeSpan.FromDays(swaptionParameters.EarliestExerciseTime);
            DateTime                 earliestExerciseTime           = DateTime.MinValue.Add(earliestExerciseTimeAsTimeSpan);
            TimeSpan                 expirationTimeAsTimeSpan       = TimeSpan.FromDays(swaptionParameters.ExpirationTime);
            DateTime                 expirationTime = DateTime.MinValue.Add(expirationTimeAsTimeSpan);

            return(SwaptionFactory.Create(swap, premium,
                                          swaptionParameters.PremiumPayer, swaptionParameters.PremiumReceiver,
                                          paymentDate, expirationDate,
                                          earliestExerciseTime, expirationTime, swaptionParameters.AutomaticExcercise));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="nameSpace"></param>
        /// <param name="baseDateForRelativeOffset"></param>
        /// <param name="baseParty"></param>
        /// <param name="optionPremia"></param>
        /// <param name="fixingCalendar"></param>
        /// <param name="paymentCalendar"> </param>
        /// <param name="cache"></param>
        /// <returns></returns>
        public static PriceableFxOptionPremium CreatePriceableFxOptionPremium(ICoreCache cache, String nameSpace,
                                                                              DateTime?baseDateForRelativeOffset, string baseParty, FxOptionPremium optionPremia,
                                                                              IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar)
        {
            bool payerIsBase    = baseParty == optionPremia.payerPartyReference.href;
            var  multiplier     = payerIsBase ? -1.0m : 1.0m;
            var  settlementDate = AdjustedDateHelper.GetAdjustedDate(cache, nameSpace, fixingCalendar, baseDateForRelativeOffset, optionPremia.paymentDate);

            if (settlementDate == null)
            {
                return(null);
            }
            var date = new PriceableFxOptionPremium("FxOptionPremiumPayment", optionPremia.payerPartyReference.href,
                                                    optionPremia.receiverPartyReference.href, payerIsBase,
                                                    MoneyHelper.Mul(optionPremia.paymentAmount, multiplier),
                                                    (DateTime)settlementDate, optionPremia.quote,
                                                    optionPremia.settlementInformation, paymentCalendar);

            return(date);
        }
Exemple #22
0
        /// <summary>
        /// Inserting coints to the machine. Saving them in order buffer
        /// </summary>
        /// <param name="amount">Amount of coins inserted</param>
        /// <returns></returns>
        public Money InsertCoin(Money amount)
        {
            if (!MoneyHelper.ValidateInsertedCoin(amount))
            {
                throw new ArgumentException("Coin not supported");
            }
            var _backedBuffer = _moneyHolder.GetBufferedAmount();

            try
            {
                _moneyHolder.AddBufferedAmount(amount);
                return(_moneyHolder.GetBufferedAmount());
            }
            catch (Exception ex)
            {
                // in case of calculation failed revert buffer to previous state
                // and throw exception
                _moneyHolder.SetBuffedAmount(_backedBuffer);
                throw ex;
            }
        }
Exemple #23
0
        public (double, double) GetRate()
        {
            double rate = 0, balance = 0;

            this.current = httpRequest.Get(BASE_URL + PAIR);
            string html   = this.current.ToString();
            Parser parser = new Parser(html);

            rate = MoneyHelper.ToDouble(parser.GetValueInput("sum1"));
            string draftBalance = parser.GetContent("span_get_max")
                                  .ToLower()
                                  .Replace("max.", "")
                                  .Replace("max", "")
                                  .Replace(":", "")
                                  .Replace("btc", "")
                                  .Trim();

            balance = MoneyHelper.ToDouble(draftBalance);

            return(rate, balance);
        }
        /// <summary>
        /// Builds a bullet payment.
        /// </summary>
        /// <param name="productType"></param>
        /// <param name="payerIsBaseParty"></param>
        /// <param name="paymentDate"></param>
        /// <param name="businessDayCalendar"></param>
        /// <param name="businessDayAdjustments"> </param>
        /// <param name="currency"></param>
        /// <param name="amount"></param>
        /// <returns></returns>
        public static BulletPayment Parse(string productType, Boolean payerIsBaseParty,
                                          DateTime paymentDate, string businessDayCalendar,
                                          string businessDayAdjustments, string currency, decimal amount)
        {
            var px = new BulletPayment
            {
                payment =
                    new Payment
                {
                    paymentAmount =
                        MoneyHelper.GetNonNegativeAmount(amount, currency)
                },
                Items            = new object[] { ProductTypeHelper.Create("BulletPayment") },
                ItemsElementName = new[] { ItemsChoiceType2.productType }
            };
            var tempDate = DateTypesHelper.ToAdjustableDate(paymentDate, businessDayAdjustments,
                                                            businessDayCalendar);

            px.payment.paymentDate = AdjustableOrAdjustedDateHelper.Create(tempDate.unadjustedDate.Value, null, tempDate.dateAdjustments);//TODO
            //Setting the items array which contains product type and product is information.
            //payment type information
            px.payment.paymentType = PaymentTypeHelper.Create("Payment");
            //Set the party information
            px.payment.payerPartyReference = new PartyReference {
                href = "Party2"
            };
            px.payment.receiverPartyReference = new PartyReference {
                href = "Party1"
            };
            if (payerIsBaseParty)
            {
                px.payment.payerPartyReference = new PartyReference {
                    href = "Party1"
                };
                px.payment.receiverPartyReference = new PartyReference {
                    href = "Party2"
                };
            }
            return(px);
        }
        /// <summary>
        /// Builds a term deposit.
        /// </summary>
        /// <param name="productType"></param>
        /// <param name="tradeDate"></param>
        /// <param name="startDate"></param>
        /// <param name="maturityDate"></param>
        /// <param name="currency"></param>
        /// <param name="notionalAmount"></param>
        /// <param name="fixedRate"></param>
        /// <param name="dayCount"></param>
        /// <returns></returns>
        public static TermDeposit Parse(string productType, DateTime tradeDate, DateTime startDate,
                                        DateTime maturityDate, string currency, decimal notionalAmount, decimal fixedRate, string dayCount)
        {
            var termDeposit = new TermDeposit
            {
                dayCountFraction       = DayCountFractionHelper.Parse(dayCount),
                fixedRate              = fixedRate,
                fixedRateSpecified     = true,
                principal              = MoneyHelper.GetPositiveMoney(notionalAmount, currency),
                startDate              = startDate,
                startDateSpecified     = true,
                maturityDate           = maturityDate,
                maturityDateSpecified  = true,
                payerPartyReference    = PartyReferenceHelper.Parse("Party1"),
                receiverPartyReference = PartyReferenceHelper.Parse("Party2"),
                Items            = new object[] { ProductTypeHelper.Create(ProductTypeSimpleEnum.TermDeposit.ToString()) },
                ItemsElementName = new[] { ItemsChoiceType2.productType }
            };

            //Set the party information
            return(termDeposit);
        }
Exemple #26
0
        public static Trade CreateSwaptionTrade(SwaptionParametersRange swaptionParametersRange, IBusinessCalendar paymentCalendar, Swap underlyingSwap)
        {
            var                      premium        = MoneyHelper.GetNonNegativeAmount(swaptionParametersRange.Premium, swaptionParametersRange.PremiumCurrency);
            AdjustableDate           expirationDate = DateTypesHelper.ToAdjustableDate(swaptionParametersRange.ExpirationDate, swaptionParametersRange.ExpirationDateBusinessDayAdjustments, swaptionParametersRange.ExpirationDateCalendar);
            AdjustableOrAdjustedDate paymentDate    = DateTypesHelper.ToAdjustableOrAdjustedDate(swaptionParametersRange.PaymentDate, swaptionParametersRange.PaymentDateBusinessDayAdjustments, swaptionParametersRange.PaymentDateCalendar);
            TimeSpan                 earliestExerciseTimeAsTimeSpan = TimeSpan.FromDays(swaptionParametersRange.EarliestExerciseTime);
            DateTime                 earliestExerciseTime           = DateTime.MinValue.Add(earliestExerciseTimeAsTimeSpan);
            TimeSpan                 expirationTimeAsTimeSpan       = TimeSpan.FromDays(swaptionParametersRange.ExpirationTime);
            DateTime                 expirationTime = DateTime.MinValue.Add(expirationTimeAsTimeSpan);
            var                      swaption       = SwaptionFactory.Create(underlyingSwap, premium, swaptionParametersRange.PremiumPayer, swaptionParametersRange.PremiumReceiver,
                                                                             paymentDate, expirationDate,
                                                                             earliestExerciseTime, expirationTime, swaptionParametersRange.AutomaticExcercise);

            swaption.Items = new object[] { new ProductType {
                                                Value = ProductTypeSimpleEnum.InterestRateSwaption.ToString()
                                            } };
            swaption.ItemsElementName = new[] { ItemsChoiceType2.productType };
            var trade = new Trade();

            XsdClassesFieldResolver.TradeSetSwaption(trade, swaption);
            return(trade);
        }
Exemple #27
0
    internal void OnXocDia_DatCuoc(Message message)
    {
        string nick     = message.reader().ReadUTF();
        sbyte  cua      = message.reader().ReadByte();
        long   money    = message.reader().ReadLong();
        int    typeCHIP = message.reader().ReadByte();

        XocDiaPlayer pl = (XocDiaPlayer)GetPlayerWithName(nick);

        if (pl != null)
        {
            //			pl.ActionChipDatCuoc (cua, btn_cua_cuoc [cua].transform.position, obj_pre_chip);
            pl.ActionChipDatCuoc(cua, GenPostionRandomInCua(cua), obj_pre_chip, money);
        }
        sum_money[cua]         += money;
        txt_sum_money[cua].text = MoneyHelper.FormatMoneyNormal(sum_money[cua]);
        if (nick.Equals(ClientConfig.UserInfo.UNAME))
        {
            sum_me_money[cua]     += money;
            txt_me_money[cua].text = MoneyHelper.FormatMoneyNormal(sum_me_money[cua]);
        }
    }
Exemple #28
0
    internal override void OnFinishGame(Message message)
    {
        try {
            //			dangchoi = false;
            int cua1 = message.reader().ReadByte();
            int cua2 = message.reader().ReadByte();
            int size = message.reader().ReadByte();
            for (int i = 0; i < size; i++)
            {
                string       _name     = message.reader().ReadUTF();
                long         moneyEarn = message.reader().ReadLong();
                XocDiaPlayer pl        = (XocDiaPlayer)GetPlayerWithName(_name);
                if (pl != null)
                {
                    if (moneyEarn > 0)
                    {
                        pl.SetRank(1);
                    }
                    else                        //thua
                    {
                        pl.SetRank(6);
                    }
                    pl.SetEffect((moneyEarn > 0 ? "+" : "") + MoneyHelper.FormatMoneyNormal(moneyEarn));
                    pl.IsReady = false;
                }
            }
            Debug.LogError("Cua 1: " + cua1 + "  Cua 2: " + cua2);
            win_effect[cua1].SetActive(true);
            if (cua2 > 1 && cua2 < 6)
            {
                win_effect[cua2].SetActive(true);
            }

            StartCoroutine(MoveMoneyFinishGame(cua1, cua2));
        } catch (Exception e) {
            Debug.LogException(e);
        }
    }
    public void SetMoneyWin(long moneuWin)
    {
        if (moneuWin == 0)
        {
            txt_money_win.gameObject.SetActive(false);
            return;
        }
        txt_money_win.gameObject.SetActive(true);
        string strTemp = "";

        if (moneuWin > 0)
        {
            txt_money_win.color = Color.yellow;
            strTemp             = "+" + MoneyHelper.FormatMoneyNormal(moneuWin);
        }
        else
        {
            txt_money_win.color = Color.red;
            strTemp             = MoneyHelper.FormatMoneyNormal(moneuWin);
        }

        txt_money_win.text = strTemp;
    }
Exemple #30
0
 public ActionResult Login(LoginViewModel model, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (!CurrentUser.Login(model.Email, model.Password, model.RememberMe))
             {
                 ModelState.AddModelError("", Resource.InvalidEmailOrPassword);
             }
             else
             {
                 MoneyHelper.SetDefaultCurrency();
                 return(RedirectToLocal(returnUrl));
             }
         }
         catch (ConcurrentLoginLimitException ex)
         {
             ModelState.AddModelError("", "Your account is currently logged in somewhere else. Please try again later!");
         }
     }
     return(View(model));
 }