Quantitative research inside the terminal
Python Lab gives you a full research environment connected directly to Dome Terminal's data pipeline. Fetch market data, run backtests, validate strategies, and export results to Dome Script — without leaving the terminal or setting up external tools.
Python Lab is a quantitative trading research environment. It is specifically designed for strategy research, indicator development, and statistical analysis using Dome Terminal's live and historical data. It is not a general-purpose Python coding environment — it won't run web scrapers or Discord bots.
What Python Lab is built for
Strategy research using real market data · Indicator calculations and statistical analysis · Backtest and walk-forward validation · Correlation and regime analysis · Exporting validated research to Dome Script for live or paper deployment
To open Python Lab: click Python Lab in the left sidebar, or press Alt+P. The lab opens in its own panel and can be floated to a second monitor. Your notebooks persist between sessions.
Create a notebook from the Python Lab home screen (click + New Notebook). Each notebook is an independent research workspace. Give it a descriptive name — you'll accumulate more of these than you expect.
2import dome as dt
3import pandas as pd
4import numpy as np
5
6# Verify the connection to terminal data
7status = dt.status()
8print(status)
9# → { "connected": true, "provider": "CME Live", "active_symbol": "ES" }
10
The import dome as dt line gives you access to the full data and backtest API. Run any cell with Shift+Enter. If dt.status() returns "connected": true, your notebook is live and ready.
The dt.data() function is your primary data access method. It fetches OHLCV data for any symbol available through your configured data providers and returns a standard pandas DataFrame.
2df = dt.data("BTC/USDT", "4h", 500)
3
4# Preview the DataFrame
5print(df.head())
6print(df.dtypes)
7
8# Available columns: timestamp, open, high, low, close, volume
9# Data is always sorted oldest → newest (ascending timestamp)
| timestamp | open | high | low | close | volume |
|---|---|---|---|---|---|
| 2024-01-15 00:00 | 42,800.00 | 43,120.50 | 42,640.00 | 43,050.25 | 18,420.3 |
| 2024-01-15 04:00 | 43,050.25 | 43,380.00 | 42,980.75 | 43,310.00 | 21,840.7 |
| 2024-01-15 08:00 | 43,310.00 | 43,450.25 | 43,100.00 | 43,150.50 | 14,220.1 |
| 2024-01-15 12:00 | 43,150.50 | 43,200.00 | 42,880.25 | 42,940.00 | 24,680.9 |
| … | … | … | … | … | … |
| Parameter | Type | What it accepts |
|---|---|---|
| symbol | string | Any symbol available in your provider: "BTC/USDT", "ES", "NQ", "AAPL", "EUR/USD" |
| timeframe | string | "1m", "5m", "15m", "1h", "4h", "1d", "1w" — must be supported by provider |
| bars | integer | Number of completed bars to return. Maximum: 5,000. More bars = slower fetch. |
| end | datetime (optional) | End date for historical research. Defaults to now (current session data). |
The dt.backtest() function runs your strategy function against historical data and returns a full performance report. Walk-forward mode (wf=True) is strongly recommended — it's the difference between an honest and a misleading result.
2def my_strategy(df):
3 df['sma20'] = df['close'].rolling(20).mean()
4 df['signal'] = (df['close'] > df['sma20']).astype(int)
5 return df['signal']
6
7# Run backtest with walk-forward validation
8results = dt.backtest(
9 df,
10 strategy=my_strategy,
11 wf=True, # walk-forward — strongly recommended
12 cost_bps=5, # 5 basis points per trade (realistic)
13 slippage_bps=2 # 2 bps slippage assumption
14)
15print(results.summary())
Reading the output metrics
Always use wf=True — here's why it matters
Without walk-forward, your backtest fits the strategy to data it has already seen — which almost always produces a better result than real trading. Walk-forward simulates deploying the strategy in rolling out-of-sample windows, giving you a realistic picture of what you'd have actually earned. The OOS Sharpe is the honest number. The in-sample Sharpe is the optimistic one.
A backtest result that passes all five of these checks is worth investigating further. A result that fails two or more is likely a false positive — do not proceed to live deployment based on it.
.shift(1) in pandas when referencing the prior bar's value.When your research passes the validation checklist, you can export the strategy function directly to the Script Library as a Dome Script template. From there it can be validated, refined in Dome Script syntax, and connected to a bot.
2dt.export(
3 my_strategy,
4 "Volume Breakout v1",
5 notes="Walk-forward validated Jan 2023 - Jan 2024. OOS Sharpe 1.18."
6)
7# → Creates a Dome Script template in Script Library
8# → Includes the backtest summary and notes as comments
9# → You can then refine, validate, and deploy from Script Library
Export carries your research context forward
The exported Dome Script template includes your backtest metrics and any notes you added as comments in the script header. This ensures that when you or someone else opens the strategy in Script Library months later, the research context is preserved — including why you built it and what the validation numbers were.
These four mistakes account for the majority of misleading research results. Knowing what they are doesn't prevent you from making them — but checking for them systematically does.
Overfitting to historical data
Running dozens of parameter combinations until you find one that looks great on the in-sample period. The strategy is memorizing the past, not discovering an edge. Walk-forward testing and a single, pre-specified parameter set are the defenses against this.
Ignoring transaction costs
Setting cost_bps=0 or not thinking about it. A strategy that trades 20 times per day at 5 bps per trade loses 1% per day just to costs — before market risk. Always include realistic costs for your instrument and broker.
Confusing in-sample with out-of-sample
Reporting the in-sample Sharpe as if it represents real-world performance. The in-sample number is what the strategy earned when it already knew the answers. The OOS number is what it earned when it didn't. Only the OOS number is a realistic performance estimate.
Testing only in trending markets
Most momentum strategies look excellent when backtested on 2020–2021 crypto data (a strongly trending period). The question is how they perform in 2022 (downtrend) and 2023 (range). If your data doesn't include all three types of conditions, your result is incomplete.