# Configuration (/configuration)



Market Lab reads non-secret settings from TOML. Keep credentials in the [credential store](/authentication), not in configuration files.

## File Discovery [#file-discovery]

Pass a file explicitly:

```bash
mlab script backtest --config ./marketlab.toml
```

Without `--config`, Market Lab uses `./marketlab.toml` when it exists. It does not search parent directories.

Supported commands:

* `script run`
* `script backtest`
* `trade long`
* `trade short`

## Precedence [#precedence]

```text
built-in defaults < marketlab.toml < CLI flags
```

CLI values override the file for the current command.

## Python V2 script configuration [#python-v2-script-configuration]

```toml
version = 1

[script]
path = "./strategy.py"
python = ".venv/bin/python"
duration = 3600

[script.params]
fast = 5
slow = 30
margin = 100

[backtest]
from = "2026-07-15"
to = "2026-07-16"

[output]
format = "terminal"
```

Python V2 declares its sources directly in `history.source(...)` calls. Do not add `[sources]` or `script.sources`.

Script paths and Python paths in TOML are resolved relative to the TOML file.

For `script run`, `duration` limits the live job in seconds. Omit it to run until stopped. Backtests use `[backtest].from` and `[backtest].to` instead.

Backtest boundaries are UTC strings in `YYYY-MM-DD` or `YYYY-MM-DD HH:MM:SS` format. A date without a time means midnight.

Python V2 must not set `[execution].venue`. Each `ctx.trade(...)` or `ctx.order(...)` request declares its own `exchange` and `symbol`.

## JavaScript V1 script configuration [#javascript-v1-script-configuration]

JavaScript V1 keeps explicit source tables:

```toml
[sources."btc@candles@binancef"]
timeframe = 60

[sources."btc@orderbook@hyperliquidf"]
depth = 20
```

These are equivalent to repeated V1 `--source` flags.

### Execution [#execution]

JavaScript V1 enables one execution venue through configuration:

```toml
[execution]
venue = "hyperliquidf"
```

Omit `[execution]` for an analysis-only JavaScript job.

## Trade Configuration [#trade-configuration]

Perpetual example:

```toml
version = 1

[market]
symbol = "BTC"

[execution]
venue = "hyperliquidf"
margin = 100
leverage = 5
order_type = "market"
dry_run = true

[output]
format = "terminal"
```

```bash
mlab trade long --config ./marketlab.toml
```

Use exactly one of `size` or `margin`.

Limit order fields:

```toml
[execution]
venue = "hyperliquidf"
size = 0.001
order_type = "limit"
price = 65000
tif = "alo"
leverage = 3
dry_run = true
```

Spot keeps the exact pair and omits perpetual-only fields:

```toml
[market]
symbol = "HYPE/USDC"

[execution]
venue = "hyperliquid"
margin = 100
order_type = "market"
dry_run = true
```

Never add API keys, wallet keys, or agent credentials to `marketlab.toml`.
