Crafting experience...
10/26/2025
A Project Made By
Submitted for
Built At
Gator Hack IV
Hosted By
Macroeconomic outcomes depend on complex interactions between consumers, firms, governments, central banks, financial markets and international trade. Existing tools often model these relationships in aggregate, making it hard for students, policymakers and investors to see how specific policy levers (taxes, interest‑rates, spending or tariffs) ripple through the economy.
Moreover, emerging assets such as cryptocurrencies are usually excluded from macro models; yet they respond strongly to inflation, interest‑rate policy and government, specially after US Treasury has decided to hold crypto-currency reserves. There is also an integration of real‑time news analysis into simulations or visual feedback loops for novice users.
To fix the problem, we have made a model, which essentially simulates the entire economy on a global scale, taking into consideration various aspects like policies, inflation rates, interest rates and their impact on GDP and country's debt. It also considers trade wars between countries, tariffs, relationship between stock market and crypto markets to model the economy.
EconoSphere proposes an interactive, agent‑based macroeconomic simulator that addresses the gaps.
Multi‑agent simulation – Models individual consumers, firms, a government, a central bank and foreign sectors (China, EU and Rest of the World) interacting through labor, goods, capital and foreign‑exchange. Users can manipulate fiscal (VAT, payroll and corporate taxes), monetary (interest rates), welfare and spending policies and watch resulting economic indicators such as GDP, unemployment and inflation update in real time.
Financial markets integration – Adds a stock market using P/E‑ratio pricing and a fear‑and‑greed index, and uniquely models cryptocurrency’s responses to inflation, interest‑rate changes and government. This allows users to test hypotheses such as “crypto as an inflation hedge.
International trade module – Extends the base model with import/export flows, tariffs, exchange‑rate dynamics and retaliation tariffs and policies. It captures realistic reactions of trading partners, e.g., foreign tariffs rising gradually in response to domestic tariffs.
AI‑powered news insights – Fetches current economic policy news, categorizes articles (monetary, fiscal, indicators), uses Azure OpenAI to analyze sentiment and expected macro impacts, then suggests simulation parameters. Users can load an article’s policy settings into the simulation with one click. Which enables them to simulate the newest policies in the news or the policies that the government is considering.
By combining simulation, data and AI analysis, EconoSphere makes macroeconomics tangible and allows non‑experts to explore “what‑if” scenarios.
The system is built in Python using Mesa for agent‑based modeling, Azure OpenAI for AI based summarization and NLP tasks, Plotly Dash for the web dashboard.
Key components include (High-level overview of the project):
Dashboard pages – The Dash app provides separate pages for simulation, financial markets, news insights, validation (comparing simulation to real data) and trade. Each page uses Dash callbacks to send user‑input parameters to the backend and display updated charts. dcc.Store objects hold simulation state and dcc.Interval triggers periodic updates.
Simulation engine – The /simulation page runs the BaseEconomyModel, which sequences labour‑market clearing, goods‑market clearing, investment, fiscal and monetary actions and metric calculation.
Extended models such as FinancialMarketsModel and TradeEconomyModel add stock/crypto dynamics and international trade steps. Agent types (consumers, firms, government, central bank, foreign sectors) encapsulate behaviour such as job seeking, production, pricing, investment, policy setting and retaliation.
Data integration – The data layer contains clients for the World Bank API (GDP, unemployment, inflation, tax revenue, government debt), NewsAPI for articles and Azure OpenAI for analysis. Machine‑learning scripts calibrate model parameters to historical data.
Frontend‑backend communication – Dash pages call functions in the simulation classes and data clients. There is no heavy relational database; the system reads calibration JSON and uses in‑memory state. External calls fetch world‑bank and news data and send article text to Azure OpenAI.
Agent | Key State Variables | Behavior |
|---|---|---|
Consumers (Households) | Wealth, income, employment status, employer | Seek jobs when unemployed, accept wages if offered > unemployment benefit; spend a fixed share of wealth on goods and services (consumption function); pay taxes on consumption, labor and corporate income; receive welfare if unemployed and buy goods with remaining income. |
Firms (Producers) | Capital stock, cash, employees, output, price, inventory, labor demand | Decide labor demand based on production function and wages; produce goods using Cobb‑Douglas production; adjust prices in response to excess demand and cost changes; invest when cash is above target; hire/fire workers to meet labor demand and pay wages; pay corporate taxes and distribute dividends. |
Government | Tax revenue, spending budget, public debt, welfare rate | Collect VAT, payroll and corporate taxes; provide welfare payments and public spending; run a budget (tax revenue minus spending) and issue debt; adjust policy levers (tax rates, government spending, welfare) either manually (via dashboard sliders) or through scenario buttons. |
Central Bank | Policy interest rate, inflation target, auto‑mode flag | Sets interest rate manually or automatically via a Taylor rule (increasing rates when inflation exceeds target and output is high); higher rates reduce investment and consumption, lower rates stimulate demand; policy transmits through stock, crypto and trade channels. |
Foreign Sector (each trading partner) | Foreign GDP, foreign price level, exchange rate, import propensity, export elasticity, tariff rate, retaliation sensitivity, inflation, GDP growth | Supplies imports to domestic economy and demands exports according to foreign GDP, domestic prices and tariffs; adjusts tariffs gradually in retaliation to domestic tariffs; exchange rate responds to interest‑rate differentials, inflation differences and trade balance (higher domestic rates strengthen currency, higher domestic inflation weakens it); GDP and price levels evolve with growth and inflation. |
Market | Mechanism | Behavior |
|---|---|---|
Labor Market | Matching with wage adjustment | Firms announce labor demand; unemployed consumers randomly apply; matches are made until positions fill; wages adjust based on tightness—tight labor markets push wages up, slack markets push wages down. |
Goods Market | Supply–demand clearing & price adjustment | Consumers demand goods based on wealth and marginal propensity to consume; firms supply production plus inventory; imports add to supply; market clears at minimum of demand and supply; firms adjust prices upward when demand exceeds supply (inflation) and downward when supply exceeds demand (deflation). |
Stock Market | P/E‑ratio pricing & sentiment | Stock prices respond to the policy interest rate (lower rates → higher P/E multiples); company earnings and fear‑and‑greed index adjust the valuation; fear‑and‑greed index uses price momentum and volatility to gauge sentiment on a 0‑100 scale; crash scenario triggers a 30 % drop and extreme fear, causing consumers to sell stocks and hold cash. |
Cryptocurrency Market | Macro‑driven, network effects | Crypto behaves as an inflation hedge—when inflation exceeds 2 % adoption increases; it is sensitive to interest rates (low rates bullish, high rates bearish); crypto returns are magnified relative to stocks (risk‑on/risk‑off); government holding crypto boosts legitimacy and adoption, causing price pumps; price follows Metcalfe’s Law network effect with log scaling and is stabilized by mean‑reversion to a fundamental value. |
Foreign Exchange & Capital Flows | Exchange‑rate determination | Exchange rate is defined as foreign currency per domestic currency (E = FC/DC). Changes combine effects: (1) interest‑rate parity – higher domestic interest relative to foreign strengthens E; (2) purchasing‑power parity – higher domestic inflation weakens E; (3) trade balance – trade surplus strengthens E. Noise adds randomness; rates are bounded between 0.1 and 10.0 to avoid unrealistic values. |
International Trade (imports/exports) | Supply & demand formulas | Imports depend on domestic consumption demand multiplied by foreign sector’s import propensity; foreign prices are converted to domestic currency and tariffs raise effective import price; competitiveness factor (0.1–2.0) adjusts quantity: cheaper imports increase quantity, expensive imports decrease it; tariff revenue goes to domestic government. |
Financial (Capital) Markets | Integration of stock/crypto with ABM | Consumers allocate a share of disposable income to stocks (baseline 70 %) and crypto (30 %) with rebalancing; allocation shifts when inflation >4 % (crypto hedge) or >6 % (more crypto); government may accumulate crypto reserve to influence price. |
Trade Integration & Economic Indicators | Tariffs, retaliation, trade flows | Tariff revenue goes to domestic government, increasing tax revenue; net trade quantity (imports – exports) affects goods supply: positive net imports increase supply and relieve inflation; trade balance uses pre‑tariff import value to measure flows; net exports as % of GDP is tracked. Country‑specific metrics record imports from, exports to, bilateral balance and exchange rate per partner. Policy scenarios include trade war (tariff hikes with gradual foreign retaliation) and free trade agreement (zero tariffs, lower retaliation, higher import propensity). |
Mathematical Modelling: We referred various online articles and a couple papers to get a good idea of the maths behind it.
User understanding – Macroeconomic concepts are complex. To make the system approachable, the dashboard offers scenario buttons (e.g., stock crash, crypto rally, trade war), AI‑generated narrative explanations and visually engaging charts
Through building EconoSphere, the team learned how to integrate agent‑based modelling with live data and AI services. Key accomplishments include:
Unique ABM simulator to integrate cryptocurrency responses to macro policy (Most of the models miss this, because up until recently, crypto was not officially recognized by the government).
Comprehensive trade module incorporating import/export supply and demand, tariffs, retaliation and exchange‑rate dynamics.
AI‑powered news insights that bridge real‑world events and simulation scenarios, demonstrating how modern AI can assist economic analysis.
Model calibration using World Bank data to align the simulation with historical trends.
We can add broader financial instruments like stablecoins, bonds, DeFi protocols, NFTs and derivative markets to the financial model.
We can implement enhanced trade modeling by incorporating capital flows, country‑specific tariffs, import quotas, currency intervention and supply‑chain linkage.
We can improve agent heterogeneity by introducing varied consumer types, firm sizes and banking agents (e.g., a banking sector example is provided as an extension point).