def main():
    expire_after = timedelta(days=1)
    if PY2:
        filename = 'cache_py2'
    else:
        filename = 'cache'
    session = requests_cache.CachedSession(cache_name=filename, expire_after=expire_after)
    dt = pd.to_datetime('2014-01-01')
    symbol = 'AUD/USD'
    symbol = symbol.replace('/', '').upper()
    year = dt.year
    month = dt.month
    month_name = datetime.datetime(year=1970, month=month, day=1).strftime('%B').upper()
    url = 'http://www.truefx.com/dev/data/{year:04d}/{month_name}-{year:04d}/{symbol}-{year:04d}-{month:02d}.zip'.format(year=year, month=month, symbol=symbol, month_name=month_name)
    response = session.get(url)
    zip_data = BytesIO(response.content)
    filename = '{symbol}-{year:04d}-{month:02d}.csv'.format(year=year, month=month, symbol=symbol)
    with ZipFile(zip_data, 'r') as zf:
        zfile = zf.open(filename)
        data = zfile.readlines()
    df = pd.DataFrame(data)
    df[0] = df[0].str.decode('utf8')
    df[0] = df[0].str.replace('\n', '')
    df[0] = df[0].map((lambda s: s.split(',')))
    df['Symbol'] = df[0].map((lambda t: t[0]))
    df['Date'] = df[0].map((lambda t: pd.to_datetime(t[1])))
    df['Bid'] = df[0].map((lambda t: t[2])).astype(float)
    df['Ask'] = df[0].map((lambda t: t[3])).astype(float)
    del df[0]
    df = df.set_index('Date')
    print(df)
def main():
    expire_after = timedelta(days=1)
    if PY2:
        filename = 'cache_py2'
    else:
        filename = 'cache'
    session = requests_cache.CachedSession(cache_name=filename, expire_after=expire_after)
    dt = pd.to_datetime('2014-01-01')
    symbol = 'AUD/USD'
    symbol = symbol.replace('/', ).upper()
    year = dt.year
    month = dt.month
    month_name = datetime.datetime(year=1970, month=month, day=1).strftime('%B').upper()
    url = 'http://www.truefx.com/dev/data/{year:04d}/{month_name}-{year:04d}/{symbol}-{year:04d}-{month:02d}.zip'.format(year=year, month=month, symbol=symbol, month_name=month_name)
    response = session.get(url)
    zip_data = BytesIO(response.content)
    filename = '{symbol}-{year:04d}-{month:02d}.csv'.format(year=year, month=month, symbol=symbol)
    with ZipFile(zip_data, 'r') as zf:
        zfile = zf.open(filename)
        data = zfile.readlines()
    df = pd.DataFrame(data)
    df[0] = df[0].str.decode('utf8')
    df[0] = df[0].str.replace('\n', )
    df[0] = df[0].map((lambda s: s.split(',')))
    df['Symbol'] = df[0].map((lambda t: t[0]))
    df['Date'] = df[0].map((lambda t: pd.to_datetime(t[1])))
    df['Bid'] = df[0].map((lambda t: t[2])).astype(float)
    df['Ask'] = df[0].map((lambda t: t[3])).astype(float)
    del df[0]
    df = df.set_index('Date')
    print(df)