Learn R Programming

ACDm (version 1.0.4.3)

computeDurations: Durations computation

Description

Computes durations from a data.frame containing the time stamps of transactions. Trade durations, price durations and volume durations can be computed (if the appropriate data columns are given).

Usage

computeDurations(transactions, open = "10:00:00", close = "18:25:00", 
rm0dur = TRUE, type = "trade", priceDiff = .1, cumVol = 10000)

Value

a data.frame with columns:

time

the calander time of the start of each duration spell.

price

the volume weighted avrage price of the shares traded during the spell of the duration.

volume

the volume (total shares traded) during the duration spell.

Ntrans

number of transactions done during the spell.

durations

the computed duration.

Arguments

transactions

a data.frame with, at least, transaction time in a column named 'time' (see Details)

open

the opening time of the exchange. Transactions done outside the trading hours will be ignored.

close

the closing time of the exchange.

rm0dur

if TRUE zero-durations will be removed and transactions done on the same second will be aggregated, e.g. price will then be the volume weighted avrage price of the aggregated transactions.

type

the type of durations to be computed. Either "trade", "price", or "volume".

priceDiff

only if type = "price". Price durtions are (here) defind as the duration until the price has changed by at least 'priceDiff' in absolute value.

cumVol

only if type = "cumVol". Volume durtions are (here) defind as the duration until the cumulative traded volume since the last duration has surpassed 'cumVol'.

Author

Markus Belfrage

Details

The data.frame must include a column named 'time' with the time of each transaction, in a time format recognizable by POSIXlt or strings in format "yyyy-mm-dd hh:mm:ss". If the column 'price' or 'volume' is included its also possible to compute price- and volume durations (see arguments priceDiff and cumVol)

Examples

Run this code
if (FALSE) {
#only the first 3 days of data:
durDataShort <- computeDurations(transData[1:56700, ]) 
str(durDataShort)
head(durDataShort)}

Run the code above in your browser using DataLab