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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.