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}} 2023-04-17 to 2023-05-16
│ │ Open │ High │ Low │ Close │ AdjClose │ Volume │
├────────────┼─────────┼─────────┼─────────┼────────┼──────────┼─────────────┤
│ 2023-04-17 │ 105.43 │ 106.71 │ 105.32 │ 106.42 │ 106.42 │ 2.90434e7 │
│ 2023-04-18 │ 107.0 │ 107.05 │ 104.78 │ 105.12 │ 105.12 │ 1.76414e7 │
│ 2023-04-19 │ 104.215 │ 105.725 │ 103.8 │ 105.02 │ 105.02 │ 1.6732e7 │
│ 2023-04-20 │ 104.65 │ 106.888 │ 104.64 │ 105.9 │ 105.9 │ 2.25153e7 │
│ 2023-04-21 │ 106.09 │ 106.64 │ 105.485 │ 105.91 │ 105.91 │ 2.2379e7 │
│ 2023-04-24 │ 106.05 │ 107.32 │ 105.36 │ 106.78 │ 106.78 │ 2.14109e7 │
│ 2023-04-25 │ 106.61 │ 107.44 │ 104.56 │ 104.61 │ 104.61 │ 3.14081e7 │
│ 2023-04-26 │ 105.56 │ 107.02 │ 103.27 │ 104.45 │ 104.45 │ 3.70682e7 │
│ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │ ⋮ │
│ 2023-05-08 │ 105.795 │ 108.42 │ 105.79 │ 108.24 │ 108.24 │ 1.7266e7 │
│ 2023-05-09 │ 108.78 │ 110.595 │ 107.725 │ 107.94 │ 107.94 │ 2.47824e7 │
│ 2023-05-10 │ 108.55 │ 113.51 │ 108.48 │ 112.28 │ 112.28 │ 4.75335e7 │
│ 2023-05-11 │ 115.86 │ 118.44 │ 114.93 │ 116.9 │ 116.9 │ 5.71151e7 │
│ 2023-05-12 │ 117.0 │ 118.26 │ 116.55 │ 117.92 │ 117.92 │ 3.12725e7 │
│ 2023-05-15 │ 116.49 │ 118.795 │ 116.48 │ 116.96 │ 116.96 │ 2.21079e7 │
│ 2023-05-16 │ 116.83 │ 121.2 │ 116.84 │ 120.09 │ 120.09 │ 3.1756724e7 │
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)