danpaquin/coinbasepro-python

AuthenticatedClient.place_stop_order Returning Invalid

ForrestHerman opened this issue · 3 comments

Currently using the below line of code to try and place a stop order

print(client.place_stop_order('ETH-USD','loss',1000.0,size=.001))

The resulting console output can be seen below

{'message': 'Invalid order_type stop'}

Checking my orders on Coinbase Pro confirms that no orders were placed.

The following two lines of code do however work

print(client.place_limit_order('ETH-USD','sell',4000.0,.001))

print(client.place_market_order('ETH-USD','sell',.001))

pip list shows cbpro as being version 1.1.4

Also seeing this same behavior using:
cbpro-notbroken v1.1.5
or
cbpro v1.1.4

Fixed in another repo. Remove this cbpro and:
pip install git+git://github.com/coin-tracker/coinbasepro-python.git
should give you the working version - the stop order syntax has changed slightly, so need to adjust. The new repo has updated README, so use that example.

There is this very "stupid" but very simple workarround:

instead of ussing place_stop_order() you can use place_order() with the parameters that would be used for place_stop_order(). It worked for me.

params = {'product_id': pair,
'side': "sell",
'price': new_price,
'order_type': "limit",
'stop': "loss",
'stop_price': new_price,
'size': new_size,
'funds': None,
'client_oid': None,
'stp': None,
'overdraft_enabled': None,
'funding_amount': None}
params = dict((k, v) for k, v in params.items() if v is not None)

out = client.place_order(**params)