%% \VignetteIndexEntry{Overview of the PMwR package}
\documentclass[a4paper,11pt]{article}
\usepackage[left = 3cm, top = 2cm, bottom = 2cm, right = 4cm]{geometry}
\usepackage[noae,nogin]{Sweave}
\usepackage{libertine}
\usepackage[scaled=0.9]{inconsolata}
\usepackage[T1]{fontenc}
\renewcommand*\familydefault{\sfdefault}
\usepackage{amsmath,amstext}
\usepackage{hyperref}
\usepackage{natbib}
\usepackage{xcolor}
\usepackage{framed}
\usepackage[flushmargin]{footmisc}
\definecolor{grau2}{rgb}{.2,.2,.2}
\definecolor{grau7}{rgb}{.7,.7,.7}
\DefineVerbatimEnvironment{Sinput}{Verbatim}{}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{frame=single,
  xleftmargin=0em, formatcom=\color{grau2},rulecolor=\color{grau7}}
\DefineVerbatimEnvironment{Scode}{Verbatim}{xleftmargin=2em}
\fvset{listparameters={\setlength{\topsep}{0pt}}}
\renewenvironment{Schunk}{\vspace{\topsep}}{\vspace{\topsep}}
\SweaveOpts{keep.source = TRUE, eps = TRUE}

<<echo=false>>=
options(continue = "  ", digits = 3, width = 60, useFancyQuotes = FALSE)
pv <- packageVersion("PMwR")
pv <- gsub("(.*)[.](.*)", "\\1-\\2", pv)
@

\begin{document}
\title{An Overview of the PMwR Package}
\author{Enrico Schumann\\\url{es@enricoschumann.net}}

{\raggedright{\LARGE An Overview of the PMwR Package}}\hspace*{\fill}
{\footnotesize Package version \Sexpr{pv}}\medskip

\noindent Enrico Schumann\\
\noindent \url{es@enricoschumann.net}\\
\bigskip

<<echo=false,results=hide>>=
library("PMwR")
library("zoo")
try(tinytest::test_package("PMwR"), silent = TRUE)
@

\noindent The aim of \textsc{pm}w\textsc{r} is to
provide a small set of reliable, efficient and convenient
tools that help in processing and analysing trade and
portfolio data. The package does not provide a complete
application to be used `as is', but tools
for creating such an application.

\noindent The package grew out of various pieces of
software that I have written since 2008.%
\footnote{In the unlikely case that you come across a
  really-old version of the package: it was called
  \textsc{pm} before 2012.} %
The package is under active development and changes
frequently, simply because the code has been written
over many years and is in need of being groomed for
general use.%
\footnote{
<<echo=false,results=hide>>=
test.rep <- readLines(system.file("unitTests/test_results.txt",
                                  package = "PMwR"))
nt <- gsub(".*\\(([0-9]+) checks?\\).*", "\\1",
           test.rep[grep("\\(\\d+ checks?\\)", test.rep)])

if (requireNamespace("tinytest")) {
    tinytest.results <- try(suppressMessages(
        suppressWarnings(tinytest::test_package("PMwR"))))
    if (inherits(tinytest.results, "try-error"))
        nt <- "several hundred"
    else
        nt <- nrow(as.data.frame(tinytest.results)) +
            sum(as.numeric(nt))
} else
    nt <- "several hundred"
@
Even if \textsc{pm}w\textsc{r} is under development:
the package is to provide well-documented and reliable
code.  For all computations, unit tests are included.
As of package version %
\Sexpr{pv}, there are \Sexpr{nt} tests
included.  These tests are stored in subdirectory
\texttt{tinytest}.} %

Specifically, interfaces to functions may not be stable
yet (e.g., argument names are currently being made
consistent across functions); in some cases, generic
functions may be introduced. The \textbf{recommended
  practice} is therefore to \textbf{explicitly name
  arguments in function calls} and not pass arguments
by position. Any changes in argument names will be
documented in the \textsc{news} file
(\,\url{http://enricoschumann.net/R/packages/PMwR/NEWS}\,)
and so can be easily followed. More details
are in the ChangeLog
(\,\url{http://enricoschumann.net/R/packages/PMwR/ChangeLog}\,).

The latest version of the package is available from
\url{http://enricoschumann.net/R/packages/PMwR/}. To install the
package from within R, type
<<eval=false, results=hide>>=
install.packages('PMwR',
                 repos = c('http://enricoschumann.net/R', getOption('repos')))
@
within a session. The package depends on several other
packages, which can be obtained from the same
repository and from \textsc{cran}.

There is currently no automatic Windows build for the
latest version. If you wish to use the package on
Windows and have problems building/installing it, then
please contact me and I will provide you with a Windows
version.


\section*{What the package provides}

\begin{description}
\item[Keep track of transactions] The package provides
  functions that work with journals (sometimes called
  blotters). See \texttt{?journal} and
  \texttt{?position}.
\item[Testing strategies] See \texttt{?btest}.
\item[Computing \textsc{p}\&\textsc{l} and returns] See
  \texttt{?pl}, \texttt{?returns}, \texttt{?rc} and
  \texttt{?unit\_prices}.
\end{description}

\noindent All details are in the manual:

\begin{center}
\url{http://enricoschumann.net/R/packages/PMwR/manual/PMwR.html}
\end{center}

\noindent I am grateful for comments, suggestions and
corrections.  Please send bug reports directly to the
package maintainer, for instance by using
\texttt{bug.report}.\index{bug reports}
<<eval=false>>=
utils::bug.report("[PMwR] Unexpected behaviour in function <XXX>",
                  maintainer("PMwR"), package = "PMwR")
@

%% \section*{Examples}

%% \subsection*{Keeping track of transactions}

%% \subsection*{Testing investment strategies}

%% \subsection*{Computing P\&L and Returns}

\end{document}
