Learn R Programming

highfrequency (version 1.0.1)

Tools for Highfrequency Data Analysis

Description

Provide functionality to manage, clean and match highfrequency trades and quotes data, calculate various liquidity measures, estimate and forecast volatility, detect price jumps and investigate microstructure noise and intraday periodicity. A detailed vignette can be found in the open-access paper "Analyzing Intraday Financial Data in R: The highfrequency Package" by Boudt, Kleen, and Sjoerup (2022, ).

Copy Link

Version

Install

install.packages('highfrequency')

Monthly Downloads

1,788

Version

1.0.1

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

October 4th, 2023

Functions in highfrequency (1.0.1)

ReMeDI

ReMeDI
RBPCov_bi

# Check data: #' @keywords internal rdatacheck <- function (rData, multi = FALSE) if ((dim(rData)[2] < 2) & (multi)) stop("Your rData object should have at least 2 columns")
ReMeDIAsymptoticVariance

Asymptotic variance of ReMeDI estimator
RV

DEPRECATED DEPRECATED USE rRVar
exchangeHoursOnly

Extract data from an xts object for the exchange hours only
getAlphaVantageData

Get high frequency data from Alpha Vantage
aggregateTS

Aggregate a time series
aggregateQuotes

Aggregate a data.table or xts object containing quote data
businessTimeAggregation

Business time aggregation
gatherPrices

Make TAQ format
autoSelectExchangeTrades

Retain only data from the stock exchange with the highest trading volume
aggregateTrades

Aggregate a data.table or xts object containing trades data´
driftBursts

Inference on drift burst hypothesis
makeReturns

Compute log returns
makeRMFormat

DEPRECATED use spreadPrices
getLiquidityMeasures

Compute Liquidity Measure
getCriticalValues

Get critical value for the drift burst hypothesis t-statistic
SPYRM

SPY realized measures
cholCovrMRCov

#' @keywords internal zgamma <- function (x, y, gamma_power) if (x^2 < y) out <- abs(x)^gamma_power else if (gamma_power == 1) out <- 1.094 * sqrt(y) if (gamma_power == 2) out <- 1.207 * y if (gamma_power == 4/3) out <- 1.129 * y^(2/3) return(out)
autoSelectExchangeQuotes

Retain only data from the stock exchange with the highest volume
makeOHLCV

Make Open-High-Low-Close-Volume bars
knChooseReMeDI

ReMeDI tuning parameter
leadLag

Lead-Lag estimation
aggregatePrice

Aggregate a time series but keep first and last observation
MDtest

# Difference of medians test # See Fried (2012) # Returns TRUE if H0 is rejected # importFrom stats density # keywords internal DMtest <- function(x, y, alpha = 0.005) m <- length(x) n <- length(y) xmed <- median(x) ymed <- median(y) xcor <- x - xmed ycor <- y - ymed delta1 <- ymed - xmed out <- density(c(xcor, ycor), kernel = "epanechnikov") fmed <- as.numeric(BMS::quantile.density(out, probs = 0.5)) fmedvalue <- (out$y[max(which(out$x < fmed))] + out$y[max(which(out$x < fmed))+1])/2 test <- sqrt((m*n)/(m + n))*2*fmedvalue*delta1 return(abs(test) > qnorm(1-alpha/2))
matchTradesQuotes

Match trade and quote data
JOjumpTest

Jiang and Oomen (2008) tests for the presence of jumps in the price series.
makePsd

Returns the positive semidefinite projection of a symmetric matrix using the eigenvalue method
plot.DBH

Plotting method for DBH objects
mergeQuotesSameTimestamp

Merge multiple quote entries with the same time stamp
mergeTradesSameTimestamp

Merge multiple transactions with the same time stamp
intradayJumpTest

Intraday jump tests
highfrequency-package

highfrequency: Tools for Highfrequency Data Analysis
getTradeDirection

Get trade direction
plot.HEAVYmodel

Plotting method for HEAVYmodel objects
quotesCleanup

Cleans quote data
print.DBH

Printing method for DBH objects
print.HARmodel

Printing method for HARmodel objects
rAVGCov

Realized covariances via subsample averaging
mukp

to use when p,k different from range [4,6]
predict.HARmodel

Predict method for objects of type HARmodel
listCholCovEstimators

Utility function listing the available estimators for the CholCov estimation
noZeroQuotes

Delete the observations where the bid or ask is zero
listAvailableKernels

Available kernels
noZeroPrices

Delete the observations where the price is zero
rCholCov

CholCov estimator
rMPV

DEPRECATED
rCov

Realized covariance
rBeta

Realized beta
predict.HEAVYmodel

Iterative multi-step-ahead forecasting for HEAVY models
rMedRQ

DEPRECATED
rBACov

rBACov
plotTQData

Plot Trade and Quote data
rMPVar

Realized multipower variation
plot.HARmodel

Plotting method for HARmodel objects
rMedRV

DEPRECATED
rBPCov

Realized bipower covariance
rMRC

DEPRECATED rMRC
rMedRQuar

An estimator of integrated quarticity from applying the median operator on blocks of three returns
rMedRVar

rMedRVar
rMRCov

Modulated realized covariance
rMinRQ

DEPRECATED
rMinRQuar

An estimator of integrated quarticity from applying the minimum operator on blocks of two returns
rOWCov

Realized outlyingness weighted covariance
rQPVar

Realized quad-power variation of intraday returns
rKernelCov

Realized kernel estimator
rRTSCov

Robust two time scale covariance estimation
rankJumpTest

Rank jump test
rSVar

Realized semivariance of highfrequency return series
rKurt

Realized kurtosis of highfrequency return series.
rQuar

Realized quarticity
rSemiCov

Realized semicovariance
rHYCov

Hayashi-Yoshida covariance
rmTradeOutliersUsingQuotes

Delete transactions with unlikely transaction prices
rThresholdCov

Threshold Covariance
sampleQData

Sample of cleaned quotes for stock XXX for 2 days measured in microseconds
salesCondition

salesCondition is deprecated. Use tradesCondition instead.
rTSCov

Two time scale covariance estimation
refreshTime

Synchronize (multiple) irregular timeseries by refresh time
rMinRV

DEPRECATED
rMinRVar

rMinRVar
rmOutliersTrades

Remove outliers in trades without using quote data
rmOutliersQuotes

Remove outliers in quotes
sampleOneMinuteData

One minute data
sampleQDataRaw

Sample of raw quotes for stock XXX for 2 days measured in microseconds
rSkew

Realized skewness
summary.HARmodel

Summary for HARmodel objects
spreadPrices

Convert to format for realized measures
sampleMultiTradeData

Multivariate tick by tick data
rTPQuar

Realized tri-power quarticity
rRVar

An estimator of realized variance.
rSV

DEPRECATED
tradesCleanup

Cleans trade data
rmNegativeSpread

Delete entries for which the spread is negative
sampleTDataEurope

European data
sampleTData

Sample of cleaned trades for stock XXX for 2 days
rmLargeSpread

Delete entries for which the spread is more than maxi times the median spread
tradesCleanupUsingQuotes

Perform a final cleaning procedure on trade data
selectExchange

Retain only data from a single stock exchange
sampleTDataRaw

Sample of raw trades for stock XXX for 2 days
tradesCondition

Delete entries with abnormal trades condition.
spotDrift

Spot Drift Estimation
spotVol

Spot volatility estimation
IVinference

Function returns the value, the standard error and the confidence band of the integrated variance (IV) estimator.
IVar

Estimators of the integrated variance
HEAVYmodel

HEAVY model estimation
ICov

Estimators of the integrated covariance
Bj

Internal HEAVY functions
BNSjumpTest

Barndorff-Nielsen and Shephard (2006) tests for the presence of jumps in the price series.
AJjumpTest

Ait-Sahalia and Jacod (2009) tests for the presence of jumps in the price series.
HARmodel

Heterogeneous autoregressive (HAR) model for realized volatility model estimation