Hi,
While sending multi legged option orders, using the method outlined here, I have the following question:
How exactly should we place the long and short positions of an option spread to ensure optimal execution? Should we always keep the long position of a spread first? If that is not the case, how exactly should we place our legs in our multi legged order?
The reason I am asking this is the following. After some time, my trading program fails with one of the following errors:
Error 1:
File “/root/miniconda3/lib/python3.12/site-packages/alpaca/common/rest.py”, line 207, in _one_request raise APIError(error, http_error) alpaca.common.exceptions.APIError: {“available”:“0”,“code”:40310000,“existing_qty”:“1”,“held_for_orders”:“1”,“message”:“insufficient qty available for order (requested: 1, available: 0)”,“related_orders”:[“503acd55-9a8c-477e-bb85-f10de42d80f3”],“symbol”:“”}ss
Error 2:
File “/root/miniconda3/lib/python3.12/site-packages/alpaca/common/rest.py”, line 207, in _one_request raise APIError(error, http_error) alpaca.common.exceptions.APIError: {“available”:“0”,“code”:40310000,“existing_qty”:“1”,“held_for_orders”:“1”,“message”:“insufficient qty available for order (requested: 1, available: 0)”,“related_orders”:[“503acd55-9a8c-477e-bb85-f10de42d80f3”],“symbol”:“”}
The reality is that I am not really trying to do any of these things(that is sell an uncovered option or sell beyond available quantity). Hence, I believe that this could be due to suboptimal placing of my multilegged order and wanted to explore more on the same.
I have another related question as well. If such an exception happens in the running of my program, how can I ignore the same and move forward rather than allowing the program to fail? I believe that would be useful to know as well.
Thanks