tedchou12 / webull

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

cannot place a stop order or stop-limit #428

Open apimir opened 6 months ago

apimir commented 6 months ago

I can't set stop orders:

wb.place_order(stock='CGEN', action='SELL', orderType='STP TRAIL', quant=1, trial_value='-5', enforce='DAY')
{'msg': 'GTX_NOT_SUPPORT_MARKET', 'code': '200', 'success': False}

wb.place_order(stock='CGEN', action='SELL', orderType='STP', quant=1, stpPrice=format(1.9, '.2f'), enforce='DAY')
{'msg': 'GTX_NOT_SUPPORT_MARKET', 'code': '200', 'success': False}

wb.place_order(stock='CGEN', price='1.68', stpPrice='1.78', action='SELL', orderType='STP LMT', quant=1, enforce='GTC', outsideRegularTradingHour=True)
{'msg': 'STOP_ORDER_NOT_SUPPORT_EXTEND_HOUR', 'code': '200', 'success': False}

wb.place_order(stock='CGEN', price='1.68', stpPrice='1.78', action='SELL', orderType='STP LMT', quant=1, enforce='GTC', outsideRegularTradingHour=False)
{'msg': 'CASH_ACCOUNT_CAN_NOT_SELL_SHORT', 'code': '200', 'success': False}

How to correct way to use place_order with action=SELL and orderType='STP'?

With orderType='LMT' everything works fine.

ICANTFINDAUSERNAMEATALL commented 6 months ago

In the last line, you need a lmtPrice instead of just price, I believe. Lmk if it works

apimir commented 6 months ago

it's did not work lmtPrice doesn't exist for place_order:

>>> help(wb.place_order)
Help on method place_order in module webull.webull:

place_order(stock=None, tId=None, price=0, action='BUY', orderType='LMT', enforce='GTC', quant=0, outsideRegularTradingHour=True, stpPrice=None, trial_value=0, trial_type='DOLLAR') method of webull.webull.webull instance
    Place an order

    price: float (LMT / STP LMT Only)
    action: BUY / SELL / SHORT
    ordertype : LMT / MKT / STP / STP LMT / STP TRAIL
    timeinforce:  GTC / DAY / IOC
    outsideRegularTradingHour: True / False
    stpPrice: float (STP / STP LMT Only)
    trial_value: float (STP TRIAL Only)
    trial_type: DOLLAR / PERCENTAGE (STP TRIAL Only)

But I have tried with another stock CNVS and it's works fine:

>>> wb.place_order(stock='CNVS', price='1', stpPrice='1.1', action='SELL', orderType='STP LMT', quant=1, enforce='GTC', outsideRegularTradingHour=False)
{'success': True, 'data': {'orderId': 'CRG6MP450248911EU01PPJM308'}}

I guess in first my post I tried to set wrong price, I mean according to this picture: telegram-cloud-photo-size-1-4933917456389483709-x

You can't set Stop Loss Price below Stop limit Price and Stop Limit Price can't be more than your Buy Price

I think we can close the issue.

winstonwilliamsiii commented 2 months ago

I will try to use these WeBull API this week. Any new updates before I run the code?