Quantifying and computing StatArb trading signals

  1. We will see over available prices a day at a time and see what calculations need to be performed, starting with the computation of SimpleMovingAverages and price deviation from the rolling SMA first:
for i in range(0, num_days):  close_prices = {}  # Build ClosePrice series, compute SMA for each symbol and price-deviation from SMA for each symbol  for symbol in SYMBOLS:    close_prices[symbol] = symbols_data[symbol]['Close'].iloc[i]    if not symbol in price_history.keys():      price_history[symbol] = []      price_deviation_from_sma[symbol] = []    price_history[symbol].append(close_prices[symbol])    if len(price_history[symbol]) > SMA_NUM_PERIODS: # we track at most SMA_NUM_PERIODS number of prices del (price_history[symbol][0]) ...

Get Learn Algorithmic Trading now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.