Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Help with test strategy please.

Hi,

I am new to Quantopian. I tried to clone a simple strategy and modified details myself. However it seem the strategy is NOT doing what I am asking it to do. Could you help pointing out the mistakes I have made in the code? Thanks so much.

Stock: APPL
Rules:

1) If Current Price > MA(30), Current Position == 0, Initiate long position with 10% of portfolio value. no. of shares = portfolio cash * 10% / current price.

2) Else If Current Price > MA(30), Current Position < 0. Flip the positions to long. i.e. number of shares after = -1*number of share before

3) Else If Current Price < MA(30), Current Position == 0. Initiate short position with 10% of portfolio value.

4) Else If Current Price < MA(30), Current Position > 0. Flip the positions to short.

5) Close all positions at 1550 EST.

1 response

Hey Brian,

The algorithm seems to be executing properly, although the performance suffers. I modified your code a little and added some logs so we can see the flow of the execution. Feel free to ask more questions!

Ryan