Skip to content

Instantly share code, notes, and snippets.

@0ex-d
Created November 12, 2016 08:55
Show Gist options
  • Save 0ex-d/c424a9e440b41e378f214607fd36aa14 to your computer and use it in GitHub Desktop.
Save 0ex-d/c424a9e440b41e378f214607fd36aa14 to your computer and use it in GitHub Desktop.
GDAX Python Wrapper
import GDAX, time
from geminipy import Geminipy
#set trade size in BTC
trade_size = '0.0001'
trade_threshold = 0
improvement_amount = 0.1
live_toggle = True
place_orders = True
#initialize gemini connection
geminiConnection = Geminipy(api_key='xxx', secret_key='xxx', live=live_toggle)
#initialize gdax connection
gdaxConnectionPrivate = GDAX.AuthenticatedClient('xxx','xxx+oAQ==', 'xxx', api_url="https://api.gdax.com")
#set default product for gdax
gdaxConnectionPublic = GDAX.PublicClient(product_id="BTC-USD")
#helper functions
def get_order_ids_gdax():
order_ids = []
for o in gdaxConnectionPrivate.getOrders()[0]:
order_ids.append(o['id'])
return order_ids
def print_all_orders_gdax():
for o in gdaxConnectionPrivate.getOrders()[0]:
print o['id']
def cancel_all_orders_gdax(order_ids):
for id in order_ids:
gdaxConnectionPrivate.cancelOrder(id)
#print
for x in gdaxConnectionPrivate.getFills()[0]:
print x
sellParams = {
'price': '200.00', #USD
'size': trade_size, #BTC
'product_id':'BTC-USD',
'type':'limit',
'side':'buy'
}
gdaxConnectionPrivate.buy(sellParams)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment