# There is a preloaded dataset called 'hfdata' contained in the package.
# It is an artificially created high-frequency trading data. The dataset
# contains 100 000 trades and five variables 'timestamp', 'price',
# 'volume', 'bid' and 'ask'. For more information, type ?hfdata.
xdata <- hfdata
# Estimate VPIN model, using the following parameter set where the time
# bar size is 5 minutes, i.e., 300 seconds (timebarsize = 300), 50
# buckets per average daily volume (buckets = 50), and a window size of
# 250 for the VPIN calculation (samplength = 250).
estimate <- vpin(xdata, timebarsize = 300, buckets = 50, samplength = 250)
# Display a description of the estimate
show(estimate)
# Plot the estimated VPIN vector
plot(estimate@vpin, type = "l", xlab = "time", ylab = "VPIN", col = "blue")
# Display the parameters of VPIN estimates
show(estimate@parameters)
# Store the computed data of the different buckets in a dataframe 'buckets'.
# Display the first 10 rows of the dataframe 'buckets'.
buckets <- estimate@bucketdata
show(head(buckets, 10))
# Store the daily VPIN values (weighted and unweighted) in a dataframe
# 'dayvpin'.
# Display the first 10 rows of the dataframe 'dayvpin'.
dayvpin <- estimate@dailyvpin
show(head(dayvpin, 10))
Run the code above in your browser using DataLab