Skip to main content

Getting Started

The MesoLive Python SDK (mesolive-sdk, import package: mesolive_sdk) provides an async Python-first interface for options trade automation. Under the hood it talks to the MesoLive SignalR hubs:

  • Control Hub (/hubs/control/v1): agents, accounts, strategies, positions, orders, and prepare/execute flows
  • Data Hub (/hubs/data/v1): snapshots + server-streaming market/portfolio data
  • Event Hub (/hubs/event/v1): real-time server→client callbacks + event history/replay

MesoLive Python SDK comes with a set of runnable examples available in the mesolive-sdk-examples package, covering common use cases for each hub and end-to-end trade flows. Please note, that this is not an exhaustive set of examples, but rather a starting point to help you get familiar with the SDK and its capabilities.

Prerequisites

You need:

  • MesoLive instance URL, e.g. https://portal.MYCOMPANY.mesolive.io
  • MesoLive API key (JWT bearer token): create one in the MesoLive Portal (see Accessing the APIs). This key is separate from the MesoSim API key.

AI Assisted Development

If you are planning to use AI tools like OpenAI Codex, Claude Code or Google Gemini, make sure to download the latest version of the Python SDK, examples and API docs to your local machine, and point your AI tool to the local files instead of the online docs.

You can find the packages in the Software Releases section (link in the Nav Menu).

Install

Install the SDK, Examples and API Docs from Software Releases, then install the runnable examples package:

python -m pip install ./mesolive_sdk-<version>-py3-none-any.whl
python -m pip install ./mesolive_sdk_examples-<version>.tar.gz

Verify:

python -c "import importlib.metadata as m; print(m.version('mesolive-sdk'))"
python -c "import importlib.metadata as m; print(m.version('mesolive-sdk-examples'))"
python -c "import mesolive_sdk; print('mesolive_sdk import OK')"

Configure

The examples below read configuration from environment variables:

export MESOLIVE_INSTANCE="https://portal.MYCOMPANY.mesolive.io"
export MESOLIVE_API_KEY="..."

Run the examples

All examples support --help and read configuration from MESOLIVE_INSTANCE / MESOLIVE_API_KEY.

Control Hub: strategies

python -m mesolive_sdk_examples.strategies_example --help
python -m mesolive_sdk_examples.strategies_example list --limit 50
python -m mesolive_sdk_examples.strategies_example get --strategy-id 123

Control Hub: agents

python -m mesolive_sdk_examples.agents_example --help
python -m mesolive_sdk_examples.agents_example list

Control Hub: accounts

python -m mesolive_sdk_examples.accounts_example --help
python -m mesolive_sdk_examples.accounts_example list --limit 50
python -m mesolive_sdk_examples.accounts_example get --account ML1234

Control Hub: positions

python -m mesolive_sdk_examples.positions_example --help
python -m mesolive_sdk_examples.positions_example list --account ML1234 --limit 50
python -m mesolive_sdk_examples.positions_example create --strategy-id 123
python -m mesolive_sdk_examples.positions_example create --strategy-id 123 --execute --paper-fill-price mid
python -m mesolive_sdk_examples.positions_example exit --position-id 789 --execute --paper-fill-price mid
python -m mesolive_sdk_examples.positions_example adjust --position-id 789 --operation UpdateVars --condition "my-adjustment-condition"

Data Hub: position market data

python -m mesolive_sdk_examples.data_example --help
python -m mesolive_sdk_examples.data_example position snapshot --position-id 789
python -m mesolive_sdk_examples.data_example position stream --position-id 789 --seconds 30

Event Hub: listen for server events

python -m mesolive_sdk_examples.events_example --help
python -m mesolive_sdk_examples.events_example dump --seconds 30

End-to-end trade flow

python -m mesolive_sdk_examples.trade_e2e_example --help
python -m mesolive_sdk_examples.trade_e2e_example --strategy-id 123

Next steps