Now that we have historical data, let's run some preliminary research to validate the thesis that the euro depreciates against the dollar during Europe business hours and appreciates during US business hours.
First, load the prices:
from quantrocket import get_prices
prices = get_prices("fiber-1h", sids="FXEURUSD", fields="Close")
Calculate the hourly returns. (Note that the timezone for FX is always New York time regardless of the currency pair.)
returns = prices.loc["Close"].pct_change()
returns.head()
Group by time and get the mean return of each group:
times = returns.index.get_level_values("Time")
returns_by_time_of_day = returns.groupby(times).mean()
Finally, plot the results:
returns_by_time_of_day.plot(kind="bar", title="EUR.USD average return by time of day (New York time)")
# add business day indicators to plot (9 AM - 5 PM Europe time = 3 AM - 11 AM New York Time)
import matplotlib.pyplot as plt
plt.axvline(x=3, label='Europe opens', c="red", linestyle="--")
plt.axvline(x=11, label='Europe closes', c="red", linestyle="-")
plt.axvline(x=9, label='US opens', c="orange", linestyle="--")
plt.axvline(x=17, label='US closes', c="orange", linestyle="-")
plt.legend()
We see clear evidence that EUR.USD declines during Europe's business day (3 AM to 11 AM New York time) then rises through the remainder of the US business day.