Plotting
TimeSeries
defines a recipe that allows plotting to a number of different plotting packages using the Plots.jl framework (no plotting packages will be automatically installed by TimeSeries
).
Here we use the data from Yahoo Fiance as a demo.
using Plots, MarketData, TimeSeries
gr()
ta = yahoo(:GOOG, YahooOpt(period1 = now() - Month(1)))
22×6 TimeArray{Float64,2,Date,Array{Float64,2}} 2021-03-23 to 2021-04-22
│ │ Open │ High │ Low │ Close │ AdjClose │
├────────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ 2021-03-23 │ 2051.7 │ 2072.302 │ 2039.22 │ 2052.96 │ 2052.96 │
│ 2021-03-24 │ 2065.3701 │ 2078.21 │ 2041.5551 │ 2045.0601 │ 2045.0601 │
│ 2021-03-25 │ 2044.8101 │ 2058.8701 │ 2010.73 │ 2044.36 │ 2044.36 │
│ 2021-03-26 │ 2038.86 │ 2050.99 │ 2014.02 │ 2035.55 │ 2035.55 │
│ 2021-03-29 │ 2027.88 │ 2058.4299 │ 2015.62 │ 2055.95 │ 2055.95 │
│ 2021-03-30 │ 2057.6299 │ 2070.78 │ 2044.03 │ 2055.54 │ 2055.54 │
│ 2021-03-31 │ 2059.1201 │ 2093.3269 │ 2056.7451 │ 2068.6299 │ 2068.6299 │
│ 2021-04-01 │ 2097.95 │ 2142.9399 │ 2096.8899 │ 2137.75 │ 2137.75 │
│ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │
│ 2021-04-14 │ 2275.1599 │ 2277.99 │ 2249.1899 │ 2254.8401 │ 2254.8401 │
│ 2021-04-15 │ 2276.98 │ 2306.5969 │ 2266.0 │ 2296.6599 │ 2296.6599 │
│ 2021-04-16 │ 2303.0 │ 2306.4399 │ 2284.45 │ 2297.76 │ 2297.76 │
│ 2021-04-19 │ 2291.98 │ 2318.45 │ 2287.845 │ 2302.3999 │ 2302.3999 │
│ 2021-04-20 │ 2307.8899 │ 2309.6001 │ 2271.71 │ 2293.6299 │ 2293.6299 │
│ 2021-04-21 │ 2285.25 │ 2295.3201 │ 2258.5701 │ 2293.29 │ 2293.29 │
│ 2021-04-22 │ 2293.23 │ 2303.762 │ 2256.45 │ 2267.9199 │ 2267.9199 │
Plotting as multiple series
The recipe allows TimeArray
objects to be passed as input to plot
. The recipe will plot each variable as an individual line, aligning all variables to the same y axis. backend).
plot(ta[:Open, :High, :Low, :Close])
Plotting candlestick
We have seriestype = :candlestick
support that requires four columns exist in the input. They are open
, high
, low
and close
(case-insensitive).
plot(ta, seriestype = :candlestick)
Other available attributes
bar_width::Float64
the valid value is from0
to1
.
plot(ta, seriestype = :candlestick, bar_width = 0.7)
xticks::Int
for controlling the density of x axis labels.
plot(ta, seriestype = :candlestick, xticks = 3, xrotation = 60)