#################################################################################
import good_downloadclass_barclays_aggregate as c1

p1 = c1.perform()
directory_where_datafiles_are_downloaded = p1.execute(download_last_x_days)
print 'OK', directory_where_datafiles_are_downloaded

#################################################################################

#################################################################################
import config
import os
import good_readvalues_marketvalue_barclays_aggregate as ofile

pclass = ofile.perform()
newdata_dict = pclass.execute(download_last_x_days,
                              directory_where_datafiles_are_downloaded)

import datetime

filedatetime = datetime.datetime.today()
filedatetime_string = filedatetime.strftime('%Y%m%d%H%M%S')

# Get path of savedjsonfile
savedjsonfile = os.path.join(config.localdatafileoutputpath,
                             'dailyreturns-barclays-usaggregate.json')


def create_saved_dict(p_savedjsonfile):
    import json
# -*- coding: cp1252 -*-
ddir = 'C:\\Batches\\AutomationProjects\\Investment Strategy\\ETL\\Downloads\\Unprocessed\\barclays\\'
download_last_x_days = -10
#################################################################################
import config

import os
import good_readvalues_marketvalue_barclays_aggregate as o

#print config.localunprocessedfolder
#localunprocessedfolderext = os.path.join(config.localunprocessedfolder,'barclays')

p = o.perform()
newdata_dict = p.execute(download_last_x_days, ddir)
for key, value in sorted(newdata_dict.iteritems()):
    print value['currdate'], value['periodreturn']