question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gdax trying to put limit or market trade

See original GitHub issue

Having a lot of trouble making trade on gdax.

When trying to call your own method for gdax create_limit_buy this happens

    return self.create_limit_buy_order (product, amount, price, params)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\ccxt\__init__.py", line 504, in create_limit_buy_order
    return self.create_order (product, 'limit', 'buy', amount, price, params)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\ccxt\__init__.py", line 6416, in create_order
    return self.privatePostOrder (self.extend (order, params))
AttributeError: 'gdax' object has no attribute 'privatePostOrder'

When trying to write my own method

response = gdax.request('orders', 'private', 'POST', params={'type': 'limit',
                                                             'side': 'buy',
                                                             'product_id': product,
                                                             'price': 3000,
                                                             'size': 1.0})   

this happens

https://api-public.sandbox.gdax.com/orders POST {'CB-ACCESS-KEY': 'ba6e6e102338f6e66244d804984bdc1e', 'CB-ACCESS-SIGN': b'pMfi9OUiCJX9YqFktaVXycNqD7MFpbEWIYgWRvwD0nI=', 'CB-ACCESS-TIMESTAMP': '1500374457', 'CB-ACCESS-PASSPHRASE': '**********', 'User-Agent': 'ccxt/1.0.158 (+https://github.com/kroitor/ccxt) Python/3.6.1'} {"type":"limit","side":"buy","product_id":"BTC/USD","price":3000,"size":1.0}
Traceback (most recent call last):
gdax POST https://api-public.sandbox.gdax.com/orders 400 Bad Request b'{"message":"invalid signature"}'
  File "C:\oop\novi ws\Crypto\testGdax.py", line 23, in <module>
    'size': 1.0})
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\ccxt\__init__.py", line 6441, in request
    return self.fetch (url, method, headers, body)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\ccxt\__init__.py", line 207, in fetch
    response = opener.open (request, timeout = int (self.timeout / 1000))
  File "C:\Program Files (x86)\Python36-32\lib\urllib\request.py", line 532, in open
    response = meth(req, response)
  File "C:\Program Files (x86)\Python36-32\lib\urllib\request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Program Files (x86)\Python36-32\lib\urllib\request.py", line 570, in error
    return self._call_chain(*args)
  File "C:\Program Files (x86)\Python36-32\lib\urllib\request.py", line 504, in _call_chain
    result = func(*args)
  File "C:\Program Files (x86)\Python36-32\lib\urllib\request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kroitorcommented, Jul 18, 2017

Ok, I fixed it, finally. Now it replies with “Insufficient funds” as it should. Code for testing:

# Python
import ccxt
gdax = ccxt.gdax ({ 
	'apiKey': '92560ffae9b8a01d012726c698bcb2f1', # standard
	'secret': '9aHjPmW+EtRRKN/OiZGjXh8OxyThnDL4mMDre4Ghvn8wjMniAr5jdEZJLN/knW6FHeQyiz3dPIL5ytnF0Y6Xwg==', 
	'password': '6kszf4aci8r', # GDAX requires a password!
})
gdax.urls['api'] = 'https://api-public.sandbox.gdax.com'
gdax.load_products ()
gdax.create_limit_buy_order ('BTC/USD', 1, 2000)

The problem was that their sandbox does not accept client_oid field. Removed it. Should work now. Thanks again!

0reactions
kroitorcommented, Jul 18, 2017

So now it says “Insufficient funds” as it should… Will add an exception for this case, though.

mbp:ccxt igorkroitor$ python3
Python 3.6.1 (default, Jul 10 2017, 04:32:51) 
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ccxt
>>> gdax = ccxt.gdax ({ 
...     'apiKey': '92560ffae9b8a01d012726c698bcb2f1', # standard
...     'secret': '9aHjPmW+EtRRKN/OiZGjXh8OxyThnDL4mMDre4Ghvn8wjMniAr5jdEZJLN/knW6FHeQyiz3dPIL5ytnF0Y6Xwg==', 
...     'password': '6kszf4aci8r', # GDAX requires a password!
... })
>>> gdax.urls['api'] = 'https://api-public.sandbox.gdax.com'
>>> gdax.load_products ()
{'BTC/USD': {'id': 'BTC-USD', 'symbol': 'BTC/USD', 'base': 'BTC', 'quote': 'USD', 'info': {'id': 'BTC-USD', 'base_currency': 'BTC', 'quote_currency': 'USD', 'base_min_size': '0.01', 'base_max_size': '10000', 'quote_increment': '0.01', 'display_name': 'BTC/USD'}}, 'BTC/GBP': {'id': 'BTC-GBP', 'symbol': 'BTC/GBP', 'base': 'BTC', 'quote': 'GBP', 'info': {'id': 'BTC-GBP', 'base_currency': 'BTC', 'quote_currency': 'GBP', 'base_min_size': '0.01', 'base_max_size': '10000', 'quote_increment': '0.01', 'display_name': 'BTC/GBP'}}, 'BTC/EUR': {'id': 'BTC-EUR', 'symbol': 'BTC/EUR', 'base': 'BTC', 'quote': 'EUR', 'info': {'id': 'BTC-EUR', 'base_currency': 'BTC', 'quote_currency': 'EUR', 'base_min_size': '0.01', 'base_max_size': '10000', 'quote_increment': '0.01', 'display_name': 'BTC/EUR'}}, 'ETH/BTC': {'id': 'ETH-BTC', 'symbol': 'ETH/BTC', 'base': 'ETH', 'quote': 'BTC', 'info': {'id': 'ETH-BTC', 'base_currency': 'ETH', 'quote_currency': 'BTC', 'base_min_size': '0.01', 'base_max_size': '1000000', 'quote_increment': '0.00001', 'display_name': 'ETH/BTC'}}, 'ETH/USD': {'id': 'ETH-USD', 'symbol': 'ETH/USD', 'base': 'ETH', 'quote': 'USD', 'info': {'id': 'ETH-USD', 'base_currency': 'ETH', 'quote_currency': 'USD', 'base_min_size': '0.01', 'base_max_size': '1000000', 'quote_increment': '0.01', 'display_name': 'ETH/USD'}}, 'LTC/BTC': {'id': 'LTC-BTC', 'symbol': 'LTC/BTC', 'base': 'LTC', 'quote': 'BTC', 'info': {'id': 'LTC-BTC', 'base_currency': 'LTC', 'quote_currency': 'BTC', 'base_min_size': '0.01', 'base_max_size': '1000000', 'quote_increment': '0.00001', 'display_name': 'LTC/BTC'}}, 'LTC/USD': {'id': 'LTC-USD', 'symbol': 'LTC/USD', 'base': 'LTC', 'quote': 'USD', 'info': {'id': 'LTC-USD', 'base_currency': 'LTC', 'quote_currency': 'USD', 'base_min_size': '0.01', 'base_max_size': '1000000', 'quote_increment': '0.01', 'display_name': 'LTC/USD'}}, 'ETH/EUR': {'id': 'ETH-EUR', 'symbol': 'ETH/EUR', 'base': 'ETH', 'quote': 'EUR', 'info': {'id': 'ETH-EUR', 'base_currency': 'ETH', 'quote_currency': 'EUR', 'base_min_size': '0.01', 'base_max_size': '1000000', 'quote_increment': '0.01', 'display_name': 'ETH/EUR'}}}
>>> gdax.create_limit_buy_order ('BTC/USD', 1, 2000)
gdax POST https://api-public.sandbox.gdax.com/orders 400 Bad Request b'{"message":"Insufficient funds"}'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/igorkroitor/ccxt/ccxt/__init__.py", line 504, in create_limit_buy_order
    return self.create_order (product, 'limit', 'buy', amount, price, params)
  File "/Users/igorkroitor/ccxt/ccxt/__init__.py", line 6422, in create_order
    return self.privatePostOrders (self.extend (order, params))
  File "/Users/igorkroitor/ccxt/ccxt/__init__.py", line 6448, in request
    return self.fetch (url, method, headers, body)
  File "/Users/igorkroitor/ccxt/ccxt/__init__.py", line 207, in fetch
    response = opener.open (request, timeout = int (self.timeout / 1000))
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
Read more comments on GitHub >

github_iconTop Results From Across the Web

Stop-limit order | How to set the limit | Coinbase Pro - GDAX
How to choose a limit price for a stop order. Let's take a look. See the full GDAX playlist here: VIDEO SECTIONS 00:00...
Read more >
5 Limit orders as makers | Trading on Coinbase Pro - GDAX
In this video, let's look at the next two limit order configurations. ... when we want to consider all possible variations of some...
Read more >
4 Limit orders as takers | Trading on Coinbase Pro - GDAX
In this video, we are going to keep talking about order types and parameters. We looked at market orders in the previous video...
Read more >
8 Stop-Limit orders | Trading on Coinbase Pro - GDAX
Let's look at stop- limit orders. I will show you how to configure them and verify their maker-taker status. We will also touch...
Read more >
Market, Limit, Stop, Stop-Limit | Order type summary explanation
Trading - Advanced Order Types with Coinbase. by DEEPLIZARD. Market, Limit, Stop, Stop- Limit | Order type summary explanation ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found