Coding Assistance and “Vibe Coding” for Financial Modeling
Students describe financial logic in English; AI writes the code; students verify, annotate, and explain it.
Coding Assistance and “Vibe Coding” for Financial Modeling
IntermediateTeaching Problem
Finance courses increasingly require programming (Python, R, VBA, SQL) for financial modeling, data analysis, and algorithmic trading. Students without computer science backgrounds stall on syntax errors and debugging—problems that consume class time better spent on financial reasoning.
How AI Addresses the Problem
The concept of ‘vibe coding’ (articulated by Prof. Kerry Back at Rice University) represents a paradigm shift: students describe financial logic in natural language, AI generates the code, and students verify, annotate, modify, and interpret the output. The student’s role shifts from ‘coder’ to ‘systems architect.’
Deployment Details
- Courses
- Financial Modeling (UG/MBA), Financial Analytics (UG/MBA), Fintech/Algorithmic Trading (MBA), Derivatives, Capstone projects
- Tools
- GitHub Copilot, ChatGPT Code Interpreter, Claude (Artifacts), Cursor IDE, Google Colab with Gemini, Replit AI
Student Workflow
- Receive a financial modeling task with clearly specified requirements.
- Write a plain-English specification describing inputs, calculations, outputs, and edge cases—before touching AI.
- Submit the specification to AI and receive generated Python/R/VBA code.
- Annotate the code line-by-line: for each meaningful section, explain the financial logic.
- Modify the code to handle at least one extension (add transaction costs, incorporate short-selling constraints, test with different time periods, add a risk metric).
- Run the final code, interpret outputs in a written memo, and present findings with a 3-minute oral walkthrough defending the financial logic.
Sample Prompts
Factor Model Construction
Build a Python script that: (1) Pulls 3 years of daily adjusted close prices for SPY and a user-defined list of 5 stock tickers from Yahoo Finance using yfinance. (2) Calculates daily log returns for each. (3) Runs an OLS regression of each stock's returns against SPY returns to estimate Beta. (4) Displays a summary table showing each stock's Beta, Alpha (annualized), R-squared, and p-value on Alpha. (5) Plots the regression line (Security Characteristic Line) for each stock with the data points. (6) Adds a brief interpretation comment below each plot explaining what the Beta and R-squared imply about the stock's risk profile.
Black-Scholes Options Pricing Calculator
Build a Black-Scholes option pricing calculator in Python. Inputs: current stock price, strike price, risk-free rate, annualized volatility, and time to expiration in years. Outputs: (1) European call and put prices, (2) all five Greeks (Delta, Gamma, Theta, Vega, Rho) for both call and put, (3) a 3D surface plot showing how call option price varies with stock price (x-axis: 50-150% of current price) and volatility (y-axis: 10-60%). (4) Add a payoff diagram at expiration overlaid with the current option value curve. Label all axes clearly with units.
Assessment Approach
- Code annotation quality25%
- Financial logic accuracy25%
- Modification quality20%
- Output interpretation and memo quality20%
- Oral walkthrough10%
Skills Developed
Finance Concepts
DCF modeling, Monte Carlo simulation, option pricing and Greeks, factor models, portfolio optimization, backtesting methodology
Analytical Skills
Code auditing for financial logic errors, model validation against analytical solutions, sensitivity analysis
Professional Skills
Technical specification writing, working with AI as a professional co-pilot, communicating quantitative results
AI Literacy Skills
Natural language-to-code translation, verifying AI-generated code against known solutions, understanding coding limitations and edge cases
Evidence
Prof. Kerry Back (Rice University, 2025) has been a leading advocate for ‘vibe coding’ in finance education. Becker et al. (2023) and Denny et al. (2024) document AI coding assistance in CS education. Wharton’s AI for Business major (2025) includes required coursework in applied machine learning.
Risks and Safeguards
Financial Logic Errors in AI Code
AI may calculate returns using price levels instead of log returns, mishandle ex-dividend dates, apply wrong sign conventions. Sign convention errors are especially common in finance code: AI frequently treats cash outflows as positive when they should be negative (or vice versa), producing DCF values with the wrong sign or NPV calculations that recommend rejection when the project is actually positive. Mitigation: require students to manually verify the sign and unit of at least one cash flow in their annotated code; include a "break it" exercise where students deliberately flip a sign and explain what the incorrect output would imply.
Copy-Paste Without Understanding
Mitigation: oral walkthroughs are highly effective at distinguishing students who understand from those who do not.
API Key Exposure
Students may paste API keys into chatbot sessions. Mitigation: explicit policy; use only free data sources.
Academic Integrity
Clearly define acceptable AI use for each assignment in the syllabus.
Try it this week
First-Week Implementation Pilot
In class, open ChatGPT or Claude and type: ‘Write Python code to calculate the present value of $10,000 received in 5 years at a 7% annual discount rate. Show the formula in a comment.’ Display the result (15 seconds). Then ask students: ‘What would you need to change if there were also annual $500 coupon payments?’ Have a student describe the change in plain English. Paste their description into the AI. Display the updated code. Debrief: ‘The AI wrote it—how would you verify it’s correct?’ Total time: 8 minutes.