All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cdm.margin.schedule.functions.StandardizedScheduleFXVarianceNotionalAmount Maven / Gradle / Ivy

There is a newer version: 6.0.0-dev.89
Show newest version
package cdm.margin.schedule.functions;

import cdm.base.math.NonNegativeQuantitySchedule;
import cdm.observable.asset.Price;
import cdm.product.asset.VarianceReturnTerms;
import cdm.product.template.PerformancePayout;
import cdm.product.template.ReturnTerms;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.expression.MapperMaths;
import com.rosetta.model.lib.functions.RosettaFunction;
import com.rosetta.model.lib.mapper.MapperS;
import java.math.BigDecimal;


@ImplementedBy(StandardizedScheduleFXVarianceNotionalAmount.StandardizedScheduleFXVarianceNotionalAmountDefault.class)
public abstract class StandardizedScheduleFXVarianceNotionalAmount implements RosettaFunction {

	/**
	* @param performancePayout 
	* @return amount 
	*/
	public BigDecimal evaluate(PerformancePayout performancePayout) {
		BigDecimal amount = doEvaluate(performancePayout);
		
		return amount;
	}

	protected abstract BigDecimal doEvaluate(PerformancePayout performancePayout);

	protected abstract MapperS varianceReturnTerms(PerformancePayout performancePayout);

	protected abstract MapperS vegaNotionalAmount(PerformancePayout performancePayout);

	protected abstract MapperS fixedRate(PerformancePayout performancePayout);

	public static class StandardizedScheduleFXVarianceNotionalAmountDefault extends StandardizedScheduleFXVarianceNotionalAmount {
		@Override
		protected BigDecimal doEvaluate(PerformancePayout performancePayout) {
			BigDecimal amount = null;
			return assignOutput(amount, performancePayout);
		}
		
		protected BigDecimal assignOutput(BigDecimal amount, PerformancePayout performancePayout) {
			amount = MapperMaths.divide(vegaNotionalAmount(performancePayout).map("getValue", nonNegativeQuantitySchedule -> nonNegativeQuantitySchedule.getValue()), MapperMaths.multiply(MapperS.of(new BigDecimal("0.02")), fixedRate(performancePayout).map("getValue", price -> price.getValue()))).get();
			
			return amount;
		}
		
		@Override
		protected MapperS varianceReturnTerms(PerformancePayout performancePayout) {
			return MapperS.of(performancePayout).map("getReturnTerms", _performancePayout -> _performancePayout.getReturnTerms()).map("getVarianceReturnTerms", returnTerms -> returnTerms.getVarianceReturnTerms());
		}
		
		@Override
		protected MapperS vegaNotionalAmount(PerformancePayout performancePayout) {
			return varianceReturnTerms(performancePayout).map("getVegaNotionalAmount", _varianceReturnTerms -> _varianceReturnTerms.getVegaNotionalAmount());
		}
		
		@Override
		protected MapperS fixedRate(PerformancePayout performancePayout) {
			return varianceReturnTerms(performancePayout).map("getVarianceStrikePrice", _varianceReturnTerms -> _varianceReturnTerms.getVarianceStrikePrice());
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy