Created
November 12, 2016 08:55
-
-
Save 0ex-d/c424a9e440b41e378f214607fd36aa14 to your computer and use it in GitHub Desktop.
GDAX Python Wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
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