Skip to content
SujitSparkPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PriceWar: Platform Pricing Intelligence & Strategic Equilibrium Suite

Enterprise Decision Intelligence for Food Delivery Platform Duopolies (Swiggy vs Zomato)
Version: 1.0.0 Production Release


πŸ“Œ Executive Summary & Market Thesis

In India's hyper-competitive on-demand food delivery landscape, Swiggy (Platform A) and Zomato (Platform B) operate as an entrenched duopoly controlling over 95% of aggregate gross merchandise value (GMV). In high-density urban zones, pricing decisionsβ€”including consumer delivery fees, merchant commission take-rates, promotional fee discounts, and fleet surge allocationsβ€”are deeply interdependent.

A platform that unilaterally cuts consumer delivery fees triggers retaliatory discounting from its rival, collapsing margins across the entire ecosystem. Conversely, excessive fee markups risk market-share migration and merchant churn.

PriceWar is an enterprise-grade quantitative pricing and strategic intelligence platform. It fuses structural econometric demand calibration with non-cooperative and cooperative game theory, empowering marketplace leadership, revenue management, and strategy executives to:

  1. Model Strategic Price Interdependence: Compute pure and mixed Nash equilibria across discrete pricing actions and identify sub-optimal price war traps.
  2. Predict Competitive Price Reactions: Derive analytical best-response functions under differentiated Bertrand price competition and capacity-constrained Cournot fleet deployments.
  3. Analyze Long-Horizon Collusion Risks: Measure the stability of tacit high-fee cooperation over repeated interactions using Folk Theorem critical discount thresholds ($\delta^*$).
  4. Solve Asymmetric Cost Uncertainty: Formulate Bayesian Nash Equilibria (BNE) when competitor logistics routing and dispatch costs are private and unobservable.
  5. Stress-Test Regulatory & Macro Shocks: Simulate marketplace disruption from open networks (ONDC), festive/IPL surge demand, and government commission caps.
  6. Optimize Two-Sided Merchant Commissions: Maximize platform take-rate revenue subject to restaurant Individual Rationality (IR) participation constraints.

πŸ› οΈ Production Technology Stack

Layer Architecture & Technology Description
Backend API Engine Python 3.11+, FastAPI, Uvicorn (ASGI) Asynchronous, sub-40ms execution, type-safe via Pydantic v2
Algorithmic Math Core nashpy, numpy, scipy Support enumeration, bimatrix solvers, and numerical optimization
Econometric Pipeline pandas, scikit-learn, joblib Structural OLS and Logit market-share model fitting, point elasticity
Frontend Dashboard React 18, TypeScript, Vite, Tailwind CSS Modular component architecture, glassmorphic dark theme
Data Visualization Recharts Responsive Analytics Multi-series reaction curves, fee distributions, trajectory timeseries
State & Networking TanStack React Query v5, Axios Declarative caching, optimistic mutations, and background polling
Automated Testing pytest, httpx (14 automated suites) Validated against known Prisoner's Dilemma, Matching Pennies, and closed forms

πŸ“‚ System Architecture & File Structure

pricewar/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py              # FastAPI production app, CORS, and router registration
β”‚   β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”‚   β”œβ”€β”€ config.py        # Cost benchmarks, commission take-rates, strategy sets
β”‚   β”‚   β”‚   β”œβ”€β”€ demand.py        # Econometric cleaner, feature engineering, Linear & Logit models
β”‚   β”‚   β”‚   β”œβ”€β”€ payoffs.py       # N x M bimatrix engine & unit margin profit calculators
β”‚   β”‚   β”‚   β”œβ”€β”€ equilibrium.py   # Pure & Mixed NE (Nashpy), IESDS, Bertrand & Cournot solvers
β”‚   β”‚   β”‚   β”œβ”€β”€ repeated.py      # Multi-period dynamic supergames, Folk theorem Ξ΄*, tournament
β”‚   β”‚   β”‚   β”œβ”€β”€ bayesian.py      # Bayesian game solver (unknown rival cost) & belief sweeps
β”‚   β”‚   β”‚   β”œβ”€β”€ scenarios.py     # ONDC 3-player, festival surge, commission cap shock models
β”‚   β”‚   β”‚   └── commission.py    # Merchant mechanism design & IR constraint optimization
β”‚   β”‚   └── routers/             # demand, oneshot, bertrand, repeated, bayesian, scenarios, commission
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”œβ”€β”€ delivery_orders.csv  # Empirical order records (N=1,500)
β”‚   β”‚   └── fitted_demand_model.joblib # Serialized model pipeline
β”‚   β”œβ”€β”€ tests/
β”‚   β”‚   β”œβ”€β”€ test_game_theory.py  # Algorithmic game theory and mathematical proof tests
β”‚   β”‚   └── test_api.py          # FastAPI endpoint integration tests
β”‚   └── requirements.txt
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api.ts               # Typed Axios client & REST response schemas
β”‚   β”‚   β”œβ”€β”€ components/          # PayoffMatrix, SliderPanel, EquilibriumCard, Navbar
β”‚   β”‚   β”œβ”€β”€ pages/               # ExecutiveSummary, DemandElasticity, OneShot, BertrandCournot, Repeated, Bayesian, ScenarioLab, CommissionDesign, EconomicFrameworks
β”‚   β”‚   β”œβ”€β”€ App.tsx              # Root application layout & React Query provider
β”‚   β”‚   └── index.css            # Tailwind styling, brand palettes, and glassmorphism
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ vite.config.ts
β”‚   └── tailwind.config.js
└── README.md

🧭 Strategic Decision Engines & Capabilities

1. Econometric Demand & Elasticity Analytics

  • Empirical Calibration: Calibrates customer order volume against consumer delivery fee ($P_i$), rival delivery fee ($P_j$), and promotional subsidies ($\text{Disc}_i$): $$Q_i = a - b \cdot P_i + c \cdot P_j + d \cdot \text{Disc}_i$$
  • Demand Sensitivity Parameters: Extracts structural coefficients for baseline volume ($a$), own-fee price sensitivity ($b$), competitor price substitution ($c$), and discount promotion lift ($d$).
  • Point Price Elasticity Spectrum: Evaluates elasticity across the β‚Ή10–₹60 fee spectrum, quantifying own-price elasticity ($\epsilon \approx -1.24$) and cross-price substitution ($\eta \approx +0.82$).

2. Simultaneous Pricing Matrix & Nash Equilibrium

  • Unit Margin Formulation: $$\text{Margin}_i = P_i + (\text{Commission Rate} \times \text{GMV}) - \text{Rider Cost} - \text{Discount}_i$$ $$\Pi_i = \text{Margin}_i \times Q_i(P_i, P_j)$$
  • Equilibrium Solvers: Identifies Pure Strategy Nash Equilibria (mutual best responses), Mixed Strategy Nash Equilibria via Nashpy support enumeration, and Iterated Elimination of Strictly Dominated Strategies (IESDS).
  • Price War Trap Diagnosis: Demonstrates why non-cooperative discounting traps both platforms in a low-profit equilibrium despite mutual high-fee profitability.

3. Continuous Oligopoly (Bertrand vs Cournot)

  • Differentiated Bertrand: Solves simultaneous reaction functions $P_1(P_2)$ and $P_2(P_1)$, identifying the competitive Nash fee $P^* = \frac{a + b \cdot mc}{2b - c}$ and comparing against the joint monopoly cartel fee $P_M$.
  • Fleet Allocation Cournot: Models capacity allocation of delivery rider slots under inverse demand $P(Q_1 + Q_2) = \alpha - \beta(Q_1 + Q_2)$.
  • Reaction Function Visualization: Interactive curves marking the unique stable equilibrium intersection.

4. Dynamic Supergames & Collusion Stability

  • Repeated Game Engine: Simulates dynamic supergames over configurable horizons ($N$ rounds) discounted by patience factor $\delta \in [0, 0.99]$.
  • Strategy Arsenal: Always Cooperate, Always Defect, Grim Trigger, Tit-for-Tat, Pavlov (WSLS), Random, and an adaptive Tabular Q-Learning Agent.
  • Folk Theorem Enforcement: Computes the exact critical threshold: $$\delta^* = \frac{\pi_{defect} - \pi_{collude}}{\pi_{defect} - \pi_{punish}}$$
  • One-Deviation Property Validation: Verifies whether a single-period defection followed by perpetual punishment is subgame perfect (SPE).
  • Strategy Tournament: Round-robin league simulation ranking strategies by cumulative discounted profit.

5. Asymmetric Information & Cost Estimation

  • Bayesian Nash Equilibrium: Formulates strategic pricing when rival operational delivery costs are private: $$c_B \in {c_L, c_H} \quad \text{with prior belief} \quad P(c_L) = p$$
  • Closed-Form BNE Solver: Solves uninformed price $P_A^$ for Swiggy and type-contingent prices $(P_B^(L), P_B^*(H))$ for Zomato.
  • Belief Sensitivity Curves: Visualizes how Swiggy's optimal fee systematically adjusts downward as the rival's likelihood of low-cost efficiency increases.

6. Macro Scenario Lab & Policy Stress Testing

  • ONDC Entry (3-Player Game): Evaluates incumbent fee compression when an open unbundled network enters at β‚Ή15 delivery.
  • Festive / IPL Surge Multiplier: Models intercept demand expansion and profit capture during peak consumption events.
  • Regulatory Commission Caps: Evaluates economic incidence when restaurant commissions are capped (e.g., from 20% to 12%), demonstrating fee pass-through to consumers.
  • Welfare Decomposition: Side-by-side analysis of Consumer Surplus vs. Platform Operating Profits.

7. Two-Sided Merchant Commission Optimization

  • Mechanism Design: Optimizes platform take-rate $r \in [5%, 35%]$ subject to each merchant's Individual Rationality (IR) participation constraint: $$\Pi_{restaurant}(r) \ge \bar{U}_{offline} \quad (\text{Reservation Walk-in Profit})$$
  • Revenue Maximization: Identifies the profit-maximizing commission rate (~21%) and the critical churn threshold (~28%).

πŸ“ˆ Strategic Decision & Mathematical Solution Matrix

Strategic Business Challenge Marketplace Context Quantitative & Algorithmic Solution
Demand Interdependence Consumer delivery volume depends simultaneously on rival platform delivery fees and promotions. Structural OLS and Logit econometric estimation; elasticity spectrum across price tiers.
Competitive Undercutting Aggressive discounting leads to margin-destructive price wars. Bimatrix Normal Form game; Pure & Mixed Nash Equilibria via Nashpy; IESDS dominance pruning.
Continuous Price Setting Platforms choose continuous delivery fees with platform brand loyalty. Differentiated Bertrand best-response equations; analytical Nash vs Cartel comparison.
Fleet Capacity Scarcity Competing for a finite pool of delivery riders during peak hours. Continuous Cournot capacity game allocating rider slots.
Collusion Enforcement Sustaining profitable delivery fees without contractual agreements. Repeated supergames with Folk Theorem $\delta^*$ calculation and One-Deviation SPE validation.
Private Cost Asymmetry Rival logistics efficiency and route optimization capabilities are unobservable. Bayesian Game with subjective prior distributions; closed-form Bayesian Nash Equilibrium.
Merchant Delisting Risk High platform commissions trigger restaurant protests and offline migration. Mechanism design subject to Individual Rationality (IR) participation constraints.
Regulatory & Open Net Shocks Government fee caps or open network protocols (ONDC) disrupting market structure. Multi-agent comparative equilibrium analysis & consumer surplus welfare measurement.

πŸš€ Installation & Local Deployment

Prerequisites

  • Python 3.11+
  • Node.js 18+ and npm

1. Backend Service Launch

cd pricewar/backend

# Create and activate virtual environment
python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run automated tests
PYTHONPATH=. pytest tests/ -v

# Launch FastAPI microservice on port 8000
uvicorn app.main:app --host 127.0.0.1 --port 8000

Interactive Swagger documentation is live at: http://127.0.0.1:8000/docs

2. Frontend Dashboard Launch

cd ../frontend

# Install dependencies
npm install

# Start Vite React development server
npm run dev

Access the enterprise dashboard at: http://localhost:5173


πŸ“Š Summary of Strategic Findings

  1. Non-Cooperative Pricing Trap: Unilateral incentives to capture short-term order share drive fees down to marginal cost plus baseline margin, confirming a classic Prisoner's Dilemma structure.
  2. Collusion Sustainability ($\delta^ \approx 0.42$):* Tacit high-fee pricing (β‚Ή45) can be sustained indefinitely if both platforms maintain discount factors $\delta \ge 0.42$. Below this threshold, immediate defection gains exceed future punishment losses.
  3. Information Asymmetry Shaves Markups: When Swiggy is uncertain about Zomato's routing costs, Swiggy is forced to price conservatively, transferring surplus to price-sensitive consumers.
  4. Regulatory Incidence: Capping restaurant commissions from 20% to 12% causes platforms to pass through ~65% of the lost margin to consumers via higher delivery fees.
  5. Merchant Commission Sweet Spot: The revenue-maximizing commission take-rate is ~21%. Above 28%, restaurant margins breach their reservation utility, triggering merchant churn.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages