# Replication Package: "Trade War and the Dollar Anchor"

**Authors:** Tarek A. Hassan, Thomas M. Mertens, Jingye Wang, and Tony Zhang

This repository contains the code and data necessary to replicate all figures and tables in the paper.

---

## Repository Structure

```
ReplicationPackage/
    Code/                                  # All replication scripts
        Compute_DataMoments.py             # Computes data moments and event study statistics
        Compute_DollarIndex.py             # Computes broad and G10 dollar indexes
        Make_Exhibits.py                   # Generates figures for Section 2
        Welfare_5_Countries_Publish.nb     # Mathematica notebook for theoretical results and plots
    Data/                                  # Input data files
        DOLdollar_BIG_ALLfwd.dta          # Hassan-Mano forward premium and currency return data
        Dollar_Indexes.csv                 # Computed dollar indexes (output from Compute_DollarIndex.py)
        ForwardSpotData.xlsx              # Forward and spot rate data for event study
        FRBM_MPD.csv                      # Foreign exchange volatility data from Federal Reserve
        FRED_VIX.csv                      # VIX data from FRED
        fx_rates.csv                       # Raw foreign exchange rate data
        GlobalRisk_Update.csv             # Global risk measure time series
        HassanMano_country_xwalk.csv      # Country crosswalk for Hassan-Mano data
        interest_rates.dta                # Sovereign bond yield data (Stata format)
        pwt1001.xlsx                      # Penn World Table 10.01 data for consumption and GDP
        share_distribution_2023.xlsx      # Country size shares calculated using GDP data
        Size_vs_Deviation_Bins.csv        # Country size bins and stabilization
        GlobalRiskResults/                # Regression results for currency betas
            d_log_broad_fx_d_log_globalrisk.csv
            d_log_spot_pa_d_log_globalrisk.csv
    Output/                               # Generated figures and tables
        figs/                             # Figures in PDF format
        tabs/                             # Tables in LaTeX format
    README.md                             # This file
```

---

## Software Requirements

### Required Software
- **Python 3.x** with the following packages:
  - `numpy`
  - `pandas`
  - `matplotlib`
  - `statsmodels`
  - `scipy`
  - `seaborn`

- **Mathematica** (for `Welfare_5_Countries_Publish.nb`)

### Installation
To install required Python packages, run:
```bash
pip install numpy pandas matplotlib statsmodels scipy seaborn
```

---

## Instructions for Replication

### Step 1: Compute Dollar Indexes
Run the script to compute the broad and G10 dollar indexes from raw foreign exchange rate data:

```bash
cd Code
python Compute_DollarIndex.py
```

**Inputs:**
- `Data/fx_rates.csv` - Daily foreign exchange rates for 26 currencies

**Outputs:**
- `Data/Dollar_Indexes.csv` - Quarterly broad and G10 dollar indexes (indexed to 2006)

**Note:** This script indexes all exchange rates to January 2006 = 100 and computes:
- **Broad Dollar Index:** Average of 26 currencies (G10 + emerging markets)
- **G10 Dollar Index:** Average of 9 G10 currencies (AUS, NZL, NOR, GBR, CAN, SWE, EUR, CHE, JPN)

### Step 2: Compute Data Moments
Run the script to compute unconditional moments and event study statistics:

```bash
python Compute_DataMoments.py
```

**Inputs:**
- `Data/pwt1001.xlsx` - Penn World Table 10.01 (consumption and GDP data)
- `Data/DOLdollar_BIG_ALLfwd.dta` - Hassan-Mano forward premium and currency return data
- `Data/HassanMano_country_xwalk.csv` - Country crosswalk
- `Data/ForwardSpotData.xlsx` - Forward and spot rate data for event study
- `Data/FRBM_MPD.csv` - Exchange rate volatility data

**Outputs (printed to console):**
- **Unconditional moments:** Interest rate differences, currency excess returns, exchange rate-consumption correlations, consumption volatility
- **Event study moments:** Changes in forward premiums, equity prices, and exchange rate volatility around April 2, 2025 tariff announcement

### Step 3: Generate Figures for Section 2
Run the main exhibit generation script:

```bash
python Make_Exhibits.py
```

**Inputs:**
- `Data/Dollar_Indexes.csv` - Dollar indexes from Step 1
- `Data/FRED_VIX.csv` - VIX volatility index
- `Data/GlobalRisk_Update.csv` - Global risk measure
- `Data/interest_rates.dta` - 5-year sovereign bond yields by currency
- `Data/GlobalRiskResults/d_log_broad_fx_d_log_globalrisk.csv` - Currency beta estimates

**Outputs:**
- `Output/figs/dollar_scatter.pdf` - **Figure 1:** Scatter plot of changes in broad dollar index vs. changes in global risk, with crisis periods (GFC, COVID) and 2025 tariffs highlighted
- `Output/figs/d_log_broad_fx_beta_y.pdf` - **Figure 2:** Cross-sectional relationship between currency betas and sovereign bond yields

### Step 4: Generate Theoretical Results (Sections 3 and 4)
Open and run the Mathematica notebook:

```
Code/Welfare_5_Countries_Publish.nb
```

This notebook contains the theoretical model and welfare analysis for the five-country case.

**Outputs:**
- `Output/figs/*.pdf` - Theoretical figures (optimal stabilization, policy transitions, correlations, etc.)
- `Output/tabs/*.tex` - LaTeX tables (calibration and simulation results)

---

## Data Description

### Primary Data Sources

1. **fx_rates.csv**
   - Daily foreign exchange rates for 26 currencies vs. USD
   - Currencies: AUS, NZL, NOR, GBR, CAN, SWE, EUR, CHE, JPN (G10) plus BRA, ZAF, HUN, KOR, MEX, CHL, RUS, IND, IDN, TUR, CHN, POL, MYS, THA, PHL, ISR, COL (emerging markets)
   - Period: 2006-2025
   - Source: Hassan, Mertens, and Wang (2024)

2. **FRED_VIX.csv**
   - Daily CBOE Volatility Index (VIX)
   - Source: Federal Reserve Economic Data (FRED)

3. **GlobalRisk_Update.csv**
   - Quarterly global risk measure
   - Variable: `risk_appended` - the global risk factor
   - Source: Hassan, Schreger, Schwedeler, and Tahoun (2021)

4. **interest_rates.dta**
   - 5-year sovereign bond yields by currency
   - Used to construct interest rate differentials
   - Source: Hassan, Schreger, Schwedeler, and Tahoun (2021)

5. **GlobalRiskResults/**
   - Pre-computed regression results showing currency-specific betas to global risk shocks
   - Used in Figure 2 to relate risk betas to interest rate differentials
   - Source: Hassan, Schreger, Schwedeler, and Tahoun (2021)

6. **pwt1001.xlsx**
   - Penn World Table 10.01
   - Contains real consumption (ccon), consumption deflator (pl_con), exchange rates (xr), and GDP data
   - Used to compute consumption growth moments and country size shares
   - Source: Feenstra, Inklaar and Timmer (2015)

7. **DOLdollar_BIG_ALLfwd.dta**
   - Forward premiums and currency excess returns for G10 currencies
   - Variables: fp12m (12-month forward premium), rx12m12 (12-month currency excess return)
   - Period: 1984-2019
   - Source: Hassan and Mano (2019)

8. **HassanMano_country_xwalk.csv**
   - Crosswalk file mapping currency names to ISO3 country codes
   - Used to merge Hassan-Mano data with other datasets

9. **ForwardSpotData.xlsx**
   - High-frequency forward rates, spot rates, interest rate swaps, and equity prices
   - Used for event study analysis around April 2, 2025 tariff announcement

10. **FRBM_MPD.csv**
    - Market-implied probability densities and exchange rate volatility
    - Source: Federal Reserve Board of Minneapolis

11. **share_distribution_2023.xlsx**
    - Country size shares calculated using 2023 GDP data
    - Used in calibration of theoretical model
    - Source: World Bank

12. **Size_vs_Deviation_Bins.csv**
    - Binned relationship between country size and optimal exchange rate stabilization

---

## Contact

For questions or issues with the replication package, please contact Jingye Wang at jingyewang@ruc.edu.cn.
