-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Open
Description
Dear Zipline Maintainers,
Before I tell you about my issue, let me describe my environment:
Environment
- Operating System:Darwin MBP.local 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 21 20:07:39 PDT 2018; root:xnu-3789.73.14~1/RELEASE_X86_64 x86_64
- Python Version: Python 3.6.4
- Python Bitness: 64
- How did you install Zipline: pip
Now that you know a little about me, let me tell you about the issue I am
having:
Description of Issue
algorithm code:
import pandas as pd
def initialize(context):
set_benchmark(symbol('SPY'))
set_commission(commission.PerShare(cost=0.01, min_trade_cost=1))
def before_trading_start(context, data):
current = data.current(symbol('GOOG'),
fields=['open','close','high','low','volume','last_traded','price'])
history = data.history(symbol('GOOG'), fields=['open','close','high','low','volume'], bar_count=10,frequency='1d')
log.info(current)
log.info(history)
def handle_data(context, data):
current = data.current(symbol('GOOG'),
fields=['open','close','high','low','volume','last_traded','price'])
history = data.history(symbol('GOOG'), fields=['open','close','high','low','volume'], bar_count=10, frequency='1d')
log.info(current)
log.info(history)
- What did you expect to happen?
execute normal - What happened instead?
raise TypeError: unsupported operand type(s) for *=: 'Timestamp' and 'float'
What steps have you taken to resolve this already?
modify code zipline/data/data_portal.py, DataPortal.get_adjusted_value, about line 690.
change:
spot_value *= ratio
to
if field != 'last_traded':
spot_value *= ratio
...
Sincerely,
hotea