pq_plot
provides an easy way to create interactive charts for time series dataset based on predefined formats.
pq_plot(dt, chart_type = "line", x = "date", y = "close", yb = NULL,
date_range = "max", yaxis_log = FALSE, title = NULL, addti = NULL,
nsd_lm = NULL, markline = TRUE, orders = NULL, arrange = list(rows =
NULL, cols = NULL), theme = "default", ...)
a list/dataframe of time series dataset
chart type, including line, step, candle.
column name for x axis
column name for y axis
column name for baseline
date range of x axis to display. Available value includes '1m'-'11m', 'ytd', 'max' and '1y'-'ny'. Default is max.
whether to display y axis values in log. Default is FALSE.
chart title. It will added to the front of chart title if it is specified.
list of technical indicators or numerical columns in dt. For technical indicator, it is calculated via pq_addti
, which including overlays and indicators.
number of standard deviation from linear regression fitting values.
whether to display markline. Default is TRUE.
a data frame of trade orders, which including columns of symbol, date, side, prices, and quantity.
a list. Number of rows and columns charts to connect. Default is NULL.
name of echarts theme, see details in e_theme
ignored
# \donttest{
# single serie
library(data.table)
library(pedquant)
data(dt_ssec)
# line chart (default)
e1 = pq_plot(dt_ssec, chart_type = 'line') # line chart (default)
e1[[1]]
#> NULL
# add technical indicators
e2 = pq_plot(dt_ssec, addti = list(
sma = list(n = 200),
sma = list(n = 50),
volume = list(),
macd = list()
))
e2[[1]]
#> NULL
# linear trend with yaxis in log
e3 = pq_plot(dt_ssec, nsd_lm = c(-0.8, 0, 0.8), markline=FALSE)
e3[[1]]
#> NULL
# multiple series
data(dt_banks)
setDT(dt_banks)
dt_banksadj = md_stock_adjust(dt_banks)
# linear trend
elist = pq_plot(dt_banksadj)
e4 = pq_plot(dt_banksadj, arrange = list(rows=1, cols=1))
e4[[1]]
#> NULL
# orders
b2 = dt_banks[symbol %in% c('601988.SH', '601398.SH')]
b2orders = b2[sample(.N, 20), .(
symbol, date, prices=close,
side = sample(c(-1, 1), 20, replace=TRUE),
term = sample(c(10, 20), 20, replace=TRUE)
)]
e5 = pq_plot(b2, orders=b2orders)
e5[[1]]
#> NULL
e6 = pq_plot(b2, orders=b2orders, arrange = list(rows=1, cols=1))
e6[[1]]
#> NULL
# }