Back to Community
Pair Trading

Hi, I am new to Quantopian
From the following link on Pair Trading
Please help me in understanding these codes and its functioning here, If there is any description of these functions on Quantopian,please let me know.

Q2) context.spread = np.ndarray((context.num_pairs, 0))
# context.hedgeRatioTS = np.ndarray((context.num_pairs, 0))
context.inLong = [False] * context.num_pairs
context.inShort = [False] * context.num_pairs

Q3) prices = history(35, '1d', 'price').iloc[-context.lookback::]

new_spreads = np.ndarray((context.num_pairs, 1))  

4) new_spreads[i, :] = Y[-1] - hedge * X[-1]

Thanks in advance.

1 response

Q1: set_slippage, set_commission, and set_symbol_lookup_date are Quantopian API functions described at http://www.quantopiancom/help .

Q2: ndarray is a NumPy function, described at , that creates an "n-dimensional array". * is the Python operator that "multiplies" a list by an int.

Q3: history is a Quantopian function. It returns a pandas.DataFrame. See and read about DataFrames and indexing.

Q4: Indexing and vector arithmetic in NumPy.