The Curated Daily
← Back to the archiveDispatch · 6 min read
Dispatch

Using AI to write better code more slowly

By the editors·Tuesday, May 26, 2026·6 min read
A laptop screen showing a code editor with a cute orange crab plush toy beside it.
Photograph by Daniil Komov · Pexels

The hype around AI coding assistants like GitHub Copilot, Tabnine, and Amazon CodeWhisperer is undeniable. Developers are promised productivity boosts, reduced boilerplate, and even the ability to generate entire functions with a few keystrokes. But in the high-stakes world of finance, where accuracy and reliability are paramount, simply writing code faster isn't the primary goal. It’s about writing code better. This article explores how to strategically use AI coding tools in finance, not for sheer speed, but for improved code quality, reduced risk, and enhanced maintainability – even if it means a slower initial development pace.

The Unique Challenges of Finance Code

Financial applications operate under a different set of constraints than, say, a social media app or an e-commerce website. The stakes are much higher.

  • Regulatory Compliance: Financial systems are heavily regulated. Code must be auditable, transparent, and comply with rules like SOX, Dodd-Frank, and GDPR.
  • Data Accuracy: Even a tiny error in calculations can lead to significant financial losses. Precision is non-negotiable.
  • Security: Financial data is a prime target for cyberattacks. Code vulnerabilities can have devastating consequences.
  • Algorithmic Fairness: In areas like loan applications or credit scoring, algorithms must be free from bias.
  • Real-time Performance: Many financial applications, such as high-frequency trading systems, require extremely low latency.

These challenges mean that blindly accepting AI-generated code without rigorous review is a recipe for disaster. A "good enough" solution isn't acceptable; it needs to be correct.

AI as a Code Assistant, Not a Code Writer

The most effective approach is to view AI not as a replacement for a skilled financial software engineer, but as a powerful assistant. Think of it like this: a seasoned architect doesn't simply tell a construction crew what to build; they provide detailed blueprints and constantly oversee the work. Similarly, you should:

  • Treat AI suggestions as proposals: Don’t just hit “accept” on everything. Carefully review the code, understanding why it works (or doesn't).
  • Focus on complex tasks: AI excels at generating boilerplate code, handling repetitive tasks, and suggesting common patterns. Leverage it for these areas to free up your time for more critical thinking.
  • Use AI for exploration: Ask the AI to explore different approaches to a problem. It can quickly generate prototypes, which you can then refine and optimize.
  • Priming the AI: Provide clear, detailed prompts and context. The better the input, the better the output. For example, instead of "write a function to calculate bond yield", try "Write a Python function to calculate the yield to maturity of a semi-annual coupon bond, considering accrued interest and taking date inputs in YYYY-MM-DD format. Include error handling for invalid date formats."

Specific Techniques for Improving Finance Code with AI

Here are some practical ways to integrate AI into your finance coding workflow, prioritizing quality over speed.

1. Enhanced Code Review

AI can significantly improve your code review process.

  • Automated Static Analysis: Tools like SonarQube (often integrated into CI/CD pipelines) combined with AI-powered analysis can flag potential bugs, security vulnerabilities, and code style violations.
  • AI-Driven Code Comparison: Paste the original code and the AI-generated version into a tool like Diffchecker and ask the AI (using a separate prompt) to identify the key differences and potential risks. "Analyze these code differences. What are the potential impacts on performance, security, and accuracy in a financial calculation context?"
  • Focus on Business Logic: Let the AI handle the low-level code checks so you can focus on verifying the correctness of the financial models and algorithms.

2. Generating Unit Tests

Robust unit tests are crucial for financial software. AI can help you write them more efficiently.

  • Test Case Generation: Give the AI a function and ask it to generate a comprehensive set of unit tests, covering edge cases, boundary conditions, and error handling. “Generate Python unit tests using pytest for this function that calculates portfolio Sharpe Ratio. Include tests for empty portfolios, negative returns, and zero standard deviation.”
  • Property-Based Testing: Explore property-based testing frameworks (like Hypothesis in Python) and use AI to help you define the properties your code should satisfy. For instance, “Suggest properties that should always hold true for a function that calculates discounted cash flow.”

3. Documenting Complex Financial Logic

Financial models can be notoriously complex. Clear and concise documentation is vital for maintainability and auditing.

  • Automated Documentation Generation: Use AI to generate docstrings and comments explaining the purpose of each function, variable, and section of code.
  • Explain Complex Code: Paste a particularly challenging section of code into the AI and ask it to explain it in plain English, including the underlying financial concepts.
  • Generating API Documentation: AI can help create documentation for APIs used to expose financial data or services. This documentation should detail input parameters, output formats, and error codes.

4. Refactoring Legacy Code

Many financial institutions rely on older systems written in languages like COBOL or FORTRAN. Refactoring this code can be risky and time-consuming.

  • Code Translation: AI can assist in translating code from one language to another (e.g., COBOL to Python). However, thorough testing is essential after translation.
  • Code Modernization: AI can suggest ways to modernize legacy code, improving its readability, maintainability, and performance.
  • Identifying Technical Debt: AI can help identify areas of code that are particularly complex or fragile, highlighting potential areas for refactoring.

Tools and Resources

Here are some tools that can help you leverage AI in your finance coding workflow:

  • GitHub Copilot: A widely popular AI pair programmer.
  • Tabnine: Another AI code completion and generation tool.
  • Amazon CodeWhisperer: AWS's AI coding companion.
  • ChatGPT/GPT-4: Powerful large language models that can assist with code generation, documentation, and explanation.
  • Sourcegraph Cody: An AI coding assistant designed for understanding and modifying large codebases.
  • SonarQube: A leading platform for continuous code quality and security analysis.

A Word of Caution: AI Doesn’t Understand Finance

This is the most important point. AI models are trained on vast amounts of data, but they don't understand the nuances of financial theory, regulations, or risk management. They can generate syntactically correct code that is logically flawed from a financial perspective.

  • Always verify financial calculations: Double-check every formula, algorithm, and financial model generated by AI.
  • Be skeptical of "black box" solutions: If the AI generates code that you don’t fully understand, don’t use it.
  • Consider regulatory implications: Ensure that all AI-generated code complies with relevant regulations.
  • Human oversight is essential: AI should augment your expertise, not replace it.

The Path Forward: Responsible AI in Finance

The future of finance software development will undoubtedly involve AI. However, the key to success lies in using these tools responsibly and strategically. By prioritizing code quality, risk management, and human oversight, you can harness the power of AI to build more robust, reliable, and secure financial systems. Don't rush the process. Slow down, review carefully, and remember that accuracy is paramount. A slower, more deliberate approach will ultimately yield better results – and avoid costly mistakes.

Disclaimer

This article contains affiliate links. If you purchase products or services through these links, we may receive a commission at no extra cost to you. This helps support our website and allows us to continue providing valuable content. We only recommend products and services that we believe are beneficial to our readers. We are not financial advisors and this content is for informational purposes only. Always conduct your own research and consult with a qualified professional before making any financial decisions.

Pass it onX·LinkedIn·Reddit·Email
The Sunday note

If this was your kind of read.

Sign up for the morning email — short, hand-written, and sent only when there's something worth your time.

Free, sent from a person, not a system. Unsubscribe in one click whenever.

Keep reading

The archive →