Montecarlo
A montecarlo simulation in short is a multitude of single simulations using a specification of what is different between the different single simulations. This means you can create anywhere from 2 to hundreds of simulations that run at the same time using a set of parameters of configuration changes.
Usually running the exact same simulation twice doesn't give a lot of difference in the results, and that's not what the montecarlo simulation is meant for. But it can do that too. It's super flexible and allows you to specify exactly what is different between each simulation.
Running a Montecarlo
To run a montecarlo we require Run Specifications for each simulator run you
would like the montecarlo to execute. This run specification is a JSON object
that specifies what values of the configuration have to be updated. So you can
for example change the block
value for every run.
Maybe most importantly you can change the prices
value between each
simulation. This gives a lot of flexibility for running multiple simulations at
the same time.
The Run Specifications can be provided in 2 ways, via a JSON string as a
parameter for the CLi and SDK. Or as a file run_specification.json
.
The run_specification.json
file has to be present in the same folder as the
configuration.yaml.dist
when running a montecarlo simulation. They will be
uploaded at the same time.
An example of Run Specifications looks like this:
[
{
"block": 16800000,
"steps": 100,
"prices": "price-id://v1-0002b13b82632224cce1e10c44553a7a385f07d5d77f9fe9fa56c5b0e0e1259e"
},
{
"block": 16801000,
"steps": 100,
"prices": "gs://almanak-simulations/prices_example.json"
},
{
"block": 16810000,
"steps": 100,
"prices": [
{
"tokenPair": [
"ETH",
"USDT"
],
"historical": [
1297.85,
1297.84,
...
]
},
{
"tokenPair": [
"USDT",
"DAI"
],
"historical": [
1.0002,
1.0002,
...
]
},
{
"tokenPair": [
"BNT",
"USDT"
],
"historical": [
0.388,
0.388,
...
]
}
]
}
]
As you can see in the example there are multiple ways of passing in certain
values. As a general rule of thumb you can always pass in the value directly or
through a gs://
link. This will pull the information from a Google Cloud
Storage bucket as long as the simulator has access to it. (If not it will throw
an error)
For prices there is also the option to pass in the Price Simulation ID via
price-id://
which will pull the Price Simulation result from the correct
location and parse it to the correct storage format for the configuration.
Result
To get the result of the montecarlo you can use the CLI or SDK.
Metrics
To get the metrics of the montecarlo you can use the CLI or SDK.