I am very new to Quantopian and Python. And I am worried that I did something wrong in the code. Can anyone help check it?
Strategy Description
The words/ numbers in < > can be changed by users in the program
Step 1: Calculate linear regression between Gold ETF (GLV) and Silver ETF (SLV)
• Look back day prices • Gold – asilver = constant (a is some constant) [linear regression]
Step 2: Use co-integration test to test mean reversion for the formula obtained from linear regression
• Test mean reversion for Gold – a*silver = constant (a is some constant) • If p-value <= , then the pair is tradable.
Step 2: Construct Bollinger band.
• Bollinger Band settings: days SMA; Standard Deviation • If pairs value (i.e. the constant in the formula) >= upper band, short (Gold – a * silver) o Sell 1 share Gold and Buy "a" share Silver
“a” should be an integer (round the number if needed) • If pairs value <= lower band, buy (Gold –a *silver) o Buy 1 share Gold and Sell "a" share Silver
o “a” should be an integer (round the number if needed)
Step 3: Exit
• Take Profit: % • Stop loss: %