Greetings,
I just created my first algorithm on Quantopian. (Please bear in mind I have no background in stocks and only a little in programming.) The algorithm is probably the dumbest algorithm you could produce. It literally just checks if today's price is higher than yesterday's. If it is, it buys 50 stocks. Otherwise, it does nothing.
yesterday = 0
def initialize(context):
context.aapl = sid(24)
def handle_data(context, data):
global yesterday
today = data[context.aapl].price
if today > yesterday:
order(context.aapl, 50)
else:
#order(context.aapl, -50)
pass
yesterday = data[context.aapl].price
When I run a full backtest, it says my total returns are 836%. How can this be? The algorithm only buys stocks. It doesn't sell them. How exactly is "total returns" computed?
Thanks for taking the time to read this n00b question.
Appreciatively,
—Nathan