Skip to main content

Getting Started

Go from zero to running simulations in under a minute! 🚀

Connect to the Platform & Get your API Key​

Login to the platform with a Web3 wallet. (you need to be whitelisted)

Multiverse Connect

Go to your User Profile (top right) and Generate API Key, copy/paste it somewhere safe where you can retrieve it. You will need it for the SDK authentication function.

Multiverse API Key
Save your Key

For security reasons, we do not store your keys, and they cannot be displayed again. Please ensure you save them securely when they are initially provided.

Install the Almanak SDK​

Install the Almanak SDK:

pip install almanak

Start a Simulation​

This part is taken from the Start Simulation Tutorial.

  1. Generate a new example project.
  2. Create & Upload a MC (Monte Carlo) configuration.
  3. Validate your MC config.
  4. Start the simulation!
from almanak import Almanak

# Instantiate your Almanak client.
client = Almanak(
api_key="<YOUR_API_KEY>",
)

# 1. Generate a boilertemplate for a simulation
client.simulations.monte_carlo.generate("MyNewSimulation")

# 2. Create a monte carlo simulation and get the upload link for config zip
data = client.simulations.monte_carlo.create_mc_upload_config(
"./MyNewSimulation/config"
)
print(data)

# 3. Validate the configuration before launching the simulation
validateResult = client.simulations.monte_carlo.validate_mc_config(
data["monte_carlo_id"]
)
print(validateResult)

# 4. Start the simulation!
startMCResult = client.simulations.monte_carlo.start(data["monte_carlo_id"])
print(startMCResult)

Get the Status and Results​

This part is taken from the Results Tutorial.

# The simulation ID is coming from when you created it
mc_id = "3f16d96d-c99f-4f7c-82b6-21131e12081c"

# 1. Get the status of monte carlo simulation
status = client.simulations.monte_carlo.get_status(mc_id)
print(status)

# 2. Download raw metrics of monte carlo simulation
metrics_data = client.simulations.monte_carlo.get_metrics(mc_id, "D:/multiverse/MyAwesomeSimulation/metrics")
print(metrics_data)

# 3. Export metrics, give the folder where the raw metrics files are stored
# and the folder where the results should be stored
# filter_by requirements. Order of priority is environment_step, agents, metrics_keys (in that order, can be None)
client.simulations.monte_carlo.metrics.to_folder(
"D:/multiverse/MyAwesomeSimulation/metrics",
"D:/multiverse/MyAwesomeSimulation/metrics-filtered",
{
"address": "0xFc1C34a9FEb232358E8F26289eE01253b059f304",
"environment_step": 99,
"metrics_keys": ["PNL_THIS_STEP"],
},
)

# 4. Create a DataFrame from the metrics of interest.
df = client.simulations.monte_carlo.metrics.to_dataframe(
"D:/multiverse/MyAwesomeSimulation/metrics",
"D:/multiverse/MyAwesomeSimulation/metrics-filtered",
filter_by={},
)

# DataFrame ready for analysis and visualization!

🎉 Congratulations! 🎉

You just ran your first simulation and gained clarity.

Multiverse Clarity