commit f898db12bc7eabc22194120c45018758a8d7c0e8 Author: git Date: Mon Mar 16 13:12:46 2026 +0000 Add README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..519f7d0 --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +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. + +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. + +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. + +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. + +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 +# 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