Intermediate
15 min
AI Analyst for Stock Market Data with BigQuery & Claude
Build a local AI analyst for stock market and investment data using Bruin CLI, BigQuery, and Claude Code.
AIBruin CLIBigQueryMCPClaude CodeFinance
Learning paths:Data AnalystData Engineer
Overview
Goal — Build a local AI analyst for stock market data using Bruin CLI, BigQuery, and Claude Code.
Audience — Data professionals and financial analysts who want an AI-powered investment analysis workflow.
Prerequisites
- BigQuery project and dataset with data already loaded
- gcloud CLI installed
- Bruin CLI installed
- Claude Code installed and authenticated for
bruin ai enhance - Bruin MCP configured for Claude Code
Steps
1) Initialise the pipeline
- Run
bruin init empty sp500. If the current folder is already git-initialised, this createssp500unless you pass--in-place. - If the current folder is not a git repo, Bruin creates a
bruin/folder first and then creates the project and pipeline inside it. - Use the pipeline path that was created. If Bruin created
sp500in your repo, drop thebruin/prefix in later commands. - For more context, see Bruin project docs and video walkthrough.
2) Authenticate to BigQuery
- Run
gcloud auth login. For more details, see gcloud auth login.
3) Configure the BigQuery connection
- Use
bruin connections add(interactive) or flags with--type google_cloud_platform. - Name the connection
gcp-defaultso later commands match the tutorial. - Test it with
bruin connections test --name gcp-default --env default.
4) Import metadata
- Run
bruin import database bruin/sp500 --connection gcp-default --schema stock_market. - For BigQuery, use
--schemasto import multiple schemas.
5) Enhance metadata
- Run
bruin ai enhance bruin/sp500using Claude Code. - Use
--claudeif multiple AI CLIs are installed. - See AI enhance command for flag options.
6) Configure Bruin MCP in Claude Code
- Add the Bruin MCP server to Claude Code. See Bruin MCP setup.
7) Create the agent instruction file
- Create an
AGENTS.mdfile in the project root with pretext, context, rules, and instructions. - Tell the agent to read
pipeline.ymlandassets/. - Require
bruin queryfor all data access, and use--dry-runwhile testing.
8) Prompt the agent
- Ask investment analysis questions, for example: "Which companies had their free cash flow margin improve in the past 4 quarters but saw their stock price decrease more than 10% during the same period?"
