Quant Trading Robot #1 - API Calls
To check your code against coding standard and some error detection, I'd suggest you pylint, if you don't know it already.
Running pylint on your original code gives a list of things to check and a score 7.29/10 which is a good start.

What you should fix:


add docstrings at module, class and function level.
remove temporary variables when used just once.

r = requests.get(url, params=params)
return r

return requests.get(url, params=params)

prefer string formatting over concatenation.

url = API_URL + '/products/' + product_id + '/candles'
url = '%s/products/%s/candles' % (API_URL, product_id)

no need to initialize each dictionary's key separately.

order = {}
order['side'] = side
order['price'] = price
order['size'] = size
order['product_id'] = product_id
order['type'] = order_type

order = {
    'side': side,
    'price': price,
    'size': size,
    'product_id': product_id,
    'type': order_type
}

consider parameter injection for the GDAXExchangeAuth instance in all your functions, it will simplify testing or reusing of the code with a different Authentication method.


Pylint complains about GDAXExchangeAuth class having too few public methods, but in this case I like the usage of a function class and there is no real need of other methods, so for me it's fine.

I assume this is probably just an example, but in any case I suggest also getting sensitive information from environment variables, something like

    import os

    API_PASSPHRASE = os.environ['API_PASSPHRASE']