realized_compute {dispositionEffect} | R Documentation |
Realized estimation
Description
Compute realized gains and realized losses as either simple counts, total quantities, expected returns and financial duration.
Usage
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")
Arguments
portfolio_quantity |
Numeric vector. The portfolio quantities of assets into the investor's portfolio. |
portfolio_price |
Numeric vector. The portfolio prices of assets into the investor's portfolio. |
transaction_quantity |
Numeric value. The quantity of the traded asset. |
transaction_price |
Numeric value. The market price of the traded asset. |
transaction_type |
Character string. Either "B" = buy or "S" = sell. |
allow_short |
Logical. If TRUE short positions are allowed, otherwise only long positions are allowed. |
realized_only |
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. |
previous_transaction_datetime |
POSIXct value. The portfolio date-time related to the last transaction of the traded asset. |
previous_datetime |
POSIXct value. The date-time of the last transaction performed by the investor. |
transaction_datetime |
POSIXct value. The date-time at which the transaction is going to occur. |
transaction_asset |
Character string. The name of the traded asset. |
method |
Character string. The method used to compute papers. Allowed values are "count", "total", "value", "duration" and "all". |
Value
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
Functions
-
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.