I'm trying to learn how this tool works and the first thing I thought I'd try was to simply plot a buy and hold portfolio of one stock against the price of the stock itself. In theory, these two series should then be identical.
However, that's not what I'm seeing.
The code I'm using looks like this:
def initialize(context):
context.stock = sid(24)
context.startup = True
set_benchmark(context.stock)
def handle_data(context, data):
if context.startup:
order_percent(context.stock, 1.0)
context.startup = False
All I'm doing is choosing a stock, setting it as the benchmark and then buying it on the first call to handle_data.
Doing this for a few different stocks and running a backtest for the first week of 2014 gives the following results:
The actual algorithm is always off initially compared to the benchmark. Any idea what I'm doing wrong?