tedchou12 / webull

Unofficial APIs for Webull.
MIT License
597 stars 181 forks source link

is it possible to place multi-leg option positions such as vertical spread? #293

Closed GuohaiZhou closed 2 years ago

GuohaiZhou commented 2 years ago

I tried to manually place orders for each leg but failed. For example, I can successfully buy a call option using the place_order_option() method but then I got the 'place_option_order failed' message when trying to sell a call option (same underlying stock and expiration date but a higher strike price). Any suggestions are highly appreciated.

kylethej commented 2 years ago

This isn't so much a suggestion as it is an observation, but I created an order for 8 Call Vertical Debit Spreads on the SPY for strikes 435/436 on Mon 4/11. I made sure to ask for a price well out of range so it wouldn't get filled. Then I hopped over to Visual Basic and looked at outstanding orders using the Webull documentation listed, and it displayed the following information about the order:

[{'ticker': {'tickerId': 913243251, 'symbol': 'SPY', 'name': 'Spdr S&P 500 Etf', 'tinyName': 'Spdr S&P 500 Etf', 'listStatus': 1, 'exchangeCode': 'PSE', 'exchangeId': 34, 'type': 3, 'regionId': 6, 'currencyId': 247, 'currencyCode': 'USD', 'secType': [1, 34, 12], 'exchangeTrade': True, 'disExchangeCode': 'NYSEARCA', 'disSymbol': 'SPY'}, 'orderId': 567284576460881920, 'brokerOrderId': 'QAJGG86EFS6P8M84BNNP1KP6IA', 'brokerId': 8, 'orderNum': '2204113170254', 'assetType': 'option', 'orderType': 'LMT', 'action': 'BUY', 'status': 'Submitted', 'statusCode': 'Working', 'statusStr': 'Working', 'lmtPrice': '0.9800', 'avgFilledPrice': '0.0000', 'totalQuantity': '8', 'filledQuantity': '0', 'createTime': '04/11/2022 13:11:53 EDT', 'createTime0': 1649697113000, 'updateTime': '04/11/2022 13:11:53 EDT', 'updateTime0': 1649697113000, 'remainQuantity': '8', 'entrustType': 'QTY', 'timeInForce': 'DAY', 'outsideRegularTradingHour': False, 'filledValue': '0.0000', 'orderSource': 'iOS', 'relation': 'normal', 'priceTolerance': '0', 'canModify': True, 'canCancel': True, 'comboType': 'NORMAL', 'comboId': 'GPGKIHDUQTMQ33J85SP9592NSA', 'expireTime': 'Day'}]

It looks like all the above information must be included when placing an order for a vertical spread. Most of the text above is relating to the SPY (SEC type, currency code, region ID, etc.) and I'm guessing the text that relates to vertical spreads is ComboID, ComboType, and relation. So if one were to attempt to order a spread on Webull, it'd likely need these arguments. I'm hoping that there is a way to generate a ComboID that relates to the specific spread the user would like to order. I briefly tried finding any documentation on the web for comboID's but found none. If we need a comboid in order to order a spread and there's no way to find the corresponding ID for the vertical of interest, then placing a vertical won't be possible.

EDIT: TLDR - Need a few additional arguments basically saying " I want a vertical" and a corresponding ID for the Vertical that specifically point to the options that should be ordered so that the request can be filled.