| Title: | Slide Automation for Trading Tables, Listings and Figures |
|---|---|
| Description: | A downstream package of 'autoslider.core' that produces tables, listings and figures for finance trading, in the same style as 'autoslider'. Where 'autoslider.core' automates clinical study outputs, this package automates trading outputs from price and trade data: performance tables, equity curves and trade listings. |
| Authors: | Joe Zhu [aut, cre] |
| Maintainer: | Joe Zhu <[email protected]> |
| License: | Apache License (>= 2.0) |
| Version: | 0.0.1 |
| Built: | 2026-10-02 13:07:55 UTC |
| Source: | https://github.com/shajoezhu/autoslider.trade |
Trading tables, listings and figures, downstream of autoslider.core.
Outputs follow the autoslider naming convention: t_*_slide() for tables,
l_*_slide() for listings and g_*_slide() for figures.
Maintainer: Joe Zhu [email protected]
Authors:
Joe Zhu [email protected]
A synthetic daily OHLCV series for three NZX instruments, used by the
candlestick figure and its tests. homepage-stock stores no price history
(only the ticker list) and fetching market data is out of scope for this
package, so the series is generated deterministically.
eg_ohlceg_ohlc
A data frame with 360 rows and 7 columns:
Trading code, one of AIA.NZ, AIR.NZ, ANZ.NZ
Trade date, Date
Opening price, numeric
Intraday high, numeric
Intraday low, numeric
Closing price, numeric
Shares traded, numeric
Synthetic data created for this package.
A small set of daily closing prices for three trading codes, used in examples and tests.
eg_priceseg_prices
A data frame with 15 rows and 3 columns:
Trading code, one of AAA, BBB, CCC
Trade date, Date
Closing price, numeric
Synthetic data created for this package.
A small set of trades used in examples and tests.
eg_tradeseg_trades
A data frame with 5 rows and 5 columns:
Trading code
Trade date, Date
BUY or SELL
Quantity traded, integer
Execution price, numeric
Synthetic data created for this package.
A richer take on the quantmod::chartSeries plot used in homepage-stock:
daily candlesticks with Bollinger Bands, moving averages and high/low
annotations in the top panel, then a volume panel with a volume moving
average, an RSI panel and a MACD panel. The four panels are stacked with
cowplot.
g_candle_slide( prices, symbol = code_col(), date = "DATE", open = "OPEN", high = "HIGH", low = "LOW", close = "CLOSE", volume = "VOLUME", ma = c(20L, 50L), title = "Candlestick" )g_candle_slide( prices, symbol = code_col(), date = "DATE", open = "OPEN", high = "HIGH", low = "LOW", close = "CLOSE", volume = "VOLUME", ma = c(20L, 50L), title = "Candlestick" )
prices |
|
symbol |
|
date |
|
open |
|
high |
|
low |
|
close |
|
volume |
|
ma |
|
title |
|
Up days are drawn in green and down days in red. When more than one trading code is supplied, only the first is plotted and the rest are ignored with a message.
A ggplot object, ready to be rendered with generate_slides()
g_candle_slide(eg_ohlc) # Only the moving averages, no Bollinger Bands shown as separate colour g_candle_slide(eg_ohlc, ma = 20L)g_candle_slide(eg_ohlc) # Only the moving averages, no Bollinger Bands shown as separate colour g_candle_slide(eg_ohlc, ma = 20L)
Plot the price history of one or more trading codes. By default every instrument is rescaled to start at 1 so that several instruments with very different price levels can be compared on the same axes.
g_equity_slide( prices, symbol = code_col(), date = "DATE", close = "CLOSE", normalize = TRUE, title = "Equity Curve" )g_equity_slide( prices, symbol = code_col(), date = "DATE", close = "CLOSE", normalize = TRUE, title = "Equity Curve" )
prices |
|
symbol |
|
date |
|
close |
|
normalize |
|
title |
|
A ggplot object, ready to be rendered with generate_slides()
g_equity_slide(eg_prices) # Absolute prices instead of a common starting point g_equity_slide(eg_prices, normalize = FALSE)g_equity_slide(eg_prices) # Absolute prices instead of a common starting point g_equity_slide(eg_prices, normalize = FALSE)
A listing of executed trades, keyed by trading code. Each trade is shown with its date, side, quantity and price, plus the computed notional value.
l_trades_slide(trades, symbol = code_col())l_trades_slide(trades, symbol = code_col())
trades |
|
symbol |
|
A listing_df object, ready to be rendered with generate_slides()
l_trades_slide(eg_trades)l_trades_slide(eg_trades)
The full list of New Zealand instruments the user tracks on their
homepage-stock kanban. Copied verbatim from that repository (168
instruments); non-ASCII company names are preserved.
nz_tickersnz_tickers
A data frame with 168 rows and 2 columns:
Company or fund name, character
Trading code on the NZX, e.g. AIA.NZ, character
Copied from homepage-stock/data/nz_list.csv.
Rendered slide decks are easier to share as PDF. pptx_to_pdf() converts
one or more .pptx files, choosing automatically between the two
converters it can find: LibreOffice (soffice --headless) or Microsoft
PowerPoint through Windows COM automation. The latter is what makes the
function usable from WSL, where no Linux converter is installed but a
Windows Office is reachable.
pptx_to_pdf(path, output_dir = NULL)pptx_to_pdf(path, output_dir = NULL)
path |
|
output_dir |
|
A character vector of the created PDF paths, invisibly
if (interactive()) { generate_slides(t_performance_slide(eg_prices), "performance.pptx") pptx_to_pdf("performance.pptx") }if (interactive()) { generate_slides(t_performance_slide(eg_prices), "performance.pptx") pptx_to_pdf("performance.pptx") }
A table of per-instrument summary statistics: the number of observations, the first and last price, the return over the period and the maximum drawdown, expressed as percentages.
t_performance_slide( prices, symbol = code_col(), date = "DATE", close = "CLOSE", digits = 2L )t_performance_slide( prices, symbol = code_col(), date = "DATE", close = "CLOSE", digits = 2L )
prices |
|
symbol |
|
date |
|
close |
|
digits |
|
An rtables object, ready to be rendered with generate_slides()
t_performance_slide(eg_prices)t_performance_slide(eg_prices)