Inspiration Hormonal fluctuations during the menstrual cycle create unpredictable, volatile spikes in macronutrient demand. When cravings hit, rational budgeting goes out the window, and people execute highly inefficient, emotional trades, usually overpaying for junk food at the nearest convenience store. We looked at this biological volatility and asked: What if we treated a sugar craving like a Wall Street margin call? CravingCapital was born to bring ruthless, high-frequency quantitative arbitrage to the junk food market.

What it does CravingCapital is a dynamic algorithmic trading engine for your grocery run.

Biological Profiling: Users input their current cycle day, cycle length, and stress level (Cortisol Alpha). The engine calculates their exact hormonal volatility and outputs minimum sugar and fat "demands."

Cross-Store Arbitrage: The engine scans real-time pricing data across local Durham supermarkets (Aldi, Tesco, Lidl, Sainsbury's) to find the widest price spreads (£/100g).

Portfolio Optimization: Using a Linear Programming solver, the app calculates the mathematically optimal basket of junk food. It maximizes the total volume of snacks while strictly adhering to the user's "Liquidity Limit" (budget) and biological constraints.

Delta-Neutral Hedging: To prevent "flavor fatigue," the algorithm calculates the sugar-to-fat ratio of every item, classifying sweet snacks as Equities and savory snacks as Bonds, forcing a balanced portfolio.

How I built it Frontend: I built a highly responsive React interface featuring a custom Candlestick chart (using Recharts) to visualize the COSI (Cross-Store Arbitrage Index), where the wick height represents the price spread between the worst and best stores.

Backend: A robust Python/FastAPI server handles the heavy lifting, ensuring seamless communication between the UI and the math engine.

The Quant Engine: I utilized PuLP (a Python Linear Programming library) to build the core optimization matrix.

Data Pipeline: I scraped real nutritional and pricing data from local Durham supermarkets, cleaning and flattening nested JSON structures to feed the math engine.

AI Integration: We integrated the Groq API to power our "girly Wolf of Wall Street" chatbot, providing hyper-personalized financial advice based on the user's real-time biological state.

Challenges I Ran Into : I ran into the classic algorithmic trap: the math was too efficient. Initially, our solver was instructed to minimize Capital Expenditure. When given an £18 budget, the algorithm found a way to hit the biological sugar/fat targets for just £3.99 and immediately stopped buying snacks. I had to completely rewrite the objective function at 4:00 AM to Maximize Satisfaction (item volume) while staying under the liquidity cap. I also battled nested JSON key mismatches, CORS middleware blocks, and the dreaded 500 Internal Server errors when connecting our React sliders to the Python backend.

Accomplishments that I’m proud of : I successfully wired a complex mathematical LP solver to a beautiful, consumer-facing React frontend. Watching the terminal print out a live, cross-store junk food receipt—routing the user to specific Aldi and Lidl branches to save 90p on an Oreo alternative—was an incredible feeling. I am also incredibly proud of the UI/UX, specifically the live debounce sliders that dynamically fetch algorithmic data without crashing the server.

What I learned I learned how to translate abstract physical realities into strict mathematical constraints. I also learned that an algorithm is only as good as its objective function, and that minimizing cost isn't always the right product choice for the end-user. I also got a masterclass in full-stack debugging: tracing a missing React state variable all the way down to a failed Python matrix execution.

What's next for CravingCapital Routing Latency & Slippage Penalties: Integrating the Google Maps API so the algorithm factors in the physical caloric burn and time (latency) required to walk between different stores.

Prime Broker Execution: Integrating with UberEats or Deliveroo APIs to automatically dispatch couriers to execute the cross-store arbitrage for the user.

Live Options Market: Predictive modeling to buy chocolate futures before the luteal phase begins.

The Stack : Frontend: React, Recharts (for the custom COSI candlestick chart), CSS (glassmorphism UI)

Backend & API: Python, FastAPI, Uvicorn, Pydantic (data validation)

Quant & Math Engine: PuLP (Python Linear Programming solver for the arbitrage matrix)

AI Integration: Groq API (Llama-3.1-8b-instant for the sassy financial assistant)

Data Pipeline: Python Web Scraping (scraper.py), JSON data structuring (market_data_enriched.json)

Built With

Share this project:

Updates