Last updated on 16th July 2024
One of the main modes of working with your simulation is via the REST API. The built-in console makes usage of this same API in order to show the basic UI with ability to view data and control the simulation. As long as you have registered a model with the server in your Main class you are able to run the server locally and from your own customized dashboard or via command line run actions and retrieve outputs from the simulation.
Details on the format and structure of this REST API can be found here
Below is a quick example using the REST API with the command line in this case running the Model Sampler on a Windows machine. To start since we are not working with an existing API let's create a sample calibration file in the JSON format to make it easier when calling on the machine.
{
"modelName": "High Frequency Model",
"outputPath":"/tmp/calibration",
"mcCount":2,
"modelSampler": {
"dimensions": {
"price":[560.00, 600.00]
},
"seeds":[156415615,15184849,66261846,18749891,98798416],
"nbSamples":5,
"nbTicks":108000
}
}
This sets out output, the model we wish to run, some inputs and seed values, and how many ticks and sample runs we want. To run this we simply need to make usage of Curl alongside our regular Maven command.
mvn clean compile exec:java -s settings.xml
... (wait until completed and server says it's online)
curl -X POST http://localhost:8080/api/simulations/model-sampler -d @calibration.json -H "Content-Type: application/json" -H "Cache-Control: no-cache"
This will in turn run the simulation. As always please refer to the REST API docs for info on constructing your POST/GET statements both for running headless per above or in your existing/new dashboard.