bitfinexcom / bitfinex-api-py

Apache License 2.0
200 stars 125 forks source link

API does not support Market orders. #171

Closed pycoder2014 closed 2 years ago

pycoder2014 commented 2 years ago

Issue type

Brief description

Neither the Rest nor Websocket api supports Market orders. That's not very nice. Is there a technical reason for this?

Steps to reproduce

-

Additional Notes:

-

itsdeka commented 2 years ago

Hello @pycoder2014, I am pretty sure it is possible to send market orders using REST and WS APIs.

from bfxapi.models.order import OrderType
response = await bfx.rest.submit_order("tBTCUSD", 10, market_type=OrderType.MARKET)
pycoder2014 commented 2 years ago

Hi Dario, If you take a closer look at the signature of that submit_order function, you'll see that it takes price as a positional argument therefore its required.

https://github.com/bitfinexcom/bitfinex-api-py/blob/a7eade4cdabde03073bb49946190c3b5668ca0ac/bfxapi/rest/bfx_rest.py#L735

itsdeka commented 2 years ago

Oh, I am sorry. You are right. I am opening a PR to fix it. Of course, you can just pass price=None to use it with the already published version of this library.

from bfxapi.models.order import OrderType
response = await bfx.rest.submit_order(symbol="tBTCUSD", amount=0.1, price=None, market_type=OrderType.MARKET)
itsdeka commented 2 years ago

https://github.com/bitfinexcom/bitfinex-api-py/pull/174

itsdeka commented 2 years ago

https://github.com/bitfinexcom/bitfinex-api-py/pull/175

vigan-abd commented 2 years ago

hi @itsdeka @pycoder2014 merged example usage for market order (https://github.com/bitfinexcom/bitfinex-api-py/pull/175), closing the issue