public Rate SetToConvention(RateConvention desiredRateConvention) { if (desiredRateConvention != RateConvention) { return(Inverted()); } return(this); }
public Rate(Currency unitCurrency, Currency refCurrency, decimal unmultipliedUnroundedRateValue, RateMetaData metaData, RateConvention rateConvention) { UnitCurrency = unitCurrency; RefCurrency = refCurrency; MetaData = metaData; this.unmultipliedUnroundedRateValue = unmultipliedUnroundedRateValue; RateConvention = rateConvention; }
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; }
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); }
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)); }
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); }
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)); }