#!/usr/bin/env python import requests, json, sys def geminiPublicTicker(type): try: uri = "https://api.gemini.com/v1/pubticker/" + type.lower().replace('_', '') response = requests.request("GET", uri) response = json.loads(response.text) price = float(response['last']) + float(response['ask']) + float(response['bid'])/3 price = round(price, 3) return price except KeyError as e: print("Gemini Spot Price Error: %s" % str(e)) sys.stdout.flush() price = 0 return price def geminiHighLowVol(type): try: uri = "https://api.gemini.com/v2/ticker/" + type.lower().replace('_', '') response = requests.request("GET", uri) response = json.loads(response.text) high = float(response['high']) low = float(response['low']) uri = "https://api.gemini.com/v1/pubticker/" + type.lower().replace('_', '') response = requests.request("GET", uri) response = json.loads(response.text) vol = float(response['volume']['USD']) return high, low, vol except KeyError as e: print("Gemini High Low Volume Error: %s" % str(e)) sys.stdout.flush() return 0, 0, 0 def geminiOpenClose(type): try: uri = "https://api.gemini.com/v2/ticker/" + type.lower().replace('_', '') response = requests.request("GET", uri) response = json.loads(response.text) open = float(response['open']) close = float(response['close']) return open, close except KeyError as e: print("Gemini Open Close Error: %s" % str(e)) sys.stdout.flush() return 0, 0