Notebooks & Cells
SQL, Python, AI, Markdown, and visualization cells for custom analysis.
Notebook Fundamentals
A notebook is an ordered collection of cells that you execute sequentially or individually. Each cell has a specific type that determines what it does: query data, run code, render a chart, compute statistics, or document your analysis. Cells can reference the output of previous cells, creating a data pipeline from raw query to finished visualization within a single document.
Notebooks are saved to your account and accessible from any device. Every save creates a version snapshot you can revert to. Notebooks can be duplicated, exported as JSON, and shared with other Thrive users via a read-only link. The shared recipient must have a Pro+ or Founder account to execute the cells.
Notebook Toolbar
The toolbar at the top of every notebook provides the core actions you use throughout your workflow.
| Run All | Executes every cell in order from top to bottom. Useful for re-running an entire analysis after changing parameters. |
| Add Cell | Opens the cell type picker. Select the type and a new cell is inserted below the currently selected cell. |
| Save | Manually saves the notebook and creates a named version. Auto-save runs every 60 seconds as a safety net. |
| Version History | Opens the version sidebar showing every saved version with timestamps. Click any version to preview or restore it. |
| Share | Generates a read-only sharing link. Recipients can view the notebook and its outputs but cannot edit or execute cells. |
| Export | Downloads the notebook as a JSON file or exports query results as CSV. |
| Parameters | Opens the parameter bar where you can define dynamic inputs that feed into cell queries. |
SQL Cells
SQL cells are the most commonly used cell type. They execute PostgreSQL queries directly against the Thrive data warehouse and display results in an interactive table. The SQL editor includes syntax highlighting, auto-completion for table and column names, and inline error reporting.
Editor Features
Full PostgreSQL syntax highlighting with keyword, function, and string coloring.
Type a table name prefix and the editor suggests matching tables and columns from the schema.
Query errors are displayed inline below the editor with the error message and the offending line highlighted.
Use {{param_name}} syntax to inject parameter cell values into your query dynamically.
Large result sets are paginated with 100 rows per page. Sort any column by clicking its header.
Shows query execution time and the number of rows returned after each run.
Example Queries
Here are practical SQL queries that demonstrate common Workbench workflows. Each can be pasted directly into a SQL cell and executed.
Schema reference
Funding rate extremes across all assets:
SELECT
symbol,
funding_rate,
funding_rate_zscore,
open_interest_usd,
price_change_24h_pct
FROM asset_screener_latest
WHERE ABS(funding_rate_zscore) > 2.0
ORDER BY ABS(funding_rate_zscore) DESC;Your top 10 trades by realized P&L:
SELECT
symbol,
direction,
entry_price,
exit_price,
realized_pnl,
opened_at,
closed_at,
tags
FROM trades
WHERE user_id = current_user_id()
AND status = 'closed'
ORDER BY realized_pnl DESC
LIMIT 10;Divergences that resolved correctly in the last 30 days:
SELECT
symbol,
divergence_type,
severity,
detected_at,
resolved_at,
resolution_outcome,
price_change_after_pct
FROM divergences
WHERE resolved_at > NOW() - INTERVAL '30 days'
AND resolution_outcome = 'correct'
ORDER BY ABS(price_change_after_pct) DESC;Hourly funding rate for a specific asset over 7 days:
SELECT
timestamp,
exchange,
funding_rate,
funding_rate * 3 * 365 AS annualized_rate
FROM funding_rate_history
WHERE symbol = '{{asset}}'
AND timestamp > NOW() - INTERVAL '7 days'
ORDER BY timestamp ASC;Parameter interpolation
{{asset}} syntax in the query above references a Parameter cell. When you run the query, Thrive substitutes the current value of the parameter. This lets you build reusable notebooks where you change one input and all dependent queries update.Python Cells
Python cells run in a sandboxed server-side environment with pre-installed data science libraries. They are designed for custom analysis that goes beyond what SQL can express: statistical modeling, custom indicator calculation, machine learning, and advanced data transformations.
Pre-Installed Libraries
DataFrames for tabular data manipulation. The primary interface for working with query results.
Numerical computing for array operations, linear algebra, and statistical calculations.
Scientific computing including optimization, interpolation, signal processing, and statistical tests.
Machine learning models for clustering, regression, classification, and feature engineering.
Charting libraries for custom visualizations rendered inline in the notebook.
HTTP client for calling external APIs from your analysis scripts.
Accessing Query Results in Python
Python cells can reference the output of any SQL cell in the same notebook using the cells object. Each SQL cell's result is available as a pandas DataFrame.
# Access the result of SQL cell "funding_data" as a DataFrame
df = cells["funding_data"].df
# Calculate the rolling 24h average funding rate
df["funding_24h_avg"] = df["funding_rate"].rolling(24).mean()
# Find assets where current funding deviates > 2 sigma from average
df["deviation"] = (df["funding_rate"] - df["funding_24h_avg"]) / df["funding_rate"].std()
outliers = df[df["deviation"].abs() > 2.0]
# Display results inline
display(outliers[["symbol", "funding_rate", "funding_24h_avg", "deviation"]])AI Cells
AI cells accept natural language prompts and translate them into SQL queries, analysis summaries, or data interpretations. They are powered by large language models with full awareness of the Thrive schema, so you can describe what you want in plain English and the AI generates and executes the corresponding query.
AI cells are particularly useful for users who are not fluent in SQL or for complex queries that would take significant time to write manually. The AI can also interpret query results: after a SQL cell returns data, you can add an AI cell that says "summarize the key takeaways from the funding rate data above" and receive a narrative analysis.
AI Cell Modes
| Query Generation | Describe what data you want and the AI writes and executes the SQL. Example: "Show me all assets where funding rate z-score is above 2 and price dropped more than 5% today." |
| Data Interpretation | Point the AI at a previous cell's output and ask for analysis. Example: "What patterns do you see in these divergence resolution rates?" |
| Strategy Suggestion | Ask the AI to suggest trading strategies based on current market data. Example: "Based on current funding extremes, which assets have the best mean-reversion setup?" |
AI cell credit cost
Visualization Cells
Visualization cells render charts, tables, and heatmaps from the output of a referenced SQL or Python cell. They provide a no-code chart builder where you select the chart type, map columns to axes, configure colors and labels, and see the result rendered instantly.
Supported Chart Types
Time-series data, trend lines, and multi-series overlays. Ideal for funding rate history, price curves, and rolling averages.
Categorical comparisons and distributions. Useful for asset rankings, volume comparisons, and signal performance by type.
Two-dimensional color-coded grids. Perfect for z-score matrices, correlation tables, and time-of-day performance analysis.
Relationship visualization between two variables. Map funding rate vs. OI change, or price change vs. volume.
Stacked or layered area fills for cumulative metrics. Exchange-level OI composition, portfolio allocation over time.
Proportional breakdowns. Trade distribution by asset, signal accuracy by type, credit usage by category.
Sortable, filterable data table with conditional formatting, sparklines, and inline bar indicators.
Statistics Cells
Statistics cells automatically compute descriptive statistics on the output of a referenced data cell. They produce a summary panel showing mean, median, standard deviation, min, max, percentiles, skewness, and kurtosis for every numeric column in the dataset. This is useful for quick exploratory analysis without writing any aggregation queries.
Counter Cells
Counter cells display a single KPI value in large, readable typography. They reference a SQL cell that returns a single row and single column, and render that value as a prominent metric card. Counter cells support conditional coloring (green/red based on positive/negative), prefix and suffix formatting (e.g., $ or %), and comparison to a previous period value with delta display.
Counter cells are the building blocks for KPI dashboards. Pin six to eight counter cells to a dashboard row and you have an executive summary of your most important metrics.
Additional Cell Types
Beyond the core cell types above, the Workbench supports several specialized cells for domain-specific workflows.
| Markdown | Rich text documentation cells with full Markdown support. Use them to annotate your analysis, explain methodology, or create report headers. |
| Parameter | Dynamic input cells that define variables (dropdowns, date pickers, text fields) injected into SQL queries via {{param}} syntax. |
| Backtest | Define a trading strategy and test it against historical data. Outputs P&L curve, drawdown chart, Sharpe ratio, and trade log. |
| Strategy | Describe entry/exit rules, position sizing, and risk parameters. Strategy cells integrate with the backtesting engine. |
| Trade Analysis | Analyze your trade journal data with pre-built analytics: win rate by asset, average hold time, P&L distribution, and time-of-day patterns. |
| Import | Upload CSV files into temporary tables that you can join with existing data warehouse tables in subsequent SQL cells. |
Building an Analysis Workflow
The real power of notebooks emerges when you chain cells together into a complete analysis pipeline. Here is a practical workflow for analyzing funding rate extremes.
Create a Parameter cell for asset selection
Add a Parameter cell with a dropdown populated from the list of tracked assets. Name the parameter asset. This becomes the dynamic input for all subsequent queries.
Query funding rate history with a SQL cell
Write a SQL query that pulls funding rate data for {{asset}} over the last 30 days. Include the exchange, timestamp, and annualized rate columns.
Visualize with a Line Chart cell
Add a visualization cell referencing the SQL output. Select "Line Chart," map timestamp to the X axis and funding_rate to the Y axis, and split by exchange for a multi-series overlay.
Compute statistics
Add a Statistics cell referencing the same SQL output. This gives you mean funding, standard deviation, min/max, and percentiles without writing aggregation queries.
Add AI interpretation
Add an AI cell with the prompt: "Analyze the funding rate history for this asset. Are current levels extreme? What does this suggest about positioning?" The AI references the SQL results and statistical summary to produce a narrative analysis.
Document with Markdown
Add a Markdown cell at the top with a title, date, and methodology description. This turns the notebook into a shareable research report that other team members can read and reproduce.
Keyboard shortcuts in notebooks
Shift+Enter to run the current cell and advance to the next. Press Cmd+Enter to run without advancing. Press Escape then A to insert a cell above, or B to insert below.