boyan-soubachov / tastyworks_api

An unofficial, reverse-engineered Python API for tastyworks.
Apache License 2.0
209 stars 79 forks source link

Cancelling Working Order #94

Open gblankford opened 2 years ago

gblankford commented 2 years ago

Has anyone figured out how to cancel an unfilled or partially filled order? I may be missing it here, but would love assistance in figuring that out.

bandwiches commented 2 years ago

Do you mean how to cancel a quote? I'm not sure I'm following your question.

gblankford commented 2 years ago

Not quite. Say you put in an order to buy 5 calls at $3000 strike for AAPL with limit price $10. If none of your order is filled, how would you cancel this order using the API?

bandwiches commented 2 years ago

I don't see any method for doing that. I would think that would be listed under the trading_account model, but I don't see any reference other than executing an order. From a quick look, below is a good starting point. Please note that this has not been tested, but is a good starting point.

url="https://api.tastyworks.com/accounts/{}/orders/{}".format(
  account_number,
  order_number
)
requests.delete(url, headers=session.get_request_headers())

Edit: When I say this hasn't been tested, I mean strictly in Python it hasn't been tested.