BUG: Algo no longer crashes after creating new history column.

Fixes an issue that caused a crash if a user assigned a new column into a
returned history DataFrame.  This occurred because we re-use DataFrames between
history() calls, so the new column caused an index-size mismatch on the next
attempted calculation.

Ideally we would fix this by in-place dropping the columns, but that isn't
supported in pandas 0.12.0, so instead we just return a complete copy of the
frame.  We should re-evaluate this implementation when we're on a more modern
pandas version.
This commit is contained in:
Scott Sanderson
2014-06-30 12:09:03 -04:00
parent f8e84ecd48
commit 75b415ac48
2 changed files with 8 additions and 2 deletions
+1
View File
@@ -351,6 +351,7 @@ def initialize(context):
def handle_data(context, data):
prices = history(bar_count=2, frequency='1d', field='price')
prices['prices_times_two'] = prices[1] * 2
context.last_prices = prices
""".strip()