Hi All -
I'm trying to use the backtester to look at a trading strategy for mutual funds (I understand this is rarely the investment vehicle of choice for algorithmic traders). So I wanted to read in the price data of a few mutual funds using the fetch_csv routine but how do I assign a sid? Here is my code so far:
# Put any initialization logic here. The context object will be passed to
# the other methods in your algorithm.
def initialize(context):
fetch_csv('https://www.dropbox.com/s/r9vyuyqw9ldyrc3/FUGAX.csv',
date_column='Date',
symbol='FUGAX',
date_format='%m/%d/%Y')
# Will be called on every trade event for the securities you specify.
def handle_data(context, data):
# Implement your algorithm logic here.
# data[sid(X)] holds the trade event data for that security.
# data.portfolio holds the current portfolio state.
# Place orders with the order(SID, amount) method.
# TODO: implement your own logic here.
order(data['FUGAX'], context.portfolio.cash/data['FUGAX'].price)
EDIT: The error I get is,
Error Algorithm must reference 1 to 10 SIDs, inclusive.
Is the backtester limited to a universe of only 10 securities?