You'll create an automated system that analyzes company earnings transcripts and generates investment insights using Anthropic's Claude API in about 90 minutes.

Key Takeaways

  • Claude API costs approximately $0.50-2.00 per company analysis depending on transcript length
  • The pipeline can process 10-50 companies in a single automated run
  • Weekly automation saves 15+ hours of manual research time per month

What You'll Need

  • Anthropic API account with $20+ credit balance
  • Python 3.8+ with pip package manager
  • Basic command line familiarity
  • Text editor or VS Code
  • SEC EDGAR API access (free)

Time estimate: 90 minutes | Difficulty: Intermediate

Step-by-Step Instructions

Step 1: Set Up Anthropic API Access and Python Environment

Visit Anthropic's developer console and create an account. Click "Get API Keys" in the dashboard and generate a new key. Copy this key immediately—you won't see it again.

Open your terminal and install the required Python packages:

pip install anthropic requests pandas schedule python-dotenv

Create a new project folder and add a .env file to store your API key securely. Never hardcode API keys in your scripts—this prevents accidental exposure if you share your code.

Step 2: Create the SEC Filing Data Fetcher

Build a function to retrieve earnings call transcripts from the SEC's EDGAR database. Create a file called transcript_fetcher.py and add the following core function:

import requests
import json
import time

def get_company_filings(ticker, filing_type="8-K"):     headers = {"User-Agent": "YourName your.email@domain.com"}     url = f"https://data.sec.gov/api/xbrl/companyfacts/CIK{get_cik(ticker)}.json"     response = requests.get(url, headers=headers)     time.sleep(0.1) # SEC rate limit compliance     return response.json() if response.status_code == 200 else None

The SEC requires a proper User-Agent header with your contact information. The 0.1-second delay ensures you stay within their 10 requests per second limit to avoid getting blocked.

Step 3: Design the Claude Analysis Prompt Template

Create a structured prompt that consistently extracts investment insights from earnings transcripts. Your prompt template should request specific, quantifiable outputs rather than generic summaries.

INVESTMENT_ANALYSIS_PROMPT = """ Analyze this earnings call transcript for investment insights. Provide a structured analysis with: 1. FINANCIAL HEALTH (Score 1-10) - Revenue growth trajectory and sustainability - Margin expansion or compression trends - Cash flow generation strength 2. COMPETITIVE POSITION (Score 1-10) - Market share gains or losses mentioned - Competitive advantages discussed - Pricing power indicators 3. MANAGEMENT QUALITY (Score 1-10) - Clarity of strategic vision - Historical execution track record - Transparency in communication 4. KEY RISKS (Top 3) - Specific operational or market risks mentioned - Quantified impact where possible 5. PRICE TARGET JUSTIFICATION - Based on disclosed metrics and guidance - Conservative and optimistic scenarios Format as structured JSON for easy parsing. Transcript: {transcript_text} """

This template ensures Claude provides consistent, actionable output rather than generic commentary. The scoring system creates comparable metrics across different companies.

A wooden table topped with scrabble tiles spelling news and mail
Photo by Markus Winkler / Unsplash

Step 4: Build the Core Analysis Pipeline

Create the main processing script that combines transcript fetching with Claude analysis. This script should handle errors gracefully and track processing costs.

import anthropic
import os
from dotenv import load_dotenv

load_dotenv()

client = anthropic.Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))

def analyze_company(ticker, transcript_text):     try:         message = client.messages.create(             model="claude-3-sonnet-20240229",             max_tokens=2000,             temperature=0.3,             messages=[{"role": "user", "content": INVESTMENT_ANALYSIS_PROMPT.format(transcript_text=transcript_text)}]         )         return message.content[0].text     except Exception as e:         print(f"Analysis failed for {ticker}: {e}")         return None

The temperature=0.3 setting keeps Claude's responses focused and consistent. Higher temperatures produce more creative but less reliable financial analysis.

Step 5: Implement CSV Export and Data Tracking

Build a system to save analysis results in a format suitable for portfolio tracking tools. Create functions that normalize Claude's JSON output and append results to a master spreadsheet.

import pandas as pd
import json
from datetime import datetime

def save_analysis_to_csv(ticker, analysis_text, output_file="investment_analysis.csv"):     try:         # Parse Claude's JSON response         analysis_data = json.loads(analysis_text)                  row_data = {             "Ticker": ticker,             "Date": datetime.now().strftime("%Y-%m-%d"),             "Financial_Score": analysis_data.get("financial_health", 0),             "Competitive_Score": analysis_data.get("competitive_position", 0),             "Management_Score": analysis_data.get("management_quality", 0),             "Top_Risk": analysis_data.get("key_risks", ["Unknown"])[0]         }                  df = pd.DataFrame([row_data])         df.to_csv(output_file, mode='a', header=not os.path.exists(output_file), index=False)              except json.JSONDecodeError:         print(f"Failed to parse analysis for {ticker}")

This function creates a cumulative dataset that tracks how your investment scores change over time. The append mode preserves historical analysis while adding new results.

Step 6: Set Up Weekly Automation

Use Python's schedule library to run your analysis pipeline automatically. Create a main execution script that processes a predefined list of companies every Sunday.

import schedule
import time

WATCHLIST = ["AAPL", "MSFT", "GOOGL", "TSLA", "AMZN"]

def run_weekly_analysis():     print(f"Starting weekly analysis at {datetime.now()}")     for ticker in WATCHLIST:         transcript = get_latest_transcript(ticker)         if transcript:             analysis = analyze_company(ticker, transcript)             if analysis:                 save_analysis_to_csv(ticker, analysis)             time.sleep(5) # Rate limiting between companies     print("Weekly analysis completed")

schedule.every().sunday.at("09:00").do(run_weekly_analysis)

while True:     schedule.run_pending()     time.sleep(3600) # Check every hour

The 5-second delay between companies prevents API rate limiting and keeps your costs predictable. Sunday morning execution ensures fresh analysis before markets open Monday.

Step 7: Test With Real Market Data

Run your pipeline on a small test set before full automation. Start with 2-3 companies to verify output quality and catch any formatting issues.

python investment_pipeline.py --test-mode --companies=AAPL,MSFT

Check that your CSV output contains properly formatted scores and that Claude's analysis makes logical sense. Look for consistent scoring patterns and verify that the JSON parsing works correctly.

Troubleshooting

API timeout errors: Increase the delay between requests to 10 seconds and reduce transcript size by extracting only Q&A sections.

JSON parsing failures: Add error handling that saves raw Claude responses to debug formatting issues before fixing your prompt template.

High API costs: Use Claude Haiku model for initial testing—it costs 80% less than Sonnet while providing adequate analysis quality.

Expert Tips

  • Pro tip: Include "respond only in valid JSON format" at the end of your Claude prompt to reduce parsing errors by 90%.
  • Set up API spending alerts in Anthropic's console at $50 monthly to avoid surprise bills during testing.
  • Cache transcript data locally to avoid re-downloading SEC filings during pipeline development.
  • Use the schedule library's run_all() function for manual pipeline execution during market hours.

What to Do Next

Once your basic pipeline works reliably, expand it to include sector-specific analysis prompts and integrate with portfolio management APIs for automated position sizing. As we explored in our analysis of AI-powered investment research, combining multiple AI models often produces superior results to single-model approaches. Consider adding sentiment analysis from earnings call audio using speech-to-text APIs, or build custom risk models using the historical scoring data your pipeline generates.