Why It Matters
In an era of increasing trade tensions and evolving geopolitical landscapes, companies face unprecedented uncertainty around import tariffs and trade barriers. Understanding corporate exposure to tariff risks across global supply chains is critical for investment decisions, risk management, and strategic planning, but manual tracking of tariff impacts across multiple companies and markets is time-intensive and often incomplete.What It Does
The cookbook REST modules combine risk taxonomy generation and report generation (src/report_generator.py, src/search_helper.py) with the Bigdata.com REST API and bigdata-smart-batching to systematically analyze corporate exposure to US import tariff risks.
How It Works
The workflow integrates hybrid semantic search, AI-powered risk taxonomies, and multi-source content analysis to deliver:- Automated Risk Taxonomy Creation using OpenAI +
generate_themes_tree_dictto build hierarchical risk categories specific to tariff impacts - Cross-Source Intelligence Gathering searching news articles, SEC filings, and earnings transcripts for relevant discussions
- AI-Powered Risk Classification categorizing content into specific risk scenarios with Media Attention, Financial Impact, and Uncertainty metrics
- Corporate Response Extraction identifying and summarizing company mitigation plans from official communications
- Dual Report Generation producing both executive summary and detailed analysis formats in professional HTML reports
A Real-World Use Case
This cookbook demonstrates the complete end-to-end workflow through analyzing how US import tariffs impact major American companies. You’ll see how the system transforms scattered tariff discussions across news, SEC filings, and earnings transcripts into structured risk assessments, complete with corporate response strategies and quantified exposure metrics for investment and risk management decisions. Ready to get started? Let’s dive in!Prerequisites
To run the Specialized Report Tariffs workflow, you can choose between two options:-
💻 GitHub cookbook
- Use this if you prefer working locally or in a custom environment.
- Follow the setup and execution instructions in the
README.md. - Copy
.env.exampleto.envand set:BIGDATA_API_KEY— your Bigdata.com API keyOPENAI_API_KEY— your OpenAI API key (required for LLM labeling and summarization)- See the cookbook
README.mdfor full setup instructions.
-
🐳 Docker Installation
- Docker installation is available for containerized deployment.
- Provides an alternative setup method with containerized deployment, simplifying the environment configuration for those preferring Docker-based solutions.
Setup and Imports
Below is the Python code required for setting up our environment and importing necessary libraries.Defining the Analysis Parameters
Core Parameters
- Main Theme (
main_theme): The central risk scenario to analyze across companies - Focus (
focus): Expert perspective for generating targeted risk taxonomies - Company Universe (
universe_path): CSV withRP_ENTITY_IDandCOMPANY_NAMEcolumns loaded viaload_universe(). - Model Selection (
llm_model): The AI model used for risk classification and summarization - Frequency (
freq): The frequency of the date ranges to search over. Supported values:Y: Yearly intervals.M: Monthly intervals.W: Weekly intervals.D: Daily intervals. Defaults to3M.
- Time Period (
start_dateandend_date): The date range for the analysis - Document Limits (
document_limit_news,document_limit_filings): The maximum number of documents to return per query to Bigdata API for each category of documents - Batch Size (
batch_size): The number of entities to include in a single batched query - Rerank Threshold (
rerank_threshold): By setting this value, you’re enabling the cross-encoder which reranks the results and selects those whose relevance is above the percentile you specify (0.7 being the 70th percentile). More information on the re-ranker can be found here. - News Fallback Control (
news_search_fallback): IfTrue, when no response is found in transcripts/filings, the system uses News as fallback and tags those responses with[From News]. IfFalse, missing responses are shown as “No evidence of discussions found in Transcripts/Filings.” Default:True.
Risk Analysis Phase
The first phase builds a risk taxonomy, retrieves news, and labels excerpts via REST + OpenAI. These steps producedf_labeled and themes_tree_dict for GenerateReport.
Generate Risk Taxonomy
Create a comprehensive taxonomy that breaks down tariff risks into specific, analyzable categories such as supply chain disruption, pricing impacts, and market access challenges.
Retrieve Relevant Content
Search news articles using the generated taxonomy to find discussions about tariff impacts across our company universe.Labeling
Use AI to analyze each news excerpt and categorize it into the appropriate risk scenarios. This creates structured data from unstructured news content.Report Generation Phase
The second phase usesGenerateReport and transforms the classified risk data into comprehensive reports with corporate mitigation strategies.
Initialize GenerateReport
TheGenerateReport class will create sector-wide risk summaries, generate company-specific risk scores and summaries, extract mitigation plans from SEC filings and earnings transcripts, and produce professional HTML reports with customizable ranking criteria.
Generate Comprehensive Report
Execute the complete report generation workflow including:- Sector-Level Summarization: Create thematic summaries across risk categories
- Company-Level Analysis: Generate risk scores for Media Attention, Financial Impact, and Uncertainty
- Mitigation Strategy Extraction: Search filings and transcripts for corporate response plans (with optional News fallback controlled by
news_search_fallback) - Data Integration: Combine all sources into structured report datasets
Final Output
Transform the analysis results into professional, customizable reports. The system provides two distinct presentation styles, each optimized for different use cases and audiences.Report Customization Options
Both report formats allow customization through multiple ranking criteria: Sector-Wide Analysis:- Identifies the most significant tariff risks across all companies
- Ranks themes by media attention and document frequency
- Provides executive summaries for each risk category
- Most Reported Issue: Highest media coverage and attention
- Biggest Risk: Greatest potential financial impact
- Most Uncertain Issue: Highest uncertainty scores and ambiguity
Report Format 1: Executive Summary Style
This format prioritizes clarity and executive readability, focusing on the top risks per company across three key dimensions. Ideal for senior management briefings and board presentations.

Report Format 2: Detailed Analysis Version
This format provides comprehensive risk analysis with extended company coverage and detailed risk breakdowns. Designed for analysts, portfolio managers, and risk management teams requiring in-depth insights.

Export Results for Further Analysis
The generated data can be exported for integration with existing risk management systems, portfolio optimization tools, or compliance reporting workflows.Conclusion
This workflow demonstrates a comprehensive approach to tariff risk analysis that combines REST-based risk taxonomy generation, news retrieval, and labeling with the report generation capabilities ofGenerateReport.
Through the integrated analysis of tariff risks and corporate mitigation strategies, you can:
- Identify Risk-Exposed Companies - Discover which companies face the greatest exposure to tariff impacts across different risk categories including supply chain disruption, pricing pressures, and market access challenges
- Assess Corporate Preparedness - Evaluate how well companies are positioned to handle tariff risks through their documented mitigation strategies and response plans
- Quantify Multi-Dimensional Risk - Use Media Attention, Financial Impact, and Uncertainty scores to compare risk levels across companies and risk categories
- Generate Investment Intelligence - Create professional reports that inform portfolio decisions, risk management strategies, and trade policy impact assessments