cdm.margin.schedule.functions.StandardizedScheduleEquityForwardNotionalAmount Maven / Gradle / Ivy
package cdm.margin.schedule.functions;
import cdm.base.math.Measure;
import cdm.base.math.NonNegativeQuantitySchedule;
import cdm.base.math.metafields.ReferenceWithMetaNonNegativeQuantitySchedule;
import cdm.observable.asset.PriceSchedule;
import cdm.observable.asset.metafields.ReferenceWithMetaPriceSchedule;
import cdm.product.common.settlement.ResolvablePriceQuantity;
import cdm.product.template.SettlementPayout;
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;
import static com.rosetta.model.lib.expression.ExpressionOperators.*;
@ImplementedBy(StandardizedScheduleEquityForwardNotionalAmount.StandardizedScheduleEquityForwardNotionalAmountDefault.class)
public abstract class StandardizedScheduleEquityForwardNotionalAmount implements RosettaFunction {
/**
* @param settlementPayout
* @return amount
*/
public BigDecimal evaluate(SettlementPayout settlementPayout) {
BigDecimal amount = doEvaluate(settlementPayout);
return amount;
}
protected abstract BigDecimal doEvaluate(SettlementPayout settlementPayout);
protected abstract MapperS forwardPrice(SettlementPayout settlementPayout);
protected abstract MapperS notionalQuantity(SettlementPayout settlementPayout);
public static class StandardizedScheduleEquityForwardNotionalAmountDefault extends StandardizedScheduleEquityForwardNotionalAmount {
@Override
protected BigDecimal doEvaluate(SettlementPayout settlementPayout) {
BigDecimal amount = null;
return assignOutput(amount, settlementPayout);
}
protected BigDecimal assignOutput(BigDecimal amount, SettlementPayout settlementPayout) {
amount = MapperMaths.multiply(forwardPrice(settlementPayout), notionalQuantity(settlementPayout)).get();
return amount;
}
@Override
protected MapperS forwardPrice(SettlementPayout settlementPayout) {
return MapperS.of(MapperS.of(settlementPayout).map("getPriceQuantity", _settlementPayout -> _settlementPayout.getPriceQuantity()).mapC("getPriceSchedule", resolvablePriceQuantity -> resolvablePriceQuantity.getPriceSchedule()).map("getValue", _f->_f.getValue()).get()).map("getValue", priceSchedule -> priceSchedule.getValue());
}
@Override
protected MapperS notionalQuantity(SettlementPayout settlementPayout) {
final MapperS thenResult = MapperS.of(settlementPayout).map("getPriceQuantity", _settlementPayout -> _settlementPayout.getPriceQuantity()).map("getQuantitySchedule", resolvablePriceQuantity -> resolvablePriceQuantity.getQuantitySchedule()).map("getValue", _f->_f.getValue());
final MapperS ifThenElseResult;
if (exists(thenResult.map("getMultiplier", nonNegativeQuantitySchedule -> nonNegativeQuantitySchedule.getMultiplier())).getOrDefault(false)) {
ifThenElseResult = MapperMaths.multiply(thenResult.map("getValue", nonNegativeQuantitySchedule -> nonNegativeQuantitySchedule.getValue()), thenResult.map("getMultiplier", nonNegativeQuantitySchedule -> nonNegativeQuantitySchedule.getMultiplier()).map("getValue", measure -> measure.getValue()));
} else {
ifThenElseResult = thenResult.map("getValue", nonNegativeQuantitySchedule -> nonNegativeQuantitySchedule.getValue());
}
return ifThenElseResult;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy