04 · Temporal Trends, Seasonality and External Events

Objective. Describe how monthly trade evolved from January 2021 to September 2026, test whether trade follows a seasonal pattern, and examine whether known regional and global events coincide with visible changes in trade.

Method.

  • Monthly totals of value and record count by trade type.
  • Seasonality: each month's value expressed as an index of its year's monthly average (2021–2025), averaged across years.
  • Event windows: mean monthly value in the three months before each event compared with the event month and the two months after it.

Note. Coinciding with an event does not show that the event caused the change. The windows give a descriptive comparison only.

%load_ext autoreload
%autoreload 2

import pandas as pd
import plotly.express as px

from scripts.analysis import load_trade, pct_change, EVENTS_CSV
from scripts.plotly_theme import use_metro, RED, BLUE, ORANGE, MUTED, INK, CREAM

use_metro()
pd.options.display.float_format = "{:,.1f}".format
TYPE_COLORS = {"import": RED, "export": BLUE, "re-export": ORANGE}

df = load_trade()

1. Monthly trade value

monthly = (
    df.groupby(["date", "trade_type"])
    .agg(
        value_bhd_m=("price_bhd", "sum"),
        records=("price_bhd", "size"),
    )
    .reset_index()
)
monthly["value_bhd_m"] = monthly["value_bhd_m"] / 1e6
fig = px.line(
    monthly,
    x="date",
    y="value_bhd_m",
    color="trade_type",
    markers=True,
    color_discrete_map=TYPE_COLORS,
)

fig.update_layout(
    title="Monthly Non-Oil Trade Value by Trade Type, 2021–2026",
    xaxis_title="Date",
    yaxis_title="Monthly Value (BHD m)",
    legend_title_text="Trade Type"
)

fig.show()
# Months with the largest month-on-month change in total trade value
total_monthly = monthly.groupby("date")["value_bhd_m"].sum()
mom = pd.DataFrame({
    "value_bhd_m": total_monthly,
    "mom_change_%": total_monthly.pct_change() * 100,
})
mom.reindex(mom["mom_change_%"].abs().nlargest(6).index)
value_bhd_m mom_change_%
date
2026-03-01 488.8 -46.9
2023-10-01 977.7 24.5
2026-04-01 604.3 23.6
2021-03-01 839.9 23.5
2026-06-01 685.3 22.2
2023-03-01 957.2 22.0

2. Seasonality

To remove the effect of growth between years, each month is divided by the average month of its own year (index = 100). The mean index per calendar month across 2021–2025 is shown, so a value of 110 means that month is typically 10% above the yearly average.

fy_monthly = monthly[monthly["date"].dt.year <= 2025].copy()
fy_monthly["year"] = fy_monthly["date"].dt.year
fy_monthly["month"] = fy_monthly["date"].dt.month
fy_monthly["index"] = (
    fy_monthly["value_bhd_m"]
    / fy_monthly.groupby(["year", "trade_type"])["value_bhd_m"].transform("mean") * 100
)

seasonal = (
    fy_monthly.groupby(["trade_type", "month"])["index"]
    .mean()
    .reset_index()
)
fig = px.line(
    seasonal,
    x="month",
    y="index",
    color="trade_type",
    markers=True,
    color_discrete_map=TYPE_COLORS,
)

fig.update_layout(
    title="Average Seasonal Profile, 2021–2025",
    xaxis_title="Month",
    yaxis_title="Seasonal Index (Year Average = 100)",
    legend_title_text="Trade Type"
)

fig.update_xaxes(dtick=1)
fig.add_hline(y=100, line_dash="dot", line_color=MUTED)

fig.show()
seasonal.pivot(index="month", columns="trade_type", values="index")
trade_type export import re-export
month
1 94.8 97.3 95.9
2 89.6 96.1 91.7
3 101.5 101.7 110.3
4 96.3 105.1 101.0
5 99.7 97.5 93.8
6 97.8 97.5 105.5
7 100.2 96.5 89.6
8 102.1 105.1 101.1
9 106.7 96.4 100.8
10 100.8 103.3 113.6
11 100.3 97.8 104.4
12 110.1 105.7 92.3

3. External events

A reference list of regional and global events that could plausibly affect Bahrain's trade. The list is saved to data/clean/external_events.csv.

events = pd.DataFrame(
    [
        ["Suez Canal blockage", "2021-03-01", "Logistics"],
        ["Bahrain VAT increase", "2022-01-01", "Economic"],
        ["Russia-Ukraine war", "2022-02-01", "Geopolitical"],
        ["Bahrain-Qatar diplomatic relations restored", "2023-04-01", "Diplomatic"],
        ["Bahrain-Qatar direct flights resume", "2023-05-01", "Logistics"],
        ["Red Sea shipping crisis", "2023-11-01", "Logistics"],
        ["Arabian Gulf Cup", "2024-12-01", "Sporting"],
        ["Iran conflict", "2026-02-01", "Geopolitical"],
    ],
    columns=["event_name", "date", "event_type"],
)
events["date"] = pd.to_datetime(events["date"])
events.to_csv(EVENTS_CSV, index=False)
events
event_name date event_type
0 Suez Canal blockage 2021-03-01 Logistics
1 Bahrain VAT increase 2022-01-01 Economic
2 Russia-Ukraine war 2022-02-01 Geopolitical
3 Bahrain-Qatar diplomatic relations restored 2023-04-01 Diplomatic
4 Bahrain-Qatar direct flights resume 2023-05-01 Logistics
5 Red Sea shipping crisis 2023-11-01 Logistics
6 Arabian Gulf Cup 2024-12-01 Sporting
7 Iran conflict 2026-02-01 Geopolitical
fig = px.line(
    monthly,
    x="date",
    y="value_bhd_m",
    color="trade_type",
    color_discrete_map=TYPE_COLORS,
)

for i, event in events.iterrows():
    fig.add_vline(
        x=event["date"],
        line_dash="dash",
        line_color=MUTED,
        line_width=1
    )

    fig.add_annotation(
        x=event["date"],
        y=1.0 - 0.07 * (i % 4),   # stagger the labels so they don't overlap
        yref="paper",
        text=event["event_name"],
        showarrow=False,
        xanchor="left",
        xshift=4,
        font=dict(size=11, color=INK),
        bgcolor=CREAM
    )

fig.update_layout(
    title="Monthly Trade Value and External Events",
    xaxis_title="Date",
    yaxis_title="Monthly Value (BHD m)",
    legend_title_text="Trade Type",
    height=650
)

fig.show()

Event-window comparison

For each event, the mean monthly value of the three months before the event month (before) is compared with the event month and the two following months (after).

wide = monthly.pivot(index="date", columns="trade_type", values="value_bhd_m")
wide["total"] = wide.sum(axis=1)

rows = []
for _, ev in events.iterrows():
    before = wide.loc[ev["date"] - pd.DateOffset(months=3): ev["date"] - pd.DateOffset(months=1)]
    after = wide.loc[ev["date"]: ev["date"] + pd.DateOffset(months=2)]
    row = {"event": ev["event_name"], "date": ev["date"].strftime("%b %Y")}
    for col in ["import", "export", "re-export", "total"]:
        row[f"{col}_%"] = pct_change(after[col].mean(), before[col].mean())
    rows.append(row)

event_windows = pd.DataFrame(rows).set_index("event")
event_windows
date import_% export_% re-export_% total_%
event
Suez Canal blockage Mar 2021 6.1 49.7 3.4 18.5
Bahrain VAT increase Jan 2022 -3.1 5.3 2.1 0.8
Russia-Ukraine war Feb 2022 1.2 11.0 2.0 5.5
Bahrain-Qatar diplomatic relations restored Apr 2023 2.6 -5.5 6.4 -0.2
Bahrain-Qatar direct flights resume May 2023 -6.8 1.8 -6.7 -3.6
Red Sea shipping crisis Nov 2023 -4.7 4.7 -7.9 -1.6
Arabian Gulf Cup Dec 2024 7.3 11.1 -7.2 7.5
Iran conflict Feb 2026 -36.9 -21.1 -38.8 -31.3

Detail: the 2026 regional conflict

Monthly value and record count from six months before to the latest available month. The record count measures how many commodity-partner flows were active, independent of their value.

def plot_event(event_name, y, y_title, months_before=6, months_after=8):

    event_date = events.loc[
        events["event_name"] == event_name, "date"
    ].iloc[0]

    temp = monthly[
        monthly["date"].between(
            event_date - pd.DateOffset(months=months_before),
            event_date + pd.DateOffset(months=months_after)
        )
    ]

    fig = px.line(
        temp,
        x="date",
        y=y,
        color="trade_type",
        markers=True,
        color_discrete_map=TYPE_COLORS,
    )

    fig.add_vline(
        x=event_date,
        line_dash="dash",
        line_color=RED
    )

    fig.update_layout(
        title=f"{y_title} Around: {event_name}",
        xaxis_title="Date",
        yaxis_title=y_title,
        legend_title_text="Trade Type"
    )

    fig.update_xaxes(
        tickformat="%b %Y",
        dtick="M1"
    )

    fig.show()
plot_event("Iran conflict", "value_bhd_m", "Monthly Value (BHD m)")
plot_event("Iran conflict", "records", "Active Records")

Findings

  1. Stable baseline before 2026. From 2021 to early 2026, monthly imports fluctuated mostly between BHD 400 m and 575 m, and re-exports between BHD 50 m and 80 m. Domestic exports rose sharply through 2021, peaked in mid-2022 (about BHD 480 m) and settled between BHD 280 m and 380 m from 2023 onward.
  2. March 2026 is an outlier. Total monthly trade fell by 46.9% between February and March 2026, to BHD 489 m. This is the largest month-on-month change in the series. The next-largest movements in the series are within ±25%.
  3. Seasonality is weak. The average seasonal index stays within roughly ±10% of the yearly mean for every trade type. Imports peak in April, August and December (about 105) and dip in February (96). Domestic exports are strongest in December (110) and weakest in February (90). Seasonality therefore cannot explain a change of the size seen in March 2026. The Feb–Sep comparison window used in notebook 07 also compares the same calendar months, which removes it entirely.
  4. Most events show no distinct signature. Six of the seven pre-2026 events coincide with changes of less than ±8% in total trade. The +18.5% after the Suez Canal blockage (March 2021) reflects the steady rise of domestic exports during 2021, not a discrete shock.
  5. The 2026 regional conflict coincides with the only large, broad decline. Mean monthly value in the event window was 31.3% lower than in the preceding three months: imports −36.9%, domestic exports −21.1% and re-exports −38.8%. The event is dated February 2026, but February values were still normal and the fall appears in March 2026, which the later notebooks treat as the first conflict month.
  6. The number of active trade flows fell as well as their value. Import records dropped from 26,325 in February to 16,610 in March 2026 (−37%), and had recovered only to 24,803 by September. Fewer commodity–partner flows were active, so the decline reflects interrupted supply, not only lower prices.