I’m playing around with the MarketData package as a way to learn Julia. Now I’ve run into a simple question: How do I access the actual number inside a TimeArray?
I’m following the MarketData example to get the daily closing price of Apple’s stock:
using MarketData, TimeSeries
AAPL = yahoo(:AAPL)
That works great. I can see a full time series of daily closing prices in a column called AdjClose
. Now I would like to plot the price history as a percentage of the most recent closing price. The mathematical formula for that is easy, and I think it should be possible to calculate it like this:
price_percent = 100 .* AAPL[:AdjClose] ./ AAPL[:AdjClose][end]
That is, the full time series, divided by the most recent closing price. The problem is, the most recent closing price, which I attempt to acces by AAPL[:AdjClose][end]
, is not a scalar, so I can divide the full time series by it:
My question is how do I access that 165.29
value so I can divide the entire time series by it?