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

net.finmath.smartcontract.oracle.ValuationOracleSamplePath Maven / Gradle / Ivy

/*
 * (c) Copyright Christian P. Fries, Germany. Contact: [email protected].
 *
 * Created on 6 Oct 2018
 */

package net.finmath.smartcontract.oracle;

import java.time.LocalDateTime;

import javax.money.CurrencyUnit;
import javax.money.Monetary;
import javax.money.MonetaryAmount;

import org.javamoney.moneta.Money;

/**
 * A valuation oracle constructed from a simulation providing a stochastic valuation oracle
 * by extracting a given sample path.
 *
 * @author Christian Fries
 */
public class ValuationOracleSamplePath implements ValuationOracle {

	private final CurrencyUnit currency = Monetary.getCurrency("EUR");
	private final StochasticValuationOracle stochasticValuationOracle;
	private final int path;

	/**
	 * Create a valuation oracle from a simulation providing a stochastic valuation oracle
	 * by extracting a given sample path.
	 *
	 * @param stochasticValuationOracle A given stochastic oracle.
	 * @param path The sample path to extract from the stochastic oracle.
	 */
	public ValuationOracleSamplePath(final StochasticValuationOracle stochasticValuationOracle, final int path) {
		this.stochasticValuationOracle = stochasticValuationOracle;
		this.path = path;
	}

	@Override
	public Double getValue(final LocalDateTime evaluationTime, final LocalDateTime marketDataTime) {
		return stochasticValuationOracle.getValue(evaluationTime).get(path);
	}

	@Override
	public MonetaryAmount getAmount(final LocalDateTime evaluationTime, final LocalDateTime marketDataTime) {
		return Money.of(getValue(evaluationTime, marketDataTime), currency);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy