SpotWise, a new open-source tool submitted for the Hacktoberfest Open-Source AI Challenge Week 2, tackles a specific pain point for long-term savers: the inability to reliably backtest precious metal investment strategies without trusting an LLM to do the math. Built by developer Abdullah, the application allows users to research and paper-trade gold, silver, and platinum using real price history, specifically targeting users in India and the Gulf who buy gold monthly. The core architectural decision here is one every finance developer should note: the AI is strictly confined to natural language processing, while all arithmetic is handled by deterministic Python code.

The Architecture of Trust

The application’s backend is built on FastAPI with modular, pure functions for price conversion and backtesting. The frontend utilizes React and TradingView Lightweight Charts, while data is sourced from metals.dev and stored in Neon Postgres. The standout feature is the 'Ask SpotWise' interface, which translates plain English plansβ€”such as "buy double when 5% below average"β€”into structured JSON requests. Crucially, the model never calculates the result. Instead, plain code executes the backtest, and the LLM merely generates a summary from a predefined list of facts. A validation function, numbers_ok(), ensures that every number in the AI's output matches the code’s calculation; if there is a mismatch, the system defaults to template text. This design means the app remains fully functional even without an LLM connected, relying on a rule-based parser.

Practical Implications for Devs

This approach solves the hallucination problem in financial tools while maintaining a low barrier to entry for hosting. Because the AI only handles text-to-JSON conversion and simple summarization, a small, self-hosted open-weight model is sufficient. The developer notes that this architecture eliminates per-query AI fees and data privacy concerns for potential commercial users, such as bullion dealers who need a price-research widget for their customers. The system respects effective-dated tax profiles for GST and VAT, ensuring that historical backtests use the tax rates that actually applied at the time, rather than current rates.

Key Takeaways

  • Deterministic Math: SpotWise enforces a strict separation of concerns where the LLM interprets intent but never performs arithmetic, using Pydantic to bound-check outputs.
  • Graceful Degradation: The application works end-to-end without an LLM, using a rule-based parser, making it viable for environments where API costs or latency are prohibitive.
  • Data Integrity: Price history is validated for gaps and anomalies, and tax calculations use effective-dated profiles to ensure historical accuracy.
  • Open Innovation: The MIT-licensed code allows for self-hosting with any OpenAI-compatible server (llama.cpp, vLLM, Ollama), preventing vendor lock-in.

The Bottom Line

SpotWise is a masterclass in pragmatic AI integration for finance; by refusing to let the model do the math, the developer has built a tool that is both trustworthy and cost-effective, proving that the best AI features are often the ones that know when to shut up and let the code speak.

Technical Notes

The demo is currently hosted on Render's free tier, meaning initial load times may be slow due to cold starts. The repository does not contain the dataset or API keys, requiring users to configure their own SPOTWISE_LLM_URL and SPOTWISE_LLM_MODEL environment variables to enable the generative explanation features. For those looking to replicate this pattern, the use of response_format: json_schema combined with post-generation validation is a robust pattern for any financial application integrating LLMs.