From 55000043ccc239b0bfa250a03d35cef0b6ec9874 Mon Sep 17 00:00:00 2001 From: git Date: Mon, 16 Mar 2026 13:16:16 +0000 Subject: [PATCH] Update README.md --- README.md | 70 +++++++++++++++++++++---------------------------------- 1 file changed, 27 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 519f7d0..a14cd76 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,40 @@ -ECB FX Trend Analyzer & Pair Ranker -Overview -This R script automates the extraction and statistical analysis of daily foreign exchange rates from the European Central Bank (ECB). Designed for trend-following or long/short strategy research, it identifies the top FX pairs exhibiting the strongest, most predictable linear trends over a customizable rolling window. +# ECB FX Trend Analyzer & Pair Ranker -Instead of relying on standard return/volatility metrics, it ranks pairs using a custom Signal-to-Noise Ratio derived from linear regression, isolating pairs that move cleanly in one direction with minimal chop. +### Overview +This R script automates the extraction and statistical analysis of daily foreign exchange rates from the European Central Bank (ECB). Designed for trend-following or long/short strategy research, it identifies the top FX pairs exhibiting the strongest, most predictable linear trends over a customizable rolling window. -Key Features -Automated Data Ingestion: Securely downloads, unzips, and cleans the latest historical daily exchange rate dataset directly from the ECB repository. +Instead of relying on standard return/volatility metrics, it ranks pairs using a custom **Signal-to-Noise Ratio** derived from linear regression, isolating pairs that move cleanly in one direction with minimal chop. -Dynamic Cross-Pair Generation: Automatically calculates non-EUR cross-pairs (e.g., USD/JPY, GBP/JPY) on the fly based on any user-defined list of target currencies. +--- -Custom Timeframes: Allows users to easily slice the dataset to analyze specific lookback periods (e.g., the last 720 days). +### Key Features +* **Automated Data Ingestion:** Securely downloads, unzips, and cleans the latest historical daily exchange rate dataset directly from the ECB repository. +* **Dynamic Cross-Pair Generation:** Automatically calculates non-EUR cross-pairs (e.g., USD/JPY, GBP/JPY) on the fly based on any user-defined list of target currencies. +* **Custom Timeframes:** Allows users to easily slice the dataset to analyze specific lookback periods (e.g., the last 720 days). +* **Statistical Ranking Methodology:** * Runs a simple linear regression for each currency pair (Exchange Rate ~ Time). + * Extracts the slope (**Beta**) to measure the strength and direction of the trend. + * Extracts the Residual Standard Error (**RSE**) to measure the volatility or "noise" around that trendline. + * Ranks all pairs by **|Beta| / RSE**, surfacing the top 3 pairs with the smoothest, most predictable trajectories regardless of whether they are trending up or down. -Statistical Ranking Methodology: * Runs a simple linear regression for each currency pair (Exchange Rate ~ Time). +--- -Extracts the slope (Beta) to measure the strength and direction of the trend. +### Prerequisites +* **R (Version 3.0 or higher):** The script relies entirely on base R functions. No external libraries (like `dplyr` or `quantmod`) are required. +* **Internet Connection:** Required for the script to automatically fetch the latest dataset directly from the ECB servers. -Extracts the Residual Standard Error (RSE) to measure the volatility or "noise" around that trendline. +--- -Ranks all pairs by |Beta| / RSE, surfacing the top 3 pairs with the smoothest, most predictable trajectories regardless of whether they are trending up or down. +### How to Use -Prerequisites -R (Version 3.0 or higher): The script relies entirely on base R functions. No external libraries (like dplyr or quantmod) are required. +**1. Open the Script** +Open the `.R` file in your preferred environment (RStudio, VS Code, or the standard R GUI). -Internet Connection: Required for the script to automatically fetch the latest dataset directly from the ECB servers. +**2. Configure Your Parameters** +At the very top of the script, locate the `CONFIGURATION` section to customize your analysis: +* `target_currencies`: An array of the currency tickers you want to analyze. The script will automatically generate all possible cross-pairs from this list. *(Note: All original columns are priced with a EUR base by default).* +* `n_days_to_analyze`: An integer representing your lookback window in days (e.g., `720` for roughly two years). Set this to `NULL` to analyze the entire historical dataset dating back to 1999. -How to Use -1. Open the Script -Open the .R file in your preferred environment (RStudio, VS Code, or the standard R GUI). - -2. Configure Your Parameters -At the very top of the script, locate the CONFIGURATION section to customize your analysis: - -target_currencies: An array of the currency tickers you want to analyze (e.g., c("USD", "JPY", "GBP", "CHF")). The script will automatically generate all possible cross-pairs from this list. Note: All currencies are priced with a EUR base by default. - -n_days_to_analyze: An integer representing your lookback window in days (e.g., 720 for roughly two years). Set this to NULL to analyze the entire historical dataset dating back to 1999. - -R +```R # Example Configuration target_currencies <- c("USD", "JPY", "GBP") -n_days_to_analyze <- 720 -3. Run the Script -Execute the script. It will run silently, downloading the data to a temporary directory, unpacking it, and crunching the linear regressions. - -4. Interpret the Output -The console will print a dataframe of the top 3 currency pairs. - -Pair: The specific currency or cross-pair. - -Beta: The daily linear trend (positive = upward trend, negative = downward trend). - -AbsBeta: The absolute value of the trend slope. - -RSE: The Residual Standard Error (volatility/noise around the trendline). - -SignalToNoise: The final ranking metric (AbsBeta / RSE). A higher number indicates a steeper, smoother, and more predictable trend. \ No newline at end of file +n_days_to_analyze <- 720 \ No newline at end of file