Author: Divyam Kamboj
Date: March 2025
This project provides a comprehensive algorithmic and mathematical summary of a flat-book, multi-route trading optimization model. The objective is to route trades (long and short) across different months, locations, and sell options while maintaining zero net market exposure (flat book).
The model accounts for:
- Pipeline and storage costs
- Inventory limits
- Forecast adjustments
Python code (using LP solvers like PuLP) implements the model for practical optimization.
- Monthly Prices:
- Midland:
P^M(m) - Houston:
P^H(m)
- Midland:
- Sour Differentials (for WTS):
- Midland:
Δ_M(m), Houston:Δ_H(m)
- Midland:
- Forecast Adjustments:
Applied to Houston prices for futures routes (set to 0 in this example) - Trading Days & Daily Capacity:
- WTI: 80,000 barrels/day
- WTS: 20,000 barrels/day
- Storage Cost:
$0.26per barrel per month held - Pipeline Cost:
$0.55fixed +0.2%of effective buying price if buying and selling locations differ - Inventory Capacity:
3,000,000 barrels per location (Midland, Houston)
For WTI:
For WTS:
If L ≠ S:
Includes adjustments and premiums/discounts for refinery routes:
- If
π ≥ 0: profitable long trade - If
π < 0: profitable short trade (profit =|π|)
To ensure zero net exposure:
For every product p, the total volume of long trades equals that of short trades.
Each route is defined by:
- Product: WTI or WTS
- Buy Month
m, Sell Monthn - Buy Location
L: Midland or Houston - Sell Option
S: Midland, Houston, or Refinery
Decision Variables:
x^+_{L,S}(m,n): long trade volumex^-_{L,S}(m,n): short trade volume
For every month m (buy) and n (sell):
Cumulative barrels stored at each location should not exceed 3,000,000 per month.
Maximize total profit:
Allocate long trades for positive profits and short trades for negative profits (i.e., positive arbitrage opportunities).
- Load all prices, trading days, and cost parameters
- Compute monthly capacities
- Enumerate all possible routes
(m, n, L, S)
For each route, calculate:
- Effective buying cost
- Pipeline cost (if needed)
- Sale price
- Storage cost
- Net profit
π
- For each route, define
x^+andx^-
- Monthly capacity
- Flat-book
- Optional storage constraint
- Maximize:
- Use an LP solver like PuLP's CBC to solve for optimal volumes
This model:
- Computes trading and storage economics for multiple oil grades and routes
- Maintains net market neutrality via flat-book constraint
- Uses linear programming to select the most profitable trade volumes
- Can be extended with additional constraints like inventory rollover, dynamic pricing, etc.
Let me know if you'd like this in a file or need a sample Python script as part of the README.md.