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

net.finmath.smartcontract.valuation.implementation.reactive.ConditionalSettlementCalculator Maven / Gradle / Ivy

There is a newer version: 1.0.6
Show newest version
package net.finmath.smartcontract.valuation.implementation.reactive;

import net.finmath.smartcontract.model.ValueResult;
import net.finmath.smartcontract.valuation.implementation.MarginCalculator;
import net.finmath.smartcontract.valuation.marketdata.curvecalibration.CalibrationDataset;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.function.Function;

//TODO check if needed, not used
public class ConditionalSettlementCalculator implements Function, Serializable {

	private final BigDecimal resultTriggerValue;
	private final String sdcXML;
	private String previousmarketdata = null;
	private final MarginCalculator calculator = new MarginCalculator();

	public ConditionalSettlementCalculator(String sdcXML, BigDecimal resultTriggerValue) {
		previousmarketdata = null;
		this.sdcXML = sdcXML;
		this.resultTriggerValue = resultTriggerValue;
	}

	@Override
	public ValueResult apply(CalibrationDataset actualmarketdata) {
		ValueResult defaultResult = new ValueResult();
		defaultResult.setValue(null);
		ValueResult finalResult = defaultResult;
		String marketDataAsJson = actualmarketdata.serializeToJson();
		try {
			if (previousmarketdata != null) {
				ValueResult marginResult = calculator.getValue(marketDataAsJson, sdcXML);
				previousmarketdata = marketDataAsJson;
				finalResult = marginResult;
			} else
				previousmarketdata = marketDataAsJson;

		} catch (Exception e) {
			System.out.println(e);
		}

		return finalResult;
	}
}







© 2015 - 2025 Weber Informatics LLC | Privacy Policy