This is an example of a way to use fetch_csv to load more complicated data that you have generated offline and want to feed into your Quantopian algo. Within a csv file you can encode a structure like a dict as a string so it's associated with a single column. The hard part is parsing it back to the original data structure because the JSON libs are not available.
This script uses fetchers 'pre_func' to parse simple dicts/lists so they can be used in your algo. It works for flat dictionaries and lists only where the keys are strings and values are floats.
An example of the data is below. Here's a breakdown of the fields and how they are used
- datedate: self explanatory
- ranking: A signal strength parameter
- relation: A single basket of stocks along with the model params encoded as a single string
- longSpreadLimits/shortSpreadLimits: Entry/Exit points for long/short positions on the spread
- timeLimit: A tuple of (days, hours, minutes) for the maximum time to wait for a reversion.
- volatilty: Used to decide on the leverage applied to the basket
date,ranking,relation,longSpreadLimits,shortSpreadLimits,timeLimit,volatility
2015-06-01,1,"{'JPM': 2.7, 'GS': -1, 'constant': 25}","(-2.0, -1.2, -0.2)","(1.5, 1.1, 0.2)","(26, 0, 0)",4.5
2015-06-01,1,"{'BCX': 2.7, 'GS': -3.3, 'MS':1.4, 'constant': -20}","(-1.8, -0.7, 0.2)","(1.5, 1.1, 0.2)","(15, 0, 0)",4.5
Within the algo data contains a 'pair_info' field that will contain this data, you can then map it to the correct symbols and place trades based on it.
This should help those of you who generate your signals offline. It's a pretty specific example, but can be used as a reference and tweaked based on your needs.