The Chronicle of Aurum AI
From a Kitchen Table Dilemma to Institutional Bullion Intelligence, Spoken Hindi Voice Engineering, and the Physical Friction Invariant
PrologueThe Kitchen Table Dilemma: Why My Mother Distrusted Finance Apps
The genesis of Aurum AI was not conceived in an air-conditioned corporate venture incubator or a speculative quantitative trading desk. It began in October 2024 at my family’s kitchen table in India.
My mother was planning a customary purchase of standard 22K jewelry for an upcoming family wedding and Diwali festivities. Like tens of millions of Indian households, gold and silver are not mere speculative tickers; they represent familial security, cultural pride, and generations of disciplined savings. Yet, watching her attempt to discover what gold was actually trading for that morning revealed a deeply broken user experience:
“Every finance app wants me to download a complex trading terminal, bombard me with push notifications yelling ‘BUY NOW! MEGA RALLY!’, or throw candlestick charts and spot COMEX dollars per ounce that mean nothing to my jeweler down the street. All I want to know is: how much is 10 grams today, what did it cost last week, and is today’s rate reasonable—explained simply in Hindi?”
When I investigated popular AI conversational chatbots, the situation proved even more perilous. Large Language Models (LLMs) routinely hallucinated arithmetic: they converted troy ounces using incorrect ratios, omitted the 15% Indian Customs Import Duty, skipped the 3% precious metals GST, and worse still—they offered reckless directional advice: “Gold looks strong today, you should definitely buy before prices surge!”
If a mother acts on such confident hallucination with hard-earned savings, the financial consequences are severe. That morning, I made a solemn engineering pledge: I would build Aurum AI—a companion engineered with institutional mathematical precision, spoken natively in warm Hindi, and bound by immutable invariants never to dispense directive financial advice.
Chapter IThe Non-Directive Core: Engineering Financial Invariants
From day one, the foundational architectural decision was the total decoupling of financial calculation from linguistic synthesis. In traditional AI bots, developers naively prompt an LLM to “calculate the price and tell the user if it is a good time to buy.” In Aurum AI, this is strictly forbidden by design.
The Three Sacred System Invariants:
- RULE-001 (Deterministic Arithmetic): The LLM is never permitted to perform multiplication, division, currency conversion, or moving average calculations. Every rupee figure originates from verified backend Python and TypeScript micro-engines.
- RULE-002 & RULE-016 (Gated Directional Bias): The system is programmatically forbidden from predicting directional price movement unless an econometric model passes rigorous walk-forward out-of-sample backtesting. If the model cannot prove an edge over a random walk, the database schema forces
trend_signal_validated = FALSE. - RULE-003 (Zero Buy/Sell Directives): Under no circumstances may the companion say “buy”, “sell”, “invest”, or “enter position”. It speaks strictly in factual relative comparisons: “Aaj ka bhav pichle pandrah din ke average se ₹450 kam chal raha hai.”
Chapter IIThe Physics of Indian Bullion: Deriving the 1.18× Landed Multiplier
To deliver figures that mirror what local Indian jewelers charge, we had to model the exact physical supply chain mechanics of precious metal importation into India. Global markets quote gold in US Dollars per troy ounce (31.1034768 grams). Domestic retail markets quote gold in Indian Rupees per 10 grams.
The Statutory Indian Landed Pricing Formula:
USD per Gram = Spot USD / 31.1034768
Base INR (10g) = (USD per Gram × 10) × Live USD/INR Exchange Rate
Landed Price = Base INR × (1 + Customs Duty + GST)
= Base INR × (1 + 0.15 + 0.03)
= Base INR × 1.18Where effective Customs Duty is 15% (10% Basic Customs Duty + 5% Agriculture Infrastructure & Development Cess - AIDC) and physical precious metals Goods & Services Tax (GST) is 3%.
For 22K jewelry gold (the 916 hallmark standard), the formula deterministically applies the statutory purity fraction:
Price_22K = Price_24K × (22 / 24) ≈ Price_24K × 0.91667
Every hourly ingestion run computes these exact landed figures and derives three distinct moving averages: MA7 (weekly pace), MA15 (bi-weekly alert trigger baseline), and MA30 (monthly anchor).
Chapter IIIThe Serverless Paradox: Building Zero-Cost High Availability
A major engineering constraint was RULE-007: Strictly Zero-Cost / Free-Tier Infrastructure. Most developers deploy heavy containerized servers (Docker/Kubernetes) on AWS EC2 or DigitalOcean, running continuous background Celery workers and accumulating substantial monthly cloud bills.
However, Vercel’s serverless architecture shuts down functions within seconds of answering an HTTP request. It cannot sustain long-running cron jobs or stateful alert listeners on the Hobby tier.
To solve this, I designed a Dual-Lifecycle Asynchronous Architecture:
- Lifecycle A (Ingestion & Alerts): Executes on GitHub Actions runners every 60 minutes. It pulls live quotes from global markets, executes the landed tax formulas, computes moving averages, checks price alert triggers, and writes parameterized records to Supabase PostgreSQL. Total infrastructure cost: $0.00.
- Lifecycle B (Interactive Voice Gateway): Runs on Vercel App Router. Telegram webhooks are received at
/api/telegram/webhook, verified with a high-entropy secret token in constant time, and acknowledged with an instant200 OKwithin 80 milliseconds. The heavy agent reasoning and audio generation are scheduled asynchronously via Next.jsafter(), preventing Telegram gateway timeouts. Total cost: $0.00.
Chapter IVCultural Voice Engineering: Edge-TTS, FFmpeg & The Opus Waveform
A text message is easily ignored; a spoken voice note from a companion feels personal and accessible to elders who may not wish to squint at tiny mobile screen fonts.
Yet, generating voice in Indian Hindi presents unique technical hurdles. Off-the-shelf TTS engines often mispronounce cultural currency denominations (e.g., pronouncing “₹1,57,084” as literal English digits rather than “Ek laakh sattaawan hazaar chaurasi rupaye”).
We solved this by pairing Microsoft Azure Edge-TTS neural synthesis (hi-IN-SwaraNeural) with custom phonetic normalization rules in TypeScript. But generating an MP3 is insufficient: when an MP3 is uploaded to Telegram, it appears as an awkward file attachment that requires external media players.
To render as a native Telegram circular voice note with a live interactive audio waveform, the audio must be transcoded using FFmpeg libopus into an OGG container with a single audio channel (Mono) at 48,000 Hz:
ffmpeg -y -i input.mp3 -c:a libopus -b:a 32k -vbr on -ar 48000 -ac 1 output.ogg
Furthermore, under RULE-021, the pipeline implements an ephemeral filesystem protocol: the moment Telegram’s sendVoice API confirms receipt, the temporary audio files are securely wiped from disk, preserving zero audio footprints.
Chapter VThe 782-Day Econometric Campaign: Confronting Non-Stationarity & Fat Tails
In Phase 9, we embarked on an ambitious data engineering campaign to determine whether machine learning could forecast next-day gold price direction. We mined 782 continuous trading days across five interconnected global markets:
| Asset Class | Market Symbol | Economic Rationale |
|---|---|---|
| Gold Futures | GC=F (COMEX) | Primary safe-haven bullion asset |
| Silver Futures | SI=F (COMEX) | Dual monetary and industrial demand |
| WTI Crude Oil | CL=F (NYMEX) | Global inflation expectations proxy |
| Nifty 50 Index | ^NSEI (NSE) | Domestic equity risk appetite & wealth effect |
| USD / INR | INR=X (FX) | Direct landed import currency transmission |
From these 782 trading days, we synthesized a high-dimensional 38-factor quantitative matrix containing momentum indicators, volatility metrics, moving average ratios, and cross-asset return spreads.
However, when we subjected the series to econometric profiling, classical assumptions of normality shattered:
- Augmented Dickey-Fuller (ADF) Test on Raw Prices: Produced a test statistic of $-0.32$ and a $p$-value of 0.9705. The raw price series is emphatically non-stationary and exhibits a random walk with drift.
- ADF on Differenced Returns: Produced a test statistic of $-8.41$ and a $p$-value of $1.02 \times 10^-13$, proving stationarity only after first-differencing.
- Excess Kurtosis (Fat Tails): Gold returns yielded an excess kurtosis of 8.04 (far exceeding the normal distribution threshold of 3.0), mathematically proving that extreme multi-sigma volatility spikes occur far more frequently than naive Gaussian models predict.
Chapter VIThe Physical Friction Invariant: Why Our Strategy Yielded a -4.63 Sharpe Ratio
This chapter represents the intellectual heart of Aurum AI’s engineering integrity. Many amateur algorithmic traders publish flashy backtests boasting “65% predictive accuracy” and “massive profits.” Almost invariably, these backtests suffer from lookahead bias and ignore real-world physical friction.
We built four distinct walk-forward machine learning models: Regularized Logistic Regression ($L_2$), Random Forest (100 trees), HistGradientBoosting, and an MA-crossover baseline.
On synthetic gross paper trading, the gradient boosting model achieved a modest out-of-sample directional accuracy of $53.4\% \pm 2.8\%$ with a raw gross return of $+4.2\%$. An unprincipled developer would have rushed this model into production, claiming an “AI edge.”
Instead, we enforced RULE-026 (Physical Bullion Friction Invariant):
In the real world, an Indian family cannot buy and sell physical bullion at paper COMEX spot prices without cost. Every transaction incurs:
• 3.0% Non-Refundable Physical GST
• 1.0% Retail Jeweler Bid-Ask Spread
• 0.2% Execution Slippage & Assaying Costs
When we subjected the model’s signals to an out-of-sample walk-forward test incorporating these real-world frictions, the results were devastating:
| Performance Metric | Paper (Frictionless) | Real Bullion Friction (RULE-026) |
|---|---|---|
| Total Cumulative Return | +4.2% | -11.8% (Net Loss) |
| Annualized Sharpe Ratio | +0.41 | -4.63 (Severe Negative) |
| Maximum Drawdown | -6.8% | -14.2% |
| Calmar Ratio | +0.62 | -0.83 |
| Brier Probability Score | 0.248 | 0.231 (Slight calibration, zero edge) |
The conclusion was undeniable: short-term algorithmic trading in physical retail bullion is a guaranteed method of wealth destruction due to tax and dealer friction.
In adherence to engineering ethics, we codified this finding as a permanent badge of honour: trend_signal_validated remains strictly locked to FALSE in our production database, and Aurum AI proudly informs users that market timing is unviable.
Chapter VIIThe Red Team Privacy & Security Audit
Because Aurum AI is built for personal and family utility, privacy and operational security (OPSEC) are paramount. In Phase 11, we executed a rigorous Red Team security assessment to identify and patch every conceivable attack vector:
- Exif Metadata Neutralization: We inspected all client screenshots uploaded to the repository, discovering GPS location metadata, device serials, and camera sensor fingerprints. We ran an automated scrubbing pipeline using Python Pillow, stripping 100% of EXIF, GPS, and device tags before committing.
- CWE-208 Timing Attack Defense: Standard string comparison (
token === expectedToken) leaks execution timing information byte-by-byte. We replaced all webhook and cron authentications with Node.jscrypto.timingSafeEqual(), ensuring constant-time evaluation. - Memory Flooding & DoS Mitigation (CWE-400): To prevent malicious actors from exhausting server memory by generating millions of fake user IDs, we implemented an LRU eviction cap restricting our in-memory sliding window rate limiter to a maximum of 5,000 active tracking buckets.
- Indirect Prompt Injection Guard (RULE-022): All user inputs passed to the Gemini Flash agent are strictly encapsulated inside
<user_query>XML tags, and the system prompt treats input strictly as unstructured data rather than system commands.