How to Intermediate · 3 min read

AI in investment banking explained

Quick answer
Investment banking leverages AI and LLMs for automating tasks such as risk assessment, market analysis, and client communication. Models like gpt-4o-mini can generate financial reports, analyze trends, and assist in decision-making, improving efficiency and accuracy.

PREREQUISITES

  • Python 3.8+
  • OpenAI API key (free tier works)
  • pip install openai>=1.0

Setup

Install the openai Python package and set your API key as an environment variable to access AI models for investment banking tasks.

bash
pip install openai>=1.0
output
Collecting openai
  Downloading openai-1.x.x-py3-none-any.whl
Installing collected packages: openai
Successfully installed openai-1.x.x

Step by step

This example uses gpt-4o-mini to generate a brief financial market summary, simulating an investment banking use case for automated report generation.

python
import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

messages = [
    {"role": "user", "content": "Provide a concise summary of the current US stock market trends and key risks for investment banking analysts."}
]

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=messages
)

print("Market summary:", response.choices[0].message.content)
output
Market summary: The US stock market shows moderate volatility driven by inflation concerns and geopolitical tensions. Key risks include interest rate hikes and supply chain disruptions impacting sectors like technology and manufacturing.

Common variations

You can use asynchronous calls, streaming responses for real-time updates, or switch to other models like claude-3-5-haiku-20241022 for nuanced financial analysis.

python
import os
import asyncio
from openai import OpenAI

async def async_market_summary():
    client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
    messages = [
        {"role": "user", "content": "Summarize recent M&A activity in the tech sector."}
    ]
    
    stream = await client.chat.completions.create(
        model="gpt-4o-mini",
        messages=messages,
        stream=True
    )

    async for chunk in stream:
        delta = chunk.choices[0].delta.content or ""
        print(delta, end="", flush=True)

asyncio.run(async_market_summary())
output
Recent M&A activity in the tech sector has accelerated, with major deals focusing on cloud computing and AI startups. This trend reflects strategic positioning to capitalize on emerging technologies and market consolidation.

Troubleshooting

  • If you receive authentication errors, verify your OPENAI_API_KEY environment variable is set correctly.
  • For rate limit errors, implement exponential backoff or upgrade your API plan.
  • If responses are incomplete, try increasing max_tokens in your request.

Key Takeaways

  • Use gpt-4o-mini or claude-3-5-haiku-20241022 for financial text generation and analysis.
  • Automate report generation and risk assessment to improve investment banking efficiency.
  • Leverage streaming API calls for real-time market updates and insights.
Verified 2026-04 · gpt-4o-mini, claude-3-5-haiku-20241022
Verify ↗