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: bug fetching order after market buy order

See original GitHub issue

Hello, first I would like to thank you for producing such an extremely excellent module.

I’m having an issue fetching orders after placing a market buy order on gdax. Gdax allows you to specify the funds you want to spend as an alternative to the size.

I can successfully place a market buy order like this: gdax.createMarketBuyOrder(‘BTC/USD’, 0.0, {‘funds’: ‘1000.0’}) and checking my account, I can see that it worked. However, when I then try to fetch the order, I get the following error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/ccxt/gdax.py", line 356, in fetch_order
    return self.parse_order(response)
  File "/usr/lib/python2.7/site-packages/ccxt/gdax.py", line 330, in parse_order
    remaining = amount - filled
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'

The information I want is returned in the HTML, but I’m not sure how to access it given that gdax.py throws this error. Your help in this matter would be really appreciated.

OS: Amazon Linux 2.0 (2017.12) LTS Release Candidate Programming Language version: python CCXT version: 1.10.802 Exchange: gdax Method: createMarketBuyOrder, fetch_order

I turned verbose on, and the full output (with personal info redacted) is as follows. Many thanks for your help.

gdax.createMarketBuyOrder('BTC/USD', 0.0, {'funds': '1000.0'})
('GET', 'https://api-public.sandbox.gdax.com/products', '\nRequest:', {'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'}, None)
('GET', 'https://api-public.sandbox.gdax.com/products', '\nResponse:', '{\'Expect-CT\': \'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"\', \'Access-Control-Allow-Methods\': \'GET,POST,DELETE,PUT\', \'X-Content-Type-Options\': \'nosniff\', \'Access-Control-Expose-Headers\': \'cb-before, cb-after\', \'Transfer-Encoding\': \'chunked\', \'Set-Cookie\': \'__cfduid=REDACTED; expires=Wed, 23-Jan-19 11:23:49 GMT; path=/; domain=.gdax.com; HttpOnly\', \'Access-Control-Max-Age\': \'7200\', \'Server\': \'cloudflare\', \'Connection\': \'keep-alive\', \'ETag\': \'W/"6ff-HaU1+dUd5wDANbSVz+GWJMt+iFY"\', \'Strict-Transport-Security\': \'max-age=15552000; includeSubDomains; preload\', \'Cache-Control\': \'public, max-age=5\', \'Date\': \'Tue, 23 Jan 2018 11:23:49 GMT\', \'Access-Control-Allow-Origin\': \'*\', \'Access-Control-Allow-Headers\': \'Content-Type, Accept, cb-session, cb-fp\', \'Content-Type\': \'application/json; charset=utf-8\', \'CF-RAY\': \'3e1a6210c8789f54-IAD\', \'Content-Encoding\': \'gzip\'}', u'[{"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","status":"online","margin_enabled":true,"status_message":null},{"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","status":"online","margin_enabled":false,"status_message":null},{"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","status":"online","margin_enabled":false,"status_message":null},{"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","status":"online","margin_enabled":false,"status_message":null},{"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","status":"online","margin_enabled":true,"status_message":null},{"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","status":"online","margin_enabled":false,"status_message":null},{"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","status":"online","margin_enabled":false,"status_message":null},{"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","status":"online","margin_enabled":false,"status_message":null}]')
('POST', 'https://api-public.sandbox.gdax.com/orders', '\nRequest:', {'Accept-Encoding': 'gzip, deflate', 'CB-ACCESS-SIGN': u'REDACTED', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36', 'Content-Type': 'application/json', 'CB-ACCESS-KEY': 'REDACTED', 'CB-ACCESS-TIMESTAMP': '1516706630', 'CB-ACCESS-PASSPHRASE': 'REDACTED'}, '{"funds":"1000.0","size":0.0,"type":"market","side":"buy","product_id":"BTC-USD"}')
('POST', 'https://api-public.sandbox.gdax.com/orders', '\nResponse:', '{\'Expect-CT\': \'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"\', \'Access-Control-Allow-Methods\': \'GET,POST,DELETE,PUT\', \'X-Content-Type-Options\': \'nosniff\', \'Access-Control-Expose-Headers\': \'cb-before, cb-after\', \'Transfer-Encoding\': \'chunked\', \'Set-Cookie\': \'__cfduid=REDACTED; expires=Wed, 23-Jan-19 11:23:49 GMT; path=/; domain=.gdax.com; HttpOnly\', \'Access-Control-Max-Age\': \'7200\', \'Server\': \'cloudflare\', \'Connection\': \'keep-alive\', \'ETag\': \'W/"177-tSBspF6tI55zJVRpc8qaGFOxFic"\', \'Strict-Transport-Security\': \'max-age=15552000; includeSubDomains; preload\', \'Date\': \'Tue, 23 Jan 2018 11:23:49 GMT\', \'Access-Control-Allow-Origin\': \'*\', \'Access-Control-Allow-Headers\': \'Content-Type, Accept, cb-session, cb-fp\', \'Content-Type\': \'application/json; charset=utf-8\', \'CF-RAY\': \'3e1a621168da9f54-IAD\', \'Content-Encoding\': \'gzip\'}', u'{"id":"4c00d963-8a9c-4180-ae6e-831dfcb1df02","product_id":"BTC-USD","side":"buy","stp":"dc","funds":"997.5062344100000000","specified_funds":"1000.0000000000000000","type":"market","post_only":false,"created_at":"2018-01-23T11:23:50.051153Z","fill_fees":"0.0000000000000000","filled_size":"0.00000000","executed_value":"0.0000000000000000","status":"pending","settled":false}')
{'info': {u'status': u'pending', u'post_only': False, u'specified_funds': u'1000.0000000000000000', u'product_id': u'BTC-USD', u'fill_fees': u'0.0000000000000000', u'funds': u'997.5062344100000000', u'created_at': u'2018-01-23T11:23:50.051153Z', u'id': u'4c00d963-8a9c-4180-ae6e-831dfcb1df02', u'stp': u'dc', u'settled': False, u'executed_value': u'0.0000000000000000', u'type': u'market', u'side': u'buy', u'filled_size': u'0.00000000'}, 'id': u'4c00d963-8a9c-4180-ae6e-831dfcb1df02'}
gdax.fetch_order('4c00d963-8a9c-4180-ae6e-831dfcb1df02')
('GET', 'https://api-public.sandbox.gdax.com/orders/4c00d963-8a9c-4180-ae6e-831dfcb1df02', '\nRequest:', {'Accept-Encoding': 'gzip, deflate', 'CB-ACCESS-SIGN': u'REDACTED', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36', 'Content-Type': 'application/json', 'CB-ACCESS-KEY': 'REDACTED', 'CB-ACCESS-TIMESTAMP': '1516706676', 'CB-ACCESS-PASSPHRASE': 'REDACTED'}, None)
('GET', 'https://api-public.sandbox.gdax.com/orders/4c00d963-8a9c-4180-ae6e-831dfcb1df02', '\nResponse:', '{\'Expect-CT\': \'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"\', \'Access-Control-Allow-Methods\': \'GET,POST,DELETE,PUT\', \'X-Content-Type-Options\': \'nosniff\', \'Access-Control-Expose-Headers\': \'cb-before, cb-after\', \'Transfer-Encoding\': \'chunked\', \'Set-Cookie\': \'__cfduid=REDACTED; expires=Wed, 23-Jan-19 11:24:35 GMT; path=/; domain=.gdax.com; HttpOnly\', \'Access-Control-Max-Age\': \'7200\', \'Server\': \'cloudflare\', \'Connection\': \'keep-alive\', \'ETag\': \'W/"1b1-Hnb76s1ZMHi2NrrOE4e0B3F6rDY"\', \'Strict-Transport-Security\': \'max-age=15552000; includeSubDomains; preload\', \'Date\': \'Tue, 23 Jan 2018 11:24:35 GMT\', \'Access-Control-Allow-Origin\': \'*\', \'Access-Control-Allow-Headers\': \'Content-Type, Accept, cb-session, cb-fp\', \'Content-Type\': \'application/json; charset=utf-8\', \'CF-RAY\': \'3e1a63320d7c9f54-IAD\', \'Content-Encoding\': \'gzip\'}', u'{"id":"4c00d963-8a9c-4180-ae6e-831dfcb1df02","product_id":"BTC-USD","side":"buy","stp":"dc","funds":"997.5062344100000000","specified_funds":"1000.0000000000000000","type":"market","post_only":false,"created_at":"2018-01-23T11:23:50.051153Z","done_at":"2018-01-23T11:23:50.068Z","done_reason":"filled","fill_fees":"2.4937653549095000","filled_size":"0.09188473","executed_value":"997.5061419638000000","status":"done","settled":true}')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/ccxt/gdax.py", line 356, in fetch_order
    return self.parse_order(response)
  File "/usr/lib/python2.7/site-packages/ccxt/gdax.py", line 330, in parse_order
    remaining = amount - filled
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
robingliscommented, Jan 23, 2018

Hmmm. Well, that’s the output I get. I guess the object returned by the market buy order is returned before the order is filled?

1reaction
robingliscommented, Jan 23, 2018

P.s. I created a trivial fix by replacing line 330 of the ccxt file gdax.py remaining = amount - filled with an if statement that sets remaining to 0.0 is amount is None. Let me know if you want me to submit that as a pull request.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stop Order on Coinbase Pro | What the WARNINGS Mean
Stop orders are just market /limit orders with a trigger called the stop price. When the stop price is triggered, the order is...
Read more >
7 Buy side stop orders | Trading on Coinbase Pro - GDAX
Let's continue our discussion on stop orders. There are two ways to configure a buy side stop order, and I'm going to show...
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 on...
Read more >
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 >
GDAX API: getting status 'rejected' (reject_reason: post only ...
"Post Only" buy orders must have a price that is less than the current market price that people are willing to sell at....
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