Skip to main content
Version: v5

Dynamic Command Execution

CommandRunner runs a command by its route string, the same way the generated obb methods and the REST API do internally. It reads the installed routers directly, so it works without the generated package and without an HTTP server. Use it when the command is chosen at runtime, for example from a configuration file or a job queue.

from openbb_core.app.command_runner import CommandRunner

runner = CommandRunner()

CommandRunner() loads the installed extensions and the user and system settings from disk. Arguments for provider-backed commands are grouped the way the generated methods group them: provider_choices names the provider, standard_params holds fields from the model's standard parent, and extra_params holds provider-specific fields. openbb-famafrench models have no standard parent, so everything goes in extra_params:

output = await runner.run(
"/famafrench/factors",
provider_choices={"provider": "famafrench"},
standard_params={},
extra_params={"region": "europe", "factor": "5_factors"},
)
output.to_dataframe()

run is a coroutine. From synchronous code, call runner.sync_run(...) with the same arguments. Commands without a model take their parameters as keyword arguments instead:

output = runner.sync_run("/quantitative/stats/skew", params={"data": rows, "target": "close"})

Here params is the command's request-body model, passed as a dictionary, and rows is a list of records.

The runner skips the conveniences of the generated methods. It does not pick a provider when a model has several, does not apply per-command defaults from the user settings, does not join list inputs into comma-separated strings, and does not apply the output_type preference, so it always returns what the command returns, usually an OBBject. Route strings match the REST paths without the /api/v1 prefix. The keys of obb.reference["paths"] list every route in the built package.