Esempio n. 1
0
 public Rate SetToConvention(RateConvention desiredRateConvention)
 {
     if (desiredRateConvention != RateConvention)
     {
         return(Inverted());
     }
     return(this);
 }
Esempio n. 2
0
 public Rate(Currency unitCurrency,
             Currency refCurrency,
             decimal unmultipliedUnroundedRateValue,
             RateMetaData metaData,
             RateConvention rateConvention)
 {
     UnitCurrency = unitCurrency;
     RefCurrency  = refCurrency;
     MetaData     = metaData;
     this.unmultipliedUnroundedRateValue = unmultipliedUnroundedRateValue;
     RateConvention = rateConvention;
 }
Esempio n. 3
0
        public Rate(Currency unitCurrency,
                    Currency refCurrency,
                    decimal unmultipliedUnroundedRateValue,
                    int multiplierDirect,
                    int multiplierIndirect,
                    int numDecimalsDirectMultiplied,
                    int numDecimalsIndirectMultiplied,
                    RateConvention rateConvention)
        {
            Debug.Assert(rateConvention != RateConvention.Default, "Ambigious rate convention, should be set to direct or indirect");

            UnitCurrency = unitCurrency;
            RefCurrency  = refCurrency;
            this.unmultipliedUnroundedRateValue = unmultipliedUnroundedRateValue;
            MetaData       = new RateMetaData(numDecimalsDirectMultiplied, numDecimalsIndirectMultiplied, multiplierDirect, multiplierIndirect);
            RateConvention = rateConvention;
        }
Esempio n. 4
0
        public Rate SetToConventionAndRoundInTradersFavor(RateConvention newRateConvention, TradeDirection tradeDirection)
        {
            if (newRateConvention != RateConvention)
            {
                this = Inverted();
            }

            Rate computedRate;

            if ((tradeDirection == TradeDirection.Sell && IsDirect()) || (tradeDirection == TradeDirection.Buy && !IsDirect()))
            {
                computedRate = NewValue(RoundUp(unmultipliedUnroundedRateValue, NumberOfDecimalsUnmultiplied));
            }
            else
            {
                computedRate = NewValue(RoundDown(unmultipliedUnroundedRateValue, NumberOfDecimalsUnmultiplied));
            }

            return(computedRate);
        }
Esempio n. 5
0
        public static Rate CreateRate(Currency unitCurrency,
                                      Currency refCurrency,
                                      decimal rateValue,
                                      bool rateValueIsMultiplied,
                                      RateMetaData metaData,
                                      RateConvention rateConvention)
        {
            var rateValueUnmultiplied = rateValue;
            var rateMultiplier        = rateConvention == RateConvention.Direct
                ? metaData.MultiplierDirect
                : metaData.MultiplierIndirect;

            if (rateValueIsMultiplied)
            {
                rateValueUnmultiplied = rateValue / rateMultiplier;
            }

            if (rateConvention == RateConvention.Indirect)
            {
                return(new Rate(refCurrency, unitCurrency, rateValueUnmultiplied, metaData, rateConvention));
            }
            return(new Rate(unitCurrency, refCurrency, rateValueUnmultiplied, metaData, rateConvention));
        }
Esempio n. 6
0
 private static decimal CalculateForwardPoints(decimal forwardPoints, RateConvention rateConventionSpotRate, RateConvention rateConventionForwardPoints, LineItemQuote lineItem)
 {
     return(rateConventionForwardPoints != rateConventionSpotRate
         ? lineItem.SpotRate.NewValue(1 / lineItem.ClientRate - 1 / (lineItem.ClientRate - forwardPoints)).RoundedValue
         : forwardPoints);
 }
Esempio n. 7
0
 private static Rate CreateRateFromUnmultipliedValue(RateConvention rateConvention, decimal value, Currency baseCurrency, Currency currency, int rateMultiplier, int numDecDirect, int numDecIndirect)
 {
     return(Rate.CreateRate(currency, baseCurrency, value, false, new RateMetaData(numDecDirect, numDecIndirect, rateMultiplier, rateMultiplier), rateConvention));
 }