November 2019
Beginner
394 pages
10h 31m
English
Now, let's define and quantify some parameters we will need to define moving averages, price deviation from moving averages, history of price deviations, and variables to compute and track correlations:
import statistics as stats# Constants/variables that are used to compute simple moving average and price deviation from simple moving averageSMA_NUM_PERIODS = 20 # look back periodprice_history = {} # history of pricesPRICE_DEV_NUM_PRICES = 200 # look back period of ClosePrice deviations from SMAprice_deviation_from_sma = {} # history of ClosePrice deviations from SMA# We will use this to iterate over all the days of data we havenum_days = len(symbols_data[TRADING_INSTRUMENT].index)correlation_history = {} ...