------------------------------------------------
Best Regards
Email: h_g...@yahoo.com
Cell: (0098) 912-462-4557
LinkedIn: linkedin.com/fa/hghare
--
You received this message because you are subscribed to a topic in the Google Groups "Zipline Python Opensource Backtester" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/zipline/9JqpJ9H1XwQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to zipline+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
def load_bars_from_database(start, end, stocks=[]):
db = pymysql.connect(host="",
user="",
passwd="",
db="")
df_dict = {}
for stock in stocks:
sql = "select date, open, high, low, close, volume from data \
where symbol = '{0}' and date > '{1}' and date < '{2}'".format(
stock, start, end)
data_raw = pd.read_sql(sql, con=db)
#Setting the date index
data_raw.index = pd.to_datetime(data_raw['date'])
data = data_raw.tz_localize('UTC')
# It might not be needed to drop the date column after converted to index
#data.drop('date', axis=1, inplace=True)
#setting the price column to be the close, this is how i think yahoo\
#finance deals with splits and such
data['price'] = data['close']
# Adding this stock to the dict of dataframes
df_dict[stock] = data
# Convert dict to a panel
panel_return = pd.Panel(df_dict)
return panel_return