Quantopian fetch_csv

143 views
Skip to first unread message

Hassan Gharehassanloo

unread,
Apr 14, 2015, 2:56:24 AM4/14/15
to zip...@googlegroups.com
Hi Everyone,
Does Zipline provide any functionality like fetch_csv in Quantipian or its equivalent?

Best Regards,
Hasan Gharehasanloo

Erick Gomez

unread,
Jun 25, 2015, 1:02:21 AM6/25/15
to zip...@googlegroups.com
Hassan,

Have you figure out how to run zipline in live trading? 

Hasan Gharehasanloo

unread,
Jun 26, 2015, 12:44:08 PM6/26/15
to Erick Gomez, zip...@googlegroups.com
Erik,
Unfortunately, not yet. It needs a lot of changes in Zipline.


------------------------------------------------
Best Regards

Hasan Gharehasanloo

Front-end Web Developer

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.

Mark Francis

unread,
Jul 6, 2015, 8:14:04 AM7/6/15
to zip...@googlegroups.com, lesta...@gmail.com
It's just a modified pandas dataframe. Look at how load_bars_from_yahoo works. I ended up writing (hacking) my own function to import from my personal database. I'm sure this is really crude but it works for me. This might give you a starting point (replace from_sql to from_csv pandas functions):

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

Reply all
Reply to author
Forward
0 new messages