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)))
24×6 TimeArray{Float64,2,Date,Array{Float64,2}} 2020-07-13 to 2020-08-13
│ │ Open │ High │ Low │ Close │ AdjClose │
├────────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ 2020-07-13 │ 1550.0 │ 1577.132 │ 1505.243 │ 1511.34 │ 1511.34 │
│ 2020-07-14 │ 1490.3101 │ 1522.95 │ 1483.5 │ 1520.58 │ 1520.58 │
│ 2020-07-15 │ 1523.13 │ 1535.33 │ 1498.0 │ 1513.64 │ 1513.64 │
│ 2020-07-16 │ 1500.0 │ 1518.6899 │ 1486.3101 │ 1518.0 │ 1518.0 │
│ 2020-07-17 │ 1521.62 │ 1523.4399 │ 1498.42 │ 1515.55 │ 1515.55 │
│ 2020-07-20 │ 1515.26 │ 1570.29 │ 1503.6 │ 1565.72 │ 1565.72 │
│ 2020-07-21 │ 1586.99 │ 1586.99 │ 1554.28 │ 1558.42 │ 1558.42 │
│ 2020-07-22 │ 1560.5 │ 1570.0 │ 1546.1 │ 1568.49 │ 1568.49 │
│ 2020-07-23 │ 1566.97 │ 1571.87 │ 1507.392 │ 1515.6801 │ 1515.6801 │
⋮
│ 2020-08-04 │ 1476.5699 │ 1485.5601 │ 1458.65 │ 1464.97 │ 1464.97 │
│ 2020-08-05 │ 1469.3 │ 1482.41 │ 1463.46 │ 1473.61 │ 1473.61 │
│ 2020-08-06 │ 1471.75 │ 1502.39 │ 1466.0 │ 1500.1 │ 1500.1 │
│ 2020-08-07 │ 1500.0 │ 1516.845 │ 1481.64 │ 1494.49 │ 1494.49 │
│ 2020-08-10 │ 1487.1801 │ 1504.075 │ 1473.08 │ 1496.1 │ 1496.1 │
│ 2020-08-11 │ 1492.4399 │ 1510.0 │ 1478.0 │ 1480.3199 │ 1480.3199 │
│ 2020-08-12 │ 1485.58 │ 1512.386 │ 1485.25 │ 1506.62 │ 1506.62 │
│ 2020-08-13 │ 1510.34 │ 1537.25 │ 1508.005 │ 1522.6123 │ 1522.6123 │
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)