Ejemplo n.º 1
0
def test_load():
	import datetime
	"""Load the historical data json file: list(dict(dict()))
	
	Convert to list(list()), print, and return
	"""
	data=load_json(filename='data/bitcrawl_historical_data.json',verbose=False)
	if not data: return data
	
	columns=[]
	for record in data:
		if 'mtgox' in record.keys():
			mtgox = record['mtgox']
			columns.append([]) #add an empty row
			if 'datetime' in mtgox.keys():
				# add the time to the empty row
				# leave it as a string and I'll convert to a value
				dt = datetime.datetime.strptime(mtgox['datetime'][0:-6],"%Y-%m-%d %H:%M:%S.%f")
				dt_value = float(dt.toordinal())+dt.hour/24.+dt.minute/24./60.+dt.second/24./3600.
				columns[-1].append(dt_value)
			if 'average' in mtgox.keys():
				# float() won't work if there's a dollar sign in the price
				value = float(mtgox['average'].strip().strip('$').strip())
				# add the value to the last row
				columns[-1].append(value)
	import pprint
	pprint.pprint(columns,indent=2)
	return columns
Ejemplo n.º 2
0
        )
    p.add_argument(
        '-f','--path','--filename',
        type    = str,
        #nargs  = '*', # other options '*','+', 2
        default = bc.FILEPATH,
        help    = 'File to append the numerical data to (after converting to a string).',
        )
    return p.parse_args()

if __name__ == "__main__":
    o = parse_args()

    data = None
    if not o.quiet or o.verbose:
        data = bc.load_json(filepath=o.path,verbose=-2)
    print o.graph
    sites, values, datetimes = bc.parse_query(o.graph)
    print 'sites',sites
    print 'values',values
    rows = bc.retrieve_data(sites,values,datetimes)
    NM  = size(rows)
    assert NM[1]>=NM[0], size(rows)
    #cols = bc.transpose_lists(rows)

    bc.display_correlation(rows=rows, labels=o.graph, leads=o.lead)

    #bc.plot_data(columns=cols,normalize=True)

    if not o.nomine:
        # mine hard-coded urls