Get data for specific date range from yahoo finance api via python
Question: I'm trying to fetch data from the Yahoo finance API via Joe C's method
described here: [Download history stock prices automatically from yahoo
finance in python](http://stackoverflow.com/questions/12433076/download-
history-stock-prices-automatically-from-yahoo-finance-in-
python/12510334#12510334)

However, when I try to pass additional parameters about the date, Yahoo
finance seems to ignore these parameters and returns a list of prices from the
beginning of the stock's existence.

Is there an easy way to get the data for a certain date range or should I just
process the results manually?

Thanks for your help.


Answer: To get data for a particular date range, you need to modify the make_url as
shown below,

    
    
    def make_url(ticker_symbol,start_date, end_date):
        print ticker_symbol
        a = start_date
        b = end_date
        dt_url = '%s&a=%d&b=%d&c=%d&d=%d&e=%d&f=%d&g=d&ignore=.csv'% (ticker_symbol, a.month-1, a.day, a.year, b.month-1, b.day,b.year)
        return base_url + dt_url
    

To use this function, you need to do the following,

    
    
    import datetime
    s = datetime.date(2012,1,1)
    e = datetime.date(2013,1,1)
    u =  make_url('csco',s,e)
    

