God Doesn't Play Dice with the Universe - You Shouldn't with Your Life Savings
How to use AI for financial analysis without falling into the blackbox trap
(Estimated read time: 8-10 minutes)
Try this cool demo I made using Claude Artifacts
My friend uploaded his stock portfolio to an AI and asked for analysis. When he discovered the AI was making up data—fake companies, fictional returns—he spent hours tweaking prompts until he got professional-looking graphs and insights. Now he's convinced he's solved the problem.
Whether he's actually solved it or not, millions are about to face the same challenge.
Zerodha just launched Model Context Protocol (MCP)—connecting AI directly to real trading accounts. (See note 1 on safety of MCP)
Now millions can ask AI (LLMs like Claude, ChatGPT, or Gemini) to analyze their actual portfolios and make real trades. What happened to my friend is about to happen at massive scale.
Why This Matters Now
As Zerodha's CEO Nitin Kamath announced, you can now "connect your Zerodha account to an AI assistant like Claude and do a variety of things like get portfolio insights, plan trades, backtest strategies, build personal finance dashboards, and much more."
To his credit, in the same post, he highlighted questions raised by his teammate Kailash:
"It concentrates decision-making and mediation in the hands of AI blackboxes."
"What about errors and failures with real-world implications?"
"How would those be debugged and traced?"
"How would accountability be established?"
The stakes just changed. When AI can access your real money, the difference between reliable analysis and convincing fiction becomes the difference between growing wealth and losing it.
The Core Problem
AI making up data isn't a bug—it's how LLMs work. They predict what analysis should look like rather than computing actual results. Even reasoning models that excel at math and code are still pattern-matching systems, not calculators.
The problems compound:
Hallucination: AI creates convincing but fictional data
Inconsistency: Same question, different answers every time
Invisible methodology: No way to verify calculations or spot errors
Expertise gap: Without domain knowledge and meticulous review of data and analysis steps, sophisticated outputs seem legitimate
AI sometimes fails at basic math—like confusing which number is bigger. If it can't handle simple comparisons reliably, how can we trust complex financial calculations?
A Much Better Approach—Though Still Imperfect
Don't ask AI to analyze your data. Ask AI to write code that analyzes your data—one step at a time.
Instead of: "Analyze my portfolio and recommend trades"
Do this: Start with "Write Python code to load and examine my portfolio data." Then ask it to explain what the code does. Once that works, move to the next step: "Now write code to calculate basic performance metrics." Test every piece before moving forward. (For another approach see note 2)
Let AI write analysis code using proven code/math libraries
Ask AI to explain the logic in plain English
Test with known data first to validate accuracy
Execute on platforms like Google Colab, Jupyter notebooks, or coding environments like Cursor
Get domain expert review of the overall approach (if possible)
Meticulously review the logic yourself to understand each step
Create visualizations through interactive dashboards—better data formats help spot issues
This approach might seem technical, but it's more accessible than you think. AI researcher Andrew Ng observes that "Everyone should learn to code with AI! Not just engineers." When it comes to your analysis, you don't need to be a coder—you just need to be willing to understand what the AI is building for you.**
Why this works better: Instead of trusting AI's direct analysis (which you can't verify), you're trusting code logic combined with AI explanations of that logic. Code can be wrong, but you can see it, understand it, and fix it. If you don't understand the code, ask AI to explain it in plain English—or even like you're 5 years old.
This breaks the blackbox. You get transparency instead of mystery, reproducibility instead of randomness. (See note 4)
How to Spot the Difference
Blackbox approach (dangerous):
AI gives different answers to identical questions
Methodology is opaque and unverifiable
Results look professional but can't be reproduced
Transparent approach (safe):
Same inputs always yield identical outputs
Every calculation step is visible in code
Logic can be examined, understood, and improved
The Bottom Line
Using AI directly for financial analysis puts critical decisions in an unreliable blackbox. Using AI to generate analysis code gives you transparency and reliability.
With AI connecting to real money, we can't afford to gamble with sophisticated guesswork anymore.
What's Next?
Want to learn this approach? Start experimenting—ask AI to write code, then ask it to execute and explain what it does. If you prefer structured learning, deeplearning.ai has excellent short courses for beginners—most are free and high quality. I started there 2.5 years back and have since built 100+ tiny AI tools through hands-on experimentation.
If you're in Pune, join our AI Study Group where we build AI projects every weekend. We share failures and learnings alongside successes - exactly the mindset you need for effective AI use in work and life. Not in Pune? Consider joining or even starting a local study group focused on practically working with AI.
The goal isn't to become a coder or a financial analyst, it's to use AI effectively and understand your tools well enough to trust your decisions.
Note:
1. MCP is new protocol technology that should be used mindfully. Use only official servers from trusted sources like Zerodha, never random third-party implementations. While Zerodha describes their MCP connection as "secure," new protocols inherently carry risks that may not be fully understood yet.
AI researcher Simon Willison warns that MCP servers can suffer from the "lethal trifecta" for prompt injection: access to private data, exposure to malicious instructions, and the ability to exfiltrate information. Attackers can potentially trick AI agents into stealing private data.
2. Why incremental development matters: Smart developers build and test one small piece at a time—it's the only way to catch problems early. When you ask AI to write complex analysis all at once, you don't avoid errors, you just create bigger messes that are nearly impossible to debug. Build incrementally, test with sample data constantly, and you'll spot issues while they're still fixable.
3. Approach 2 (Function/Tool Calling): Use AI systems that can call pre-built code functions where AI interprets your requests but specialized tools do the actual calculations. You get conversational interface without letting AI do the math directly. This is theoretically possible in some platforms like Google AI Studio or certain chatbots, but it's not well-developed or widely accessible at this moment. Most users can focus on Approach 1.
4. About code errors and layered verification: AI-generated code often has syntax errors and logical flaws, but you can see, understand, and fix them. This approach still has risks—AI explanations can be wrong too. But you're layering multiple verification steps: code logic + AI explanation + your review + testing with sample data. Each layer catches different types of errors, making the overall approach much more reliable than direct AI analysis.
When using MCP with Claud, or in environments like Cursor, the principle remains: generate code, don't trust direct analysis.
5: Anticipated FAQs -
"Isn't AI still doing everything?"
AI is still writing the financial logic and explaining what the code does. If AI hallucinates analysis, why wouldn't it hallucinate code logic?
The key differences:
Multiple verification points: You can test code on sample data, ask AI to explain each function separately, modify pieces and see how outputs change
Reproducibility: Same code always produces same output, unlike AI analysis which varies each time
Incrementality: Build piece by piece, catching errors early rather than getting one big wrong answer
Reviewability: Other people (or AIs) can examine the same code logic
The honest answer: You're still trusting AI heavily, but you're creating a framework where AI's mistakes are more likely to be caught and corrected. It's "AI in a verifiable system" vs "AI in a black box"—not perfect, but meaningfully safer.
"Won't this take forever compared to just asking AI directly?"
Initially, yes—it takes longer. But consider what you're trading off: a few extra hours of setup versus potentially losing money on decisions based on fictional data. Once you build working code, you can reuse and modify it for future analysis. More importantly, would you rather spend time building something reliable, or spend time (and money) recovering from bad decisions based on hallucinated analysis?
"This sounds too technical - I'm not a programmer"
You don't need to become a programmer—you need to become someone who understands their tools. Start small: ask AI to write code for simple calculations like "what's my portfolio's total return?" Then ask it to explain each line in plain English. If you don't understand something, ask AI to explain it "like I'm 5." The goal isn't coding mastery—it's tool literacy. You're learning to verify what AI builds for you rather than blindly trusting it.
"What if the AI-generated code has bugs I can't spot?"
This is why you test incrementally with sample data and known results first. Start with simple calculations you can verify manually. If your portfolio has 10 stocks and you know the total value, does the code calculate that correctly? Build complexity gradually. Bugs in transparent code are still easier to catch and fix than errors in black-box analysis.
"Isn't this overkill for basic portfolio tracking?"
For simple tracking, probably yes. Use existing tools like Google Sheets, Portfolio Visualizer, or your broker's dashboard. This approach makes sense when you need custom analysis—complex risk calculations, backtesting strategies, or combining multiple data sources in ways existing tools don't support.
"What platforms should I use to run this code?"
Start with Google Colab (free, runs in browser, no setup). For more control, try coding environments like Cursor. The key is picking something where you can see the code, run it step by step, and modify it easily.
"How do I know if my approach is actually working better?"
Are you catching errors you would have missed before? Do you understand your analysis well enough to explain it to someone else? Can you reproduce your results? These are signs the approach is working.