Compute realized gains and realized losses as either simple counts, total quantities, expected returns and financial duration.
realized_count(
portfolio_quantity,
portfolio_price,
transaction_quantity,
transaction_price,
transaction_type,
allow_short = TRUE,
realized_only = FALSE
)
realized_total(
portfolio_quantity,
portfolio_price,
transaction_quantity,
transaction_price,
transaction_type,
allow_short = TRUE,
realized_only = FALSE
)
realized_value(
portfolio_quantity,
portfolio_price,
transaction_quantity,
transaction_price,
transaction_type,
allow_short = TRUE,
realized_only = FALSE
)
realized_duration(
portfolio_quantity,
portfolio_price,
transaction_quantity,
transaction_price,
transaction_type,
previous_transaction_datetime,
previous_datetime,
transaction_datetime,
allow_short = TRUE,
realized_only = FALSE
)
realized_compute(
portfolio_quantity,
portfolio_price,
transaction_quantity,
transaction_price,
transaction_type,
previous_transaction_datetime,
previous_datetime,
transaction_datetime,
transaction_asset,
allow_short = TRUE,
realized_only = FALSE,
method = "all"
)
realized_empty(transaction_asset, method = "all")
Numeric vector. The portfolio quantities of assets into the investor's portfolio.
Numeric vector. The portfolio prices of assets into the investor's portfolio.
Numeric value. The quantity of the traded asset.
Numeric value. The market price of the traded asset.
Character string. Either "B" = buy or "S" = sell.
Logical. If TRUE short positions are allowed, otherwise only long positions are allowed.
Logical. If TRUE only realized gains and realized losses are computed. Otherwise also paper gains and paper losses on excess quantity of the traded asset are computed.
POSIXct value. The portfolio date-time related to the last transaction of the traded asset.
POSIXct value. The date-time of the last transaction performed by the investor.
POSIXct value. The date-time at which the transaction is going to occur.
Character string. The name of the traded asset.
Character string. The method used to compute papers. Allowed values are "count", "total", "value", "duration" and "all".
The described functions have different return behaviors
realized_compute
returns a data frame
containing the values of realized and paper gains and losses computed by
means of the chosen method on each portfolio assets.
realized_count
returns a named vector containing the values
of realized and paper gains and losses computed using the count method.
realized_total
returns a named vector containing the values
of realized and paper gains and losses computed using the total method.
realized_value
returns a named vector containing the values
of realized and paper gains and losses computed using the value method.
realized_duration
returns a named vector containing the values
of realized and paper gains and losses computed using the duration method.
realized_empty
returns a named vector containing empty values
of realized and paper gains and losses computed using the chosen method.
In particular:
RG_"method"
contains Realized Gains results
RL_"method"
contains Realized Losses results
PG_"method"
contains Paper Gains results
PL_"method"
contains Paper Losses results
realized_count
: Computation, as simple counts, of realized
gains and realized losses of the traded asset.
realized_total
: Computation, as total quantity, of realized
gains and realized losses of the traded asset.
realized_value
: Computation, as expected return, of
realized gains and realized losses of the traded asset.
realized_duration
: Computation, as financial duration, of
realized gains and realized losses of the traded asset.
realized_compute
: Wrapper that calls other realized_. functions to
compute realized gains and realized losses of the traded asset based on the
chosen method.
realized_empty
: Simple function to obtain empty results for
realized and paper computations based on the chosen method.