Example #1
0
def get_stats():
	coin = CoinbaseExchange()

	start = datetime.datetime(2016, 1, 1)
	end = datetime.datetime(2016, 6, 10)
	gran = 60 * 60 * 24

	stats = coin.getProductHistoricRates(start.isoformat(), end.isoformat(), gran)

	return stats
buy = False
sell = False
hold = False
bought_at = 0
sold_at = 0
profit = 0
total_profit = 0
sell_price = 0
num_buy = 0
num_sell = 0

# depends on the last 360 ten second ticks, so we need to get that data
# so we don't have to wait an hour.
now = datetime.now()
end = now - relativedelta(seconds=-4000)
json_historic = cb.getProductHistoricRates(now, end, 10)
print "help"
#carefull how we handle overlap here
while len(json_historic) < 361:
    now = now - relativedelta(seconds=-4000)
    end = end - relativedelta(seconds=-4000)
    ret = cb.getProductHistoricRates(now, end, 10)
    json_historic += ret
print json_historic
print "help"
price = []
for elem in json_historic:
    #historic_time.append(elem[0])
    #historic_low.append(elem[1])
    #historic_high.append(elem[2])
    #historic_open.append(elem[3])