This project simulates international trade networks and their evolution over time, accounting for geographic distance, political relationships (friendship), tariffs, and transaction costs.
Deployed App: https://tradesimulation.streamlit.app/
- Geographic Distance: Countries located closer to each other have lower transaction costs
- Friendship Dynamics: Political relationships affect tariffs and evolve as trade happens
- Network Statistics: Comprehensive analysis of network structure including:
- Clustering coefficients
- Centrality measures (degree, betweenness)
- Network diameter and path lengths
- Community detection
The project includes a full-featured interactive Streamlit application that allows you to:
- Configure simulation parameters (countries, political blocs, tariffs, etc.)
- Run simulations and visualize trade networks in real-time
- Apply policy shocks and observe how they propagate through the network
- Compare network simulation with Mean-Field Approximation (MFA)
- Analyze economic metrics like GDP, poverty rates, and inequality
-
Install the required packages:
pip install streamlit networkx numpy pandas plotly~=5.19 scipy
-
Run the Streamlit app:
streamlit run trade_app.py
-
The app will open in your web browser at http://localhost:8501
- Countries: Control the number of countries in the simulation (4-80)
- Political blocs: Group countries into alliance blocs with preferential trading
- Tariff gap: Set how much higher inter-bloc tariffs are compared to intra-bloc tariffs
- Two-good world: Enable comparative advantage with countries producing two goods with different efficiency
- Policy shock: Apply tariff changes to specific countries and observe ripple effects
- Trade Network: Directed graph with countries as nodes and trade relationships as edges
- Friendship Matrix: Tracks political relationships between countries
- Transaction Costs: Partially based on geographic distance between countries
- Tariffs: Based on political relationships (friendship matrix)
The simulation tracks and visualizes:
-
Economic Indicators:
- Average tariffs
- Transaction costs
- Friendship levels
- GDP growth
- Poverty rates
- Inequality (Gini coefficient)
-
Network Structure:
- Number of trade relationships
- Network diameter
- Clustering coefficient
- Community formation
-
Trade Hubs:
- Countries with high betweenness centrality
- Major players in the global trade network
trade_app.py- Main Streamlit applicationmodel.py- Core simulation primitives and enginevisualization.py- Plotting and visualization functionsanalytics.py- Statistical analysis and advanced metricstrade_stats.py- Functions for analyzing trade network statistics
- Python 3.x
- NetworkX
- NumPy
- Matplotlib
- Pandas
- Plotly
- Streamlit
- Scipy