Listen to Financial Trends
Import financial data from 1990 until now.
In[1]:=
msft = TimeSeriesRescale[
TimeSeries@
FinancialData["MSFT", {"Jan. 1, 1990", DateString[Now]}], {0, 10}];
aapl = TimeSeriesRescale[
TimeSeries@
FinancialData["AAPL", {"Jan. 1, 1990", DateString[Now]}], {0,
10}];
Resample and smooth the data.
In[2]:=
resampledMSFT =
TimeSeriesResample[Round[MovingAverage[msft, 60]], 1/8];
resampledAAPL =
TimeSeriesResample[Round[MovingAverage[aapl, 60]], 1/8];
ListLinePlot[{resampledMSFT, resampledAAPL},
PlotStyle -> {Automatic, Automatic, PointSize[Large]},
PlotLegends -> {"MSFT", "AAPL"}]
Out[2]=
Define a function to convert price to frequency.
In[3]:=
midiToFreq[m_] := Clip[2^((m - 69)/12)*440., {0, 22050}];
Generate audio controlled by the two time series.
In[4]:=
res = .8 Mean[{AudioGenerator[{"Sin",
midiToFreq[.5 resampledMSFT + 40]}],
AudioGenerator[{"Triangle", midiToFreq[.5 resampledAAPL + 40]}]}]
In[5]:=
Spectrogram[res, 4096, 4096, PlotRange -> {All, {0, 4000}},
ImageSize -> 300]
Out[5]=