applyFilter: Filter out bad prices

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/applyFilter.R

Description

Deletes data where the Bid-Ask spread is extremely wide, which is probably a bad print

Usage

1
  applyFilter(BAM, filter = 1e-04, verbose = TRUE)

Arguments

BAM

An xts object that has Bid, Ask, and

filter

a very small number that is the percentage of data to delete

verbose

TRUE/FALSE. If TRUE, the number of rows that were removed will be printed to the standard output connection via cat

Details

If you want to delete rows where the bid ask spread is wider than it is 98 pct of the time, use filter=0.02

Value

Same as BAM only with fewer rows

Note

If applyFilter is called with a filter value of 0, it may still filter the row with the widest Bid-Ask spread.

This is intended to clean data with extremely low bid prices, or extremely high ask prices, but currently does not filter out rows with high bid prices or low ask prices.

Author(s)

Garrett See

See Also

quantile

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
#Create psuedo-BAM data
getSymbols('SPY')
SPY <- cbind(Lo(SPY),Hi(SPY),Cl(SPY))
colnames(SPY) <- paste("SPY",c('Bid.Price','Ask.Price','Mid.Price'),sep='.')
#make some bad prints
SPY[length(SPY[,1])-4,1] <- 0
SPY[length(SPY[,1])-3,2] <- 10000
SPY[length(SPY[,1])-1,1] <- 0
tail(SPY) #look at the raw data
SPY <- applyFilter(SPY, filter=1e-02)
tail(SPY)

## End(Not run)
#

qmao documentation built on May 2, 2019, 4:54 p.m.