When testing, I have only been doing a week because it does take some time to compute. I just did a 1 year backtest on your strategy and it is attached.
Did you make sure that your start and end dates are different when setting up your Backtest? Because it is possible not to have any stocks selected in your requirements per day and if you only did a short period, you might have only received the one hit.
Don't be afraid to Attach
your BackTest so that I can see what you are talking about ;)
So, I have not attempted your second nor third sections - a lot of time well spent working on the first part. We will get there in due time.
Click on Source Code
. The last section does the ordering. Right now the only strategy is to order all of the daily picks, 10 shares each.
def SimpleEPS_timeToTrade(context, data):
print "Time to Trade!"
for i in context.todays_entries:
print "Ordering: " + str(i.symbol)
order(i, 10)
See more here: https://www.quantopian.com/help#api-order
I am still new here, so I cannot describe well the parameters of order()
. But order(i,10)
orders 10 shares of each of cotext.todays_entries
.
context.todays_entries
is set in before_trading_start()
as you prescribed in the first section of your original post.
before_trading_start()
is a key function for a quantopian algorithm and it is called each "day" before anything else.
initialize()
is another key function that is called only once to setup everything and is essentially not called again. (How quantopian does this in the backend, I am gathering, is slightly different, but that is the gist.)
SimpleEPS_TimeToTrade()
is called twice a day because I have set that up with schedule_function
in the initialize
function.
handle_data()
is another key function that is called every minute. You likely don't need to concern yourself with this function.
To implement your second and third sections, you might put that logic in the SimpleEPS_TimeToTrade
function. :yoda: