obmodeling is an R package which uses xts time series objects to manipulate and analyze:

  • Market depth statistics

  • Price movement, liquidity changes (Cartea, Jaimungal, and Penalva 2015)

  • Market spread (De Jong and Rindi 2009, 91–96)

  • Measures of volatility (De Jong and Rindi 2009, 92, and Cartea, Jaimungal, and Penalva (2015))

  • PIN/VPIN (Easley et al. 1996, Easley, Prado, and O’Hara (2012))

  • Price pressure (Hendershott and Menkveld 2014, Cont, Kukanov, and Stoikov (2014))

  • Trade imbalance (Cont, Kukanov, and Stoikov 2014)


# load the data here, ob_trades & ob_quotes

load.quotes(system.file('extdata/ob_quotes.csv',package = 'obmodeling'))
load.trades(system.file('extdata/ob_trades.csv',package = 'obmodeling'))
  • obmodeling uses an environment to store parsed trades and quotes
  • you can access that environment via getOB()
  • currently supports Reuters data format, more to come

Calling Functions

head(effective.spread('ESH6', store=TRUE),2)
##                            effective.spread
## 2016-02-11 00:00:01.526174             0.25
## 2016-02-11 00:00:01.644326             0.25
  • When applicable functions contain a store function, saving the data in the environment
ob <- getOB()
## [1] "quotes"           "trades"           "effective.spread"

Current Functions

  • bidask.changes
  • effective.spread
  • load.quotes
  • load.trades
  • market.depth.stats
  • quoted.spread
  • ticks.wide
  • trade.imbalance
  • trade.size.stats
  • vpin
  • wmp

Visualize Order Book


Future Visalizations

Orderbook through time

Future Analysis

  • Market Toxicity Measures

  • Event Analysis (Almgren 2012)



Almgren, Robert. 2012. “High-Frequency Event Analysis in Eurex Interest Rate Futures.” Technical report, Working Paper, Quantitative Brokers.

Cartea, Álvaro, Sebastian Jaimungal, and José Penalva. 2015. Algorithmic and High-Frequency Trading. Cambridge University Press.

Cont, Rama, Arseniy Kukanov, and Sasha Stoikov. 2014. “The Price Impact of Order Book Events.” Journal of Financial Econometrics 12 (1). Oxford Univ Press: 47–88.

De Jong, Frank, and Barbara Rindi. 2009. The Microstructure of Financial Markets. Cambridge University Press.

Easley, David, Nicholas M Kiefer, Maureen O’hara, and Joseph B Paperman. 1996. “Liquidity, Information, and Infrequently Traded Stocks.” The Journal of Finance 51 (4). Wiley Online Library: 1405–36.

Easley, David, Marcos M López de Prado, and Maureen O’Hara. 2012. “Flow Toxicity and Liquidity in a High-Frequency World.” Review of Financial Studies 25 (5). Soc Financial Studies: 1457–93.

Hendershott, Terrence, and Albert J Menkveld. 2014. “Price Pressures.” Journal of Financial Economics 114 (3). Elsevier: 405–23. http://faculty.haas.berkeley.edu/hender/price_pressures.pdf.