Closed briansp2020 closed 5 years ago
@briansp2020 thanks for the feedback. Glad to year the software is useful to more than just me. Thank you also for surfacing your issue with the code snippets.
Quick answer, I have not tried using the code to buy back a shorted option.
If you wanted to come up with a solution, you could follow the api calls in Chrome's inspect while using the Robinhood website to see how RH closes them. I don't have an option option contracts atm but can look next week. Feel free to beat me to the punch.
@westonplatter Thanks for getting back to me. I'm not familiar with web stuff. So, if you can give me some pointers, I'd appreciate it.
If I right click on the submit button and select Inspect, will I be able to find out the information? There are so many tabs and sections, it's very hard to figure out where to look. If you can give me some simple steps to find out the necessary information for placing initial option orders (i.e. how to find
direction = "credit"
legs = [{ "side": "sell",
"option": candidate["url"],
"position_effect": "open",
"ratio_quantity": 1 }]
), maybe I can use same steps to find information for buying options to close...
essentially execute the "close option" workflow on robinhood's website and take this approach, https://www.youtube.com/watch?v=WOQDrGrd9H8, to confirm the HTTP params sent in the AJAX/API call to robinhood's backend.
@westonplatter Thanks for you help. I was able to successfully issue "buy to cover order". The information I get from OptionPosition.all & OptionPosition.mergein_market_list was slightly different. So, instead of specifying "url", I needed to specify "option"
legs = [{ "side": "buy",
"option": data["option"],
"position_effect": "close",
"ratio_quantity": 1 }]
@briansp2020 glad you found a solution.
and thanks for posting it to the thread. Definitely helpful to others who hit the same issue.
Hi, Thanks for the great software. I used option_order_place_single.py as the base to sell short an option contract and it works great. However, I'm having trouble buy an option contract to close it.
To sell short, I use
which works. To buy, I tried
I get the url of the option I sold short using OptionPosition.all & OptionPosition.mergein_market_list. Is there any issues that you are aware of in short selling options and buy options to close it?