Note: This class is a rough first pass and will change drastically in future releases.
An object of the class "tradelist" containing a data frame of trades and a data frame of supplementary information.
Objects can be created by calls of the form
new("tradelist", orig, target, ...)
.
type
:Object of class "character"
specifying the type of the tradelist. Must be "all"
or
"ranks"
.
id.var
:Object of class "character"
containing the name of the column in the data
slot to be
used as a unique identifier.
price.var
:Object of class "character"
specifying the column in the data
slot to be used as the
reference price. Defaults to price.usd
.
candidates
:Object of class "data.frame"
containing one row for each candidate trade.
ranks
:Object of class "data.frame"
where
candidate trades have been interleaved by trade type (B,S,X,C) and
assigned a unique rank, "rank.t".
chunks
:Object of class "data.frame"
that
contains one row for each chunk, a smaller portion of an order.
swaps
:Object of class "data.frame"
where buys
and sells have been matched with other shorts and covers of similar
market value and desirability.
swaps.actual
:Object of class "data.frame"
where the least desirable chunks that would exceed if
"turnover" if ordered have been removed.
actual
:Object of class "data.frame"
where the
chunks have been rolled up into one row/order per security.
final
:Object of class "trades"
containing
the most basic information on the set of trades in the tradelist.
chunks.actual
:Object of class "data.frame"
where "swaps" have been turned back into chunks and each chunk has
its own row.
sorts
:Object of class "optionalList"
which may
be interpreted as a list of key-value pairs. The key is the name of
the sort and must exist as a column in the "data" slot. The numeric
value expresses the relative weight of the sort.
rank.sorts
:Object of class "list"
, where the
names of the elements are the names of the sorts defined in the
"sorts" list and the elements are data frames, each of which
contains a ranking of the candidate trades created by applying an
individual sort.
regions
:Object of class "character"
chunk.usd
:Object of class "numeric"
that
expresses the minimum unsigned market value in US dollars of a
chunk. Defaults to $10,000.
trade.usd.min
:Object of class "numeric"
that
expresses the minimum unsigned market value a trade must have in
order to be placed. Trades of lower market value are removed from
the "candidates" data.frame and appended to the "restricted" data frame.
restrictions
:Object of class "data.frame"
with
1 row for each trade and three columns, "id", "type", and
"reason". "id" uniquely identifies the trade, "type" accepts a
value of B, S, C, or X (buy, sell, cover, or short), expressing
the type of trade that is prohibited, and "reason" is a label
expressing why the restriction exists.
restricted
:Object of class "data.frame"
that
contains one row for every trade for which a restriction exists
to.equity
:Object of class "logical"
expressing whether or not the algorithm should trade towards the
value of target.equity
turnover
:Object of class "numeric"
that
expresses the maximum unsigned market value of all trades effected in
one session.
tca
:Object of class "character"
expressing
whether or not to use trade cost adjustment.
rank.gain.min
:Object of class "numeric"
specifying the minimum amount of difference between two trades'
rank required in order for the pair to be considered as a swap.
target.equity
:Object of class "numeric"
expressing the unsigned market value of the target portfolio.
mv.long.orig
:Object of class "numeric"
The
market value of the long side of the original portfolio.
mv.short.orig
:Object of class "numeric"
The
unsigned market value of the short side of the original portfolio
unrestricted
:Object of class "logical"
specifying whether any restrictions should be applied, including
checks for price and volume.
data
:Object of class "data.frame"
containing
supplementary information about the "tradelist". Must contain an
"id" column, a "price.usd" column, a "volume" column, and a column
named after each element listed in "sorts".
verbose
:Object of class "logical"
controlling
whether methods on this object should be verbose. Defaults to FALSE.
signature(object = "tradelist")
: Returns a
vector with the following elements: "id", "side", "shares", "mv",
names(object@sorts), and "rank.t"
signature(object = "tradelist")
: Rolls up the
chunks calculated in calcChunksActual
into single orders and stores the
result as a data frame in the "actual" slot.
signature(object = "tradelist", orig =
"portfolio", target = "portfolio")
: Builds a data frame of
candidate trades with one row per trade by determining which positions
have different numbers of shares in the original and target
portfolios. Removes trades in the "restrictions" data frame,
trades with a market value below "trade.usd.min", and trades that
would cause a side change in one session, and appends these trades
to the "restricted data frame."
signature(object = "tradelist")
:
Turns the swaps calculated in calcSwapsActual
back into
chunks and stores the results in a data frame in the
"actual.chunks" slot.
signature(object = "tradelist")
: Examines
the data frame stored in the "ranks" slot, breaks the
candidate trades into chunks of size "chunk.usd" or
smaller, and stores the results in the "chunks" slot
signature(object = "tradelist")
:
Examines the data frame stored in the "swaps" slot and removes
swaps, which had they been processed as orders, would have
exceeded the specified "turnover" of the tradelist. Stores the results as a data
frame in the "swaps.actual" slot.
signature(object = "tradelist")
: Using the
"chunks" data frame created by the calcChunks
method, pairs
attractive chunks with other attractive chunks of similar market
value and stores the results as a data frame in the swaps
slot.
signature(object = "tradelist")
: Using
information from the candidates
data frame, interleaves
the trades and calculates an absolute rank for each trade,
"rank.t". Stores the results in the ranks
slot
signature(object = "tradelist")
:
Returns a vector of class character
containing the
following elements: "id", "orig", "target", "side", "shares", "mv"
signature(object = "tradelist")
: Returns a
vector of class character
containing the following
elements: rankCols(object), "tca.rank", "chunk.shares",
"chunk.mv", "chunk".
signature(object = "tradelist")
: Creates a
data frame of dummy chunks for a given side and dollar amount
(total.usd). The supplied dollar amount, together with the tradelist
object's chunk size, determines the number of rows in the resulting
data frame.
signature(.Object = "tradelist")
:
Transparently calls calcCandidates
, calcRanks
, calcChunks
,
calcSwaps
, calcSwapsActual
, calcChunksActual
, calcActual
to construct the tradelist
object.
signature(object = "tradelist")
: Returns a
vector of class character
containing the following
elements: "id", "orig", "target", "side", "shares", "mv", names(object@sorts)
,
"rank.t"
signature(object = "tradelist")
: Returns a
vector of class character
containing the following
elements: candidatesCols(object)
, "reason".
signature(object = "tradelist", id =
"character")
: Returns detailed information regarding a security in
the tradelist.
signature(object = "tradelist")
: Prints a
detailed summary of tradelist attributes.
signature(object = "tradelist")
: If the
market value of the side passed as the "side" parameter to this
function is is greater than market value of the side as specified
by the "value" parameter, excises the least desirable trades on
that side until the the market value of that side is less than
value. Returns a copy of the data frame stored in the "actual"
slot with the trades that meet the forementioned conditions
removed.
Daniel Gerlanc daniel@gerlanc.com