Hi David,
Once you get proficient with the Wolfram Language you will find that it takes very little effort to manipulate date and generate simple visualizations for exploratory data analysis. It took me ~ 5 min to write that code. To generalize it a bit we can define a function that takes two symbols, a start date and end date, and generates a plot of the price with the correlation as the plot label.
ClearAll@compareFinancialData;
compareFinancialData[symbol1_String, symbol2_String, startDate_, endDate_] := Module[
{data1, data2, commonDates, filtered1, filtered2},
data1 = FinancialData[symbol1, {startDate, endDate}]["DatePath"];
data2 = FinancialData[symbol2, {startDate, endDate}]["DatePath"];
commonDates = Intersection[data1[[All, 1]], data2[[All, 1]]];
filtered1 = Select[data1, MemberQ[commonDates, First@#] &];
filtered2 = Select[data2, MemberQ[commonDates, First@#] &];
ResourceFunction["CombinePlots"][
DateListPlot[filtered1,
PlotStyle -> ColorData[97][1],
PlotLegends -> LineLegend[{ColorData[97][2]}, {symbol1}],
PlotLabel ->
"Correlation: " <>
ToString@Round[Correlation[filtered1[[All, 2]], filtered2[[All, 2]]], .001],
ImageSize -> 500],
DateListPlot[filtered2,
PlotStyle -> ColorData[97][2],
PlotLegends -> LineLegend[{ColorData[97][2]}, {symbol2}],
FrameStyle -> ColorData[97][2]],
"AxesSides" -> "TwoY"]
]
To reproduce the previous result
compareFinancialData["^DJI", "ETH/USD", "2021-01-01", Today]
To compare a set of symbols
symbols = {"^DJI", "ETH/USD", "BTC/USD", "XRP/USD"};
Subsets[symbols, {2}] //
Map[compareFinancialData[First@#, Last@#, "2021-01-01", Today] &] //
Partition[#, UpTo[2]] & //
Grid[#, Frame -> All, Spacings -> {1, 1}] &
The date string format "1/1/2021" is ambiguous, is it M/D/Y or D/M/Y? Use an unambiguous format such as "YYYY-MM-DD".
FinancialData
has data on a small set of cryptocurrencies. If you are interested in cryptocurrency data analysis, take a look at this resource function by @Anton Antonov. I believe he has submitted it for inclusion in the function repository, but it is not yet available there.