stefan-jansen / zipline-reloaded

Zipline, a Pythonic Algorithmic Trading Library
https://zipline.ml4trading.io
Apache License 2.0
1.13k stars 210 forks source link

Doesn't work with Pandas 2.0 and SQLAlchemy 2.0 #184

Closed dsdante closed 1 year ago

dsdante commented 1 year ago

Zipline doesn't work with Pandas 2.0 ("Algorithm should have a utc datetime") and SQLAlchemy 2.0 ("The 'future' parameter passed to create_engine() may only be set to True").

The latest pre-2.0 versions seem to work, at least I can run a simple test program:

import pandas as pd
import pandas_datareader.data as web
from zipline import run_algorithm
from zipline.api import order, record, symbol

def initialize(context):
    pass

def handle_data(context, data):
    order(symbol('AAPL'), 10)
    record(AAPL=data.current(symbol('AAPL'), 'price'))

start = pd.Timestamp('2014')
end = pd.Timestamp('2018')

sp500 = web.DataReader('SP500', 'fred', start, end).SP500
benchmark_returns = sp500.pct_change()

result = run_algorithm(start=start,
                       end=end,
                       initialize=initialize,
                       handle_data=handle_data,
                       capital_base=100000,
                       benchmark_returns=benchmark_returns,
                       bundle='quandl',
                       data_frequency='daily')

Environment:

BirdyLiu6471023 commented 1 year ago

Hi, did you solve this ["The 'future' parameter passed to create_engine() may only be set to True"] ? I have the same mistake here.

MBounouar commented 1 year ago

pandas >= 2 and sqlalchemy >= 2 , introduce non-backward compatible changes. You need to downgrade pandas and sqlalchemy

stefan-jansen commented 1 year ago

Please retry with latest, just released version.