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 creates sp500 unless 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 sp500 in your repo, drop the bruin/ prefix in later commands.
  • For more context, see Bruin project docs and video walkthrough.

2) Authenticate to BigQuery

3) Configure the BigQuery connection

  • Use bruin connections add (interactive) or flags with --type google_cloud_platform.
  • Name the connection gcp-default so 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 --schemas to import multiple schemas.

5) Enhance metadata

  • Run bruin ai enhance bruin/sp500 using Claude Code.
  • Use --claude if multiple AI CLIs are installed.
  • See AI enhance command for flag options.

6) Configure Bruin MCP in Claude Code

7) Create the agent instruction file

  • Create an AGENTS.md file in the project root with pretext, context, rules, and instructions.
  • Tell the agent to read pipeline.yml and assets/.
  • Require bruin query for all data access, and use --dry-run while 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?"