tradelist-class {portfolio} | R Documentation |
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
:"character"
specifying the type of the tradelist. Must be "all"
or
"ranks"
.id.var
:"character"
containing the name of the column in the data
slot to be
used as a unique identifier. candidates
:"data.frame"
containing one row for each candidate trade.ranks
:"data.frame"
where
candidate trades have been interleaved by trade type (B,S,X,C) and
assigned a unique rank, "rank.t".chunks
:"data.frame"
that
contains one row for each chunk, a smaller portion of an order.swaps
:"data.frame"
where buys
and sells have been matched with other shorts and covers of similar
market value and desirability.swaps.actual
:"data.frame"
where the least desirable chunks that would exceed if
"turnover" if ordered have been removed.actual
:"data.frame"
where the
chunks have been rolled up into one row/order per security.final
:"trades"
containing
the most basic information on the set of trades in the tradelist.chunks.actual
:"data.frame"
where "swaps" have been turned back into chunks and each chunk has
its own row.sorts
:"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
:"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
:"character"
chunk.usd
:"numeric"
that
expresses the minimum unsigned market value in US dollars of a
chunk. Defaults to $10,000.trade.usd.min
:"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
:"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
:"data.frame"
that
contains one row for every trade for which a restriction existsto.equity
:"logical"
expressing whether or not the algorithm should trade towards the
value of target.equity
turnover
:"numeric"
that
expresses the maximum unsigned market value of all trades effected in
one session.tca
:"character"
expressing
whether or not to use trade cost adjustment.target.equity
:"numeric"
expressing the unsigned market value of the target portfolio.mv.long.orig
:"numeric"
The
market value of the long side of the original portfolio.mv.short.orig
:"numeric"
The
unsigned market value of the short side of the original portfoliounrestricted
:"logical"
specifying whether any restrictions should be applied, including
checks for price and volume.data
:"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".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" slotsignature(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
slotsignature(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