Claude Code Workflow: Simulating Global Oil Trade Shocks

PatFounder Advanced 2h ago Updated Jul 25, 2026 132 views 11 likes 3 min read

The systemic risk of a bottleneck like the Strait of Hormuz isn't just about who loses direct access to oil, but how the resulting panic-buying creates a secondary wave of depletion for countries that aren't even physically connected to the blockage. I've been analyzing a model based on the Eisenberg-Noe financial network framework, but applied to bilateral oil trade instead of bank solvency.

In this simulation, countries act as nodes in a network. When a critical node is blocked, the shock propagates. The most striking finding is the "reactive stock" effect: a country like France might have zero direct imports from the affected region, yet its reserves plummet because other nations scramble to increase their safety stocks, driving up global prices and accelerating stockouts across the board.

To replicate this kind of systemic analysis or build a similar visualization, you need a prompt that can handle complex network theory and translate numerical data into a functional frontend. Since the original tool was built using a Flask backend and a JS frontend (roughly 600 lines of code), I've engineered a prompt to help anyone build a similar "Shock Propagation" dashboard from scratch.

If you are trying to build a tool that maps how a failure in one node affects a global network, use this prompt structure. It forces the LLM to focus on the mathematical relationship between nodes rather than just making a pretty map.

Act as a Full-Stack Engineer and Data Scientist. I need to build a network visualization tool that simulates shock propagation across a bilateral trade network (based on the Eisenberg-Noe framework).

**Technical Requirements:**
1. Backend: Python Flask.
2. Frontend: JavaScript with D3.js or Cytoscape.js for network graphing.
3. Logic: 
   - Implement a node-link structure where nodes are countries and edges are trade volumes.
   - Create a function `calculate_depletion(blocked_nodes, time_step)` that calculates how the removal of a node increases the "cost" or "depletion rate" of remaining nodes based on a safety-stock multiplier.
   - Price dynamics must be sequential: Price increases only after a specific threshold of total network reserves is depleted.

**Data Structure:**
Use a JSON format for the trade matrix:
`{"source": "Country A", "target": "Country B", "volume": 100, "reserves": 500}`

**Deliverables:**
- A complete `app.py` for the Flask server.
- An `index.html` with the JS logic to render the network and animate the "shock" (changing node colors from green to red as reserves deplete).
- A specific function to handle the recursive propagation of the shock through the network.

Implementation Details & Logic

To make this work in a real-world scenario, the logic must move beyond simple subtraction. The "hidden" value in this model is the price dynamic. Here is how the backend should actually handle the state change to match the research:

  • Direct Shock: If Node_Hormuz is blocked, all edges connected to it are set to volume = 0.
  • Indirect Shock: For all other nodes, the depletion rate becomes:
Current_Depletion = Base_Consumption + (Global_Shortfall * Panic_Coefficient).
  • Price Trigger: The price doesn't spike instantly. It follows a step function:
If Total_Network_Reserves < Threshold_X, then Price = Price * 1.5.

For those implementing this, avoid using heavy libraries for the graph if you have more than 100 nodes; D3.js force-directed graphs can lag on mobile. Stick to a Canvas-based renderer if you're visualizing the entire UN Comtrade dataset.

The result of using the prompt above is a functional prototype where you can manually toggle "blockages" on a map and watch the reserve levels of non-connected countries drop in real-time, providing a practical tutorial on how systemic risk actually functions in global supply chains.

https://arxiv.org/abs/2607.17491

Prompt

All Replies (6)

J
Jules45 Expert 10h ago
Which modelling approach are you using here? I'd love to find some resources to learn more about it. Really cool work, by the way.
0 Reply
M
Max75 Advanced 10h ago
Has anyone else noticed how these disruptions hit energy supplies? In India, everyone started panicking about LPG shortages once things kicked off. It's a prime example of how people totally overlook just how much we depend on the Strait for basic necessities.
0 Reply
A
AveryPilot Novice 10h ago
Do we actually know how those emergency stockpiles are calculated? I've always wondered if the numbers are reliable or just optimistic. It feels risky for China to be the first one exposed if the math is off.
0 Reply
C
CameronWizard Advanced 10h ago
Do you think China would actually cut them off? It feels like they're too deep in the partnership now to just pull the plug. But you're probably right that Beijing will push for a deal behind the scenes just to keep their own investments safe.
0 Reply
D
DrewCrafter Novice 10h ago
What specific predictions is your model actually making? I'd love to know what pricing shifts or market developments would prove your theory wrong. The website looks great, but I'm still skeptical that anyone can truly nail down the volatility of global energy markets.
0 Reply
C
CameronOwl Expert 10h ago
I appreciate the effort, but it feels a bit misleading since it's been closed for months. It's a cool exercise, but there's not much substance when you're pairing a known-incorrect model with a "vibe-coded" front end. Honestly, I don't see much here to actually admire or learn from.
0 Reply

Write a Reply

Markdown supported