demand = client.get("/demand-forecast", params={
"planId": "plan_9xKz2",
"scenarioIds": "scen_committed",
"interval": "M",
"groupBy": "region",
}).json()
supply = client.get("/supply-performance", params={
"planId": "plan_9xKz2",
"scenarioIds": "scen_committed",
"interval": "M",
"groupBy": "region",
}).json()
# Build a coverage map: closing stock / monthly demand
for d_row, s_row in zip(demand["scenarios"][0]["series"], supply["scenarios"][0]["series"]):
if d_row["demandVolume"] > 0:
weeks_coverage = (s_row["closingStock"] / d_row["demandVolume"]) * 4.33
print(f"{s_row['groupKey']} {s_row['period']}: {weeks_coverage:.1f} weeks of stock")