I have updated my GitHub with a new Jupyter notebook. This notebook analyzes the relationship between the price movements of Bitcoin (BTC=F) and Ether (ETH-USD) over time. Specifically, it aims to find the optimal “lag” or time delay between the two cryptocurrency prices that results in the highest correlation.
It begins by importing the necessary libraries for data retrieval, analysis, and visualization. Pandas is used for handling the time series data, while NumPy provides numerical computing functions. Matplotlib plots the results.
The notebook then retrieves the daily close prices of BTC and ETH from Yahoo Finance over the period from 2016 to 2023 using Pandas DataReader. It prints the column names to check the data.
Next, it aligns the two time series to only include dates that are common to both. This ensures they can be directly compared.
A for loop then calculates the cross-correlation between BTC and lagged (time-shifted) versions of ETH prices over a range of lags from -100 to 100 days.
It finds the lag with the maximum correlation value, deemed the “optimal lag”. This tells us how far ahead or behind ETH prices tend to move compared to BTC.
Some cleaning steps normalize the prices before plotting. Finally, the notebook visualizes the optimal lagged ETH series against BTC, as well as a plot of the cross-correlations across different lags.
The end result gives us valuable insight into the lead-lag relationship between the two largest cryptocurrencies and how closely their prices tend to move in tandem over time when accounting for delays.
This kind of analysis can also be valuable when comparing other financial assets or market indices to uncover relationships in their price movements over time.
Leave a Reply