Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Working through algo bugs

Ok,

I am getting somewhere with my 1st algorithm. Just need to work through some bugs.

First, what does the algo do?

Captures the opening price and then waits until the current_price is between .10 and .20 above the open price.

The sell conditions are as follows:

If current_price falls below opening price by .10.
If current_price is > $1.10 above opening price.
If EOD is approaching.

I cannot figure out why the first two transactions are BUYS, I only want one open position at a time, so there should not be two BUYS in a row in the transaction table.

I also cannot figure out why the first SELL was for 100 shares, there were many more shares that should have been sold.

And finally, the log shows multiple "below open price sales" for a similar amount right in a row.

2 responses

Hi Chuck,

Let's see if I can understand what you want to do:

  1. Trade in one security only (e.g. Netflix).
  2. Each day, record the opening price.
  3. If the price rises and lands between $0.10 & $0.20 above the opening price, then execute a single buy for the day, shifting all cash into the market.
  4. Presumably, if it gets too late in the day, you will no longer buy.
  5. If you have bought into the stock, then sell all shares:

    If current_price falls below opening price by .10.
    If current_price is > $1.10 above opening price.
    If EOD is approaching.

Did I miss anything?

Grant

Grant that is exactly what i want to do.

I think I have some issues with the if statements. Not sure why my buy and sells are not "matched" up.