Skip to content

Instantly share code, notes, and snippets.

@OpenGamma-Blog
Last active December 13, 2015 16:58
Show Gist options
  • Save OpenGamma-Blog/4943722 to your computer and use it in GitHub Desktop.
Save OpenGamma-Blog/4943722 to your computer and use it in GitHub Desktop.
MATLAB and OpenGamma 3
package com.opengamma.externalanalytics.test;
import java.net.URL;
import com.mathworks.mps.client.MWClient;
import com.mathworks.mps.client.MWHttpClient;
import com.opengamma.externalanalytics.matlab.CustomMatlabModel;
public class StandAloneRunner {
public static void main(String[] args) {
MWClient client = new MWHttpClient();
try {
CustomMatlabModel m = client.createProxy(new URL(
"http://localhost:9910/OpenGamma_MATLAB_Analytics"),
CustomMatlabModel.class);
boolean isCall = true;
double Price = 100;
double Strike = 100;
double Rate = 2.0 / 100.0;
double Time = 30.0 / 365.0;
double Volatility = 7.0 / 100.0;
double Yield = 1.0 / 100.0;
double price = m.MatlabBlackScholes(isCall, Price, Strike, Rate,
Time, Volatility, Yield);
System.out.println("Price: " + price);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
client.close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment