NEWS
PMwR 1.0-1 (2024-10-19)
- change URL to DOI, as requested by CRAN
PMwR 1.0-0
- 'returns': default for 'na.rm' is now FALSE. The
warning about missing values, introduced in version
v0.19-6, is handled by new argument 'na.warn' (with
default FALSE). Note that 'na.rm' had always affected
only a limited number of cases of holding-period return
computations.
- when computing portfolio returns, 'returns' no longer
ignores argument 'pad' when no rebalancing takes place
- various minor changes and documentation updates;
many tests have been added. See the ChangeLog for
all details. The manual at
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html
has also been updated.
PMwR 0.19-6
- 'unit_prices': rename argument 'initial.shares' to
'initial.units', and support its use. The function also
gains arguments 'round.price' and 'round.units'.
- 'returns' now issues a warning when there are NAs in
series and argument 'na.rm' is not explicitly set. This
warning will be removed when the default of 'na.rm' is
set to FALSE in the not-too-distant future version 1.0.
- 'pricetable' supports multivariate zoo series
- various minor changes and documentation updates.
See the ChangeLog for all details. The manual at
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html
has also been updated.
PMwR 0.19-5 (2024-07-21)
- fixed: 'rc' did not compute total contributions correctly
when returns were not sorted in time
- fixed: the zoo method of 'returns' no longer ignores
argument 'na.rm'
- 'is_valid_ISIN' gains an argument 'NA.FALSE', with
default FALSE. With this default, is_valid_ISIN(NA)
evaluates to NA, whereas before an NA would evaluate
to FALSE. To retain the old behaviour, set NA.FALSE
to TRUE. The function also no longer emits a (harmless
but annoying) warning when the check digit of an invalid
ISIN was not a number.
- 'rc' now supports (or where it did so already, gets
documentation for) various computations, notably
for linking single-period returns
- the print methods for summaries of 'NAVseries' have
been improved, notably in the multivariate case
- 'instrument' methods have been added for 'NAVseries'
- experimental: 'as.NAVseries' now splits a
multivariate zoo-series into a list of NAVseries
- documentation updates
PMwR 0.19-4
- the computations for 'position' are more efficient now
- documentation updates
PMwR 0.19-3 (2023-10-19)
- documentation updates. In particular, many help pages
now have links to the revelant manual sections.
(The manual at
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html
has also been updated.)
PMwR 0.19-2
- 'split_trades' gains an argument 'drop.zero', for
dropping zero-amount trades
- 'pl': fix a bug in printing in case of an initial
position but no trades in journal
- 'as.journal(journal)' now evaluates to journal
(instead of giving an error)
- the package now depends on R >= 3.5. R 3.5 was released
in 2018.
- various minor changes and documentation updates.
See the ChangeLog for all details. The manual at
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html
has also been updated.
PMwR 0.19-1 (2023-06-05)
- the package now depends on R >= 3.3. That's because
the macro \doi{} is now used in the docs. R 3.3
was released in 2016, so this requirement appears
not too unreasonable.
- functions ".expand" and ".tree" are no longer
exported, as they are used internally only
- the first argument of the (rarely-used) position
method of 'journal' (i.e. 'journal.position') is
now named 'amount', in alignment with the generic
- helper function '.pl_stats' is now documented
- various documentation updates.
See the ChangeLog for all details. The manual at
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html
has also been updated.
PMwR 0.19-0
- Version 0.19 is intended be the last one before the
release of version 1.0.
- 'returns' gains an argument 'na.rm', currently with
default TRUE, which matches the current behaviour. In a
not-too-distant future version, the default will be
changed to FALSE.
- 'returns' supports timestamps of class 'yearqtr' and
'yearmon', as provided by the package 'zoo'
- 'btest': function 'do.rebalance' may now return a
logical vector with length equal to the number of
assets, indicating which assets to rebalance
- a transpose method is now defined for holding-period
'returns', for the (rare) case that a returns matrix is
to be transposed [before, this had required an explicit
conversion with as.matrix, and otherwise would have
resulted in an error]
- 'rc' ignores missing prices as along as
corresponding weights are zero
- various minor bug fixes and documentation updates.
See the ChangeLog for all details. The manual at
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html
has also been updated.
PMwR 0.18-0 (2022-10-19)
- 'streaks' gains an argument 'relative', with default
TRUE, which is the current behaviour. If FALSE, the
function looks at differences instead of relative
changes (returns), which is useful, for instance, for
interest rates. For an example, see
https://enricoschumann.net/notes/streaks-in-equity-returns-and-yield-changes.html
- 'btest': rebalance arithmetic is performed only for
positions with non-zero change also in period 1,
i.e. in the rare case when burn-in is 0, which
allows NAs in prices. (For periods > 1, this
behaviour had been introduced in version 0.10-0.)
- 'position': if 'when' is not specified, timestamps
are now effectively ignored, even if they are NA
- There is an additional public Git repository at
https://git.sr.ht/~enricoschumann/PMwR
- various minor bug fixes and documentation updates.
See the ChangeLog for all details. The manual at
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html
has also been updated.
PMwR 0.17-0 (2021-10-19)
- the print method for "rebalance" no longer ignores
multipliers [note that this never affected the actual
computations, only the printing of turnover and
transaction values]
- calling 'returns' with a position/weights now warns if
there are missing prices at rebalance times
- experimental: 'rc' provides alternative methods to
compute performance contribution; it also gains
rudimentary support for performance attribution
(Brinson et al.)
- various minor bug fixes and documentation updates.
See the ChangeLog for all details. The manual at
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html
has also been updated.
PMwR 0.16-1 (2021-09-18)
- position: fix computing dates from timestamps in
certain locales (timezones with large UTC offsets)
in case the "when" keyword was used, as in
position(J, when = "endofday")
Thanks go to the CRAN team/Brian Ripley for helping
to pinpoint the problem.
PMwR 0.16-0 (2021-01-19)
- returns: computations for rebalanced portfolios are
more efficient, and function 'returns' now supports
both fixed weights and fixed positions. When
calling 'returns' with 'rebalance.when' and
argument 'weights'/'position', the resulting
'contributions' no longer ignore argument 'pad'.
- 'unit_prices' now supports cashflows for different
ids/accounts, even on the same timestamp. An
attribute 'transactions' is attached: a data.frame
of the transactions, for each id/account.
Redundant columns are no longer returned, but they
can easily be recovered (see Examples for
?unit_prices).
- 'div_adjust' supports several payments on the
same timestamp
- various minor bug fixes and documentation updates.
See the ChangeLog for all details. The manual at
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html
has also been updated.
PMwR 0.15-1
- div_adjust: fix handling of dividends that occur on
the first timestep
PMwR 0.15-0 (2020-10-19)
- 'valuation': argument 'price.table' has been renamed:
price.table => vprice
The function also gains a new argument 'use.names',
with default FALSE. To keep the old behaviour,
simply rename the argument.
If 'use.names' is set to TRUE, column names are
matched against instruments. In effect, argument
'vprice' in 'valuation' behaves in essentially the
same way as argument 'vprice' of function 'pl'.
For examples, see ?valuation and
https://enricoschumann.net/notes/valuing-positions.html
- when a subset is taken from a 'pricetable', the
result is no longer a pricetable but a numeric
matrix. The behaviour is controlled by a new
argument 'as.matrix'. For the old bevahiour, set
this argument to FALSE, i.e. say
p[...., ...., as.matrix = FALSE]
- the PMwR package now explicitly depends on R version >= 3.2
- new function 'is_valid_SEDOL'
- 'pl': it is now checked that custom valuation dates
passed via 'along.timestamp' are in ascending order
(and they now get sorted if they are not)
- 'rebalance' now warns about NAs in the 'price' input
- the summary method for journals is now properly
documented
- various minor bug fixes and documentation updates.
See the ChangeLog for all details. The manual at
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html
has also been updated.
PMwR 0.14-0 (2020-03-11)
- 'btest': handling of argument 'do.rebalance' has
been fixed. It had not worked properly when set to
"firstofquarter" or "lastofquarter". Thanks to
Lutchmie Narine for reporting.
- 'btest': 'variations.settings' gains an option
'expand.grid'. If FALSE, 'btest' does not compute
combinations of variations. See
https://enricoschumann.net/notes/backtest-strategy-on-different-datasets.html
for an example.
- 'streaks': the function now also allows to compute
streaks relative to a benchmark
- 'streaks': default value for 'down' has been
changed to '-up'
- 'journal': the summary method now allows
aggregation by timestamp and instrument
- objects of class 'position' support the unary '!'
operator: the result is a logical matrix of the
same dimension as the original position
- 'div_adjust': support several splits on a single
timestamp
- 'returns': the 'weights' argument needs no longer
sum to one
- 'NAVseries': the toLatex method for summaries
gains an argument 'include.bm', with default FALSE
- various minor bug fixes and documentation
updates. See the ChangeLog for all details.
PMwR 0.13-0
- 'btest': fix handling of initial position -- with
an initial position specified and burn-in set to
zero, the suggested position now equals the
initial position (as it does for a burn-in greater
than zero)
- 'NAVseries': fix method, which did not work
properly when 'start' or 'end' were not included
in 'timestamp'
- 'NAVseries': add a 'lines' method
- 'returns': period "total" is now an alias for
"itd" (inception to date)
- 'journal': argument 'reverse', for subsetting, has
been renamed to 'invert' ('reverse' still works,
but with a warning, and will be removed in the
future). Also, for consistency, the argument now
applies to numeric and logical subscripts as well.
- various documentation updates; new features are
now described at
https://enricoschumann.net/notes/PMwR/
PMwR 0.12-0 (2019-08-26)
- 'returns': fix returns computation for zoo series
with a lag different from 1 and no padding (the
timestamp of the resulting returns series was wrong)
- 'returns': returns will now be computed for period
"itd" even when no timestamp is provided
- 'pl' gains a new argument 'footnotes' , with
default TRUE. If FALSE, less information is
printed for 'pl' objects. Also, open positions no
longer produce a warning ("sum(amount) is not
zero"), but only a message, which is only shown
when 'footnotes' is TRUE.
- 'pricetable' supports shortcuts for setting up a
pricetable with a single timestamp but several
instruments. See the Examples at ?pricetable.
- 'valuation' now warns when there are missing
values in 'multiplier', and gains an argument
'do.warn' to switch off the warning
- 'btest' works in more cases with NAs in prices:
when 'convert.weights' is TRUE, only non-zero
weights are converted. So as long as a strategy
does not specify positions in series with
missing prices, positions and so on can be
computed.
- experimental: 'btest' now checks the 'dim'
attribute of 'prices' (after having them unlisted,
in the case of several assets). Only if none is
found, 'as.matrix' is called. This allows
alternative classes to be used for 'prices', as
long as they define subsetting via
integers/logicals in the same way as numeric
matrices.
- there is now a textutils::toHTML method for
'position'; it currently only supports positions
at a single point in time
- see the ChangeLog for all details
PMwR 0.11-1 (2019-06-03)
- div_adjust: fix handling of dividends for case
additive = FALSE
- rebalance: 'drop.zero' now drops instruments for
which 'current' and 'target' are the same, i.e. for
which no rebalancing is necessary (before, it would
only drop instruments for which both 'current' and
'target' are zero)
- a tutorial on backtesting is available at
https://ssrn.com/abstract=3374195
PMwR 0.11-0 (2019-04-01)
- returns: 'weights' may now also be a matrix with as
many rows as 'rebalance.when'. Also, rebalancing at
the first timestamp is no longer implied (see
ChangeLog entry of 2018-11-09 for details).
- position: new argument 'use.names', which allows to
use names/colnames as instrument information. Also,
matrix input is now treated specially; see examples at
https://enricoschumann.net/notes/computing-positions.html
- NAVseries: new argument 'drop.NA'. Also, if 'NAV'
inherits from 'btest', the function now calls
'as.NAVseries.btest'.
- summary.NAVseries: new argument 'bm' ("benchmark").
If set, a 'tracking.error' is computed. The summary
method now can handle several NAVseries as inputs,
which allows easier comparison of series.
- as.NAVseries.btest: method gains optional arguments
'instrument', 'title' and 'description'
- plot_trading_hours.R: fix axis-tick positions when
'label' is "days"
- functions 'scaleTrades' and 'splitTrades' have
finally been removed (they had not been exported
for a long time; see ChangeLog entry of 2017-06-23).
Use drop-in replacements 'scale_trades' and
'split_trades' instead.
- split_trades: 'price' may now be missing (in which
case NA is used)
- various documentation updates/fixes; see the
ChangeLog for all details.
PMwR 0.10-0
- btest: support automatic computation of
variations, both serially and in parallel. See new
arguments 'variations', 'variations.settings'
and 'replications'. See some examples at
https://enricoschumann.net/notes/parallel-backtests.html
- new generic function 'streaks' with methods for
zoo, NAVseries and numeric vectors
- new vignette on 'drawdowns and streaks'
- pl: In several cases in which profit/loss was set
to NA, it now defaults (more appropriately) to 0.
For instance, with a custom timestamp the
realised/unrealised profit/loss before the first
trade is now 0, not NA.
- quote32: the function now also recognises a
colon (:) as a separator. The function can now parse
more variations; see examples at
https://enricoschumann.net/notes/treasury-bond-quotes.html
- instrument: new replacement method
'instrument<-.journal'
- drawdowns: new method for NAVseries
- valuation.position method is now exported (though
still experimental)
- pl.btest: fixed passing of additional arguments
- returns: argument 'period' may also be 'hourly'
- scale1: argument 'when' may also be 'last'
- various documentation updates/fixes; see the
ChangeLog for all details. The manual at
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html
has also been updated.
PMwR 0.9-0
- summary.NAVseries: argument 'monthly' has been
renamed:
monthly => monthly.vol
- summary.NAVseries: new argument 'assume.daily',
with default FALSE; when TRUE, numeric
timestamps are considered daily data, e.g. for
annualising returns
- NAVseries: add a 'window' method
- NAVseries: summary now includes recovery from
drawdown
- journal: add an 'all.equal' method
- btest: new argument 'include.timestamp', with
default TRUE
- returns: for portfolio returns, if a timestamp
is specified, 'rebalance.when' is matched
against this timestamp (e.g., 'rebalance.when'
may be specified as Date when the timestamp is
of class Date)
PMwR 0.8-0
- drawdowns: new generic function with methods for
zoo and numeric vectors
- plot_trading_hours: improved support for daily
series (interval becomes "1 day", etc.)
- pl: new argument 'do.sum'; if TRUE, P/L across
instruments is summed
- pl: new argument 'pl.only'; if TRUE, return P/L as
a numeric vector
- btest: if a timestamp of class Date or POSIXct is
specified, burn-in 'b' may be an actual timestamp
- rebalance: new argument 'current.weights' with
default FALSE; if TRUE, the current portfolio is
assumed to be a vector of weights
- returns: add method for as.data.frame for
holding-period returns
- the manual has been substantially revised. See
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html
PMwR 0.7-0
- scale1: objects that are modified by 'scale1' gain
an attribute "scale1_origin", which provides the
timestamp at which scaling starts
- btest: the handling of argument 'lag' has been
fixed (the argument had been ignored in some
situations)
- quote32: the function now also recognises a
colon (:) as a separator
- pl: new method for data frames
- New vignettes: "Computing returns", "Treasury
Quotes with 1/32 Fractions" and "Profit/Loss for
Open Positions"
PMwR 0.6-0
- btest: two arguments have been renamed
tradeOnOpen => trade.at.open
assignInGlobals => Globals
- plot_trading_hours: two arguments have been renamed
excludeWeekends => exclude.weekends
do.plotAxis => do.plot.axis
- Function 'isValidISIN' is no longer available; use
the drop-in replacement 'is_valid_ISIN' instead.
- Byte-compilation is now on by default.
- New vignette 'FinTeX'.
- New datasets DAX and REXP.
- New generic function instrument, also for
replacement.
- NAVseries: new method 'toLatex.summary.NAVseries';
see the vignette for examples.
- pricetable: the function is now a generic, with a
default and a zoo method. Methods for pricetable
have been added (print, '[', as.matrix).
- quote32: the function now recognises both a hyphen
(-) or single quote (') as a separator
- A more-comprehensive list of changes is available
in the ChangeLog:
https://enricoschumann.net/R/packages/PMwR/ChangeLog
PMwR 0.5-0
- A number of functions have been renamed:
isValidISIN => is_valid_ISIN
closeOnFirst => close_on_first
plotTradingHours => plot_trading_hours
scaleToUnity => scale_to_unity
scaleTrades => scale_trades
splitTrades => split_trades
twExposure => tw_exposure
For the time being, the old functions can still be
called with
PMwR:::<old-fun-name>
but the old names shall be removed in a future
version.
- New 'as.matrix' method for monthly holding-period
returns, which places returns into a numeric matrix
with years in rows and months in columns. For other
holding periods, as.matrix is called on the raw
numeric data.
- returns: argument 'period' may also be 'quarterly'
or a single year, such as "2007"
- btest: 'do.signal' and 'do.rebalance' can also be
the string 'lastofquarter' to rebalance on last day
of quarter; or 'firstofquarter' to rebalance on
first day of quarter
- A more-comprehensive list of changes is available
in the ChangeLog:
https://enricoschumann.net/R/packages/PMwR/ChangeLog
PMwR 0.4-0
- New functions 'unit_prices', for computing
time-weighted returns, and 'rc', for computing
return contributions.
- New helper functions '.expand' and '.tree', for
displaying account hierachies.
- Various new methods: 'as.data.frame.position',
'summary.journal', 'as.zoo.position', 'pl.btest',
'toOrg.journal'.
- Support for (some) arithmetic operations on
'position' and 'quote32' objects.
- Updated manual chapter on computing returns:
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html#computing-returns
- Updated manual chapter on backtesting:
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html#backtesting
PMwR 0.3-4
- Moved function 'runStats' to a separate package 'runStats'
https://enricoschumann.net/R/packages/runStats/ .
The PMwR package contains only R code now, so no
special tools are required for installing from source.
- There is a public Git repository at
https://github.com/enricoschumann/PMwR
PMwR 0.1-96
- A draft of the manual chapter on computing profit
and loss is available:
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html#profit-and-loss
PMwR 0.1-90
- A draft of the manual chapter on scaling series is
available:
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html#scaling-series
PMwR 0.1-89
- A draft of the manual chapter on computing returns
is available:
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html#computing-returns
PMwR 0.1-81
- The PMwR package provides utilities for backtesting
investment and trading strategies, computing
profit-and-loss and returns, reporting, and more.
The package is still under heavy development.
Please see the ChangeLog for updates.