Open dubleigh opened 2 years ago
Hello TedChou12
Some background on the issue:
The code works if 'STP' is changed to 'LMT', however this converts the stop-loss into a limit order
Thank you!
Hello,
Looks like the error might be related to needing a new function for modifying combo orders?
thanks! Let me take a look! πππ
@dubleigh
Sorry for the delay, did you use the
modify_order_otoco
?
Does it not work?
Hello Ted, I will need to check that function again. Last time I remember using it, it worked for open orders that had not yet been placed as I was able to provide all of the information for the function. For placed orders, how would I handle the "order_id1" and "price" fields? Would I only provide information for the one order that will be modified? Thank you!
modify_order_otoco(self, order_id1='', order_id2='', order_id3='', stock='', price='', stop_loss_price='', limit_profit_price='', time_in_force='DAY', quant=0)
Hello Ted,
I am testing out using the modify_order_otoco command for an OTOCO order that has already been executed (the master order has turned into a position) and i am still getting errors. I am uncertain what to enter for the master order, as this is not really an order anymore, but a position where I cannot control the price.
Code:
# Stock Info:
stock = 'ATEN'
time_in_force = 'GTC'
quant = 16
# Master Order:
order_id1 = 548446791318669312
price = 13.02
# Stop loss:
order_id2 = 548446789645137920
stop_loss_price = 12.15
# Take Profit:
order_id3 = 548446789649332224
limit_profit_price = 15.00
result = wb.modify_order_otoco(order_id1=order_id1, order_id2=order_id2, order_id3=order_id3, stock=stock, price=price,
stop_loss_price=stop_loss_price, limit_profit_price=limit_profit_price, time_in_force=time_in_force, quant=quant)
pp.pprint(result)
Results in:
{ 'code': '500', 'msg': '', 'success': False, 'traceId': '7e99abff01304ec2b0cb5205610d16c2'}
When substituting the comboId (RVHG1M8H8JH668VE2SOJ228V4A) for any of the orderId's I get the following error:
{ 'code': '400',
'msg': 'JSON parse error: Cannot deserialize value of type '
'java.lang.Long
from String "RVHG1M8H8JH668VE2SOJ228V4A": not a '
'valid Long value; nested exception is '
'com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot '
'deserialize value of type java.lang.Long
from String '
'"RVHG1M8H8JH668VE2SOJ228V4A": not a valid Long value\n'
' at [Source: (PushbackInputStream); line: 1, column: 619] (through '
'reference chain: '
'com.webull.trade.api.v2.model.order.ComboOrderRequest["modifyOrders"]->java.util.ArrayList[2]->com.webull.trade.api.model.order.ReqPlaceOrder["orderId"])',
'success': False,
'traceId': 'a7025ff8b60c402a94e6811835b1bb66'}
Do you think this modify_order_otoco command is supposed to work for open orders only? (where all three orders are open and not when the master order has been exercised and is now a position)
Thank you!
It seems as if the modify_order_otoco from the API requires three groups of data under 'modifyOrders' (master order, stop loss, take profit) whereas the screen capture from the webull website above only requires two fields (stop loss, take profit). My initial thought is that an additional command is needed for managing the existing open orders once the original master order is executed and turned into a position. This additional command only has fields for the remaining open orders and omits the original master order details.
It seems as if the modify_order_otoco from the API requires three groups of data under 'modifyOrders' (master order, stop loss, take profit) whereas the screen capture from the webull website above only requires two fields (stop loss, take profit). My initial thought is that an additional command is needed for managing the existing open orders once the original master order is executed and turned into a position. This additional command only has fields for the remaining open orders and omits the original master order details.
cc: @tedchou12 @dubleigh , were you able to get to the bottom of this?
Essentially what i'm trying to do is -
Hello,
When modifying a STP order, by adjusting the price input, I get an error. Below is the print out of my variables along with the response from webull:
WEBULL: Modifying order_id: 525616357736200192, stock: EPM, price: 4.5, action: SELL, orderType: STP, enforce: GTC, quant: 14, outsideRegularTradingHour: True { 'code': 'trade.webull.SYSTEM_INTERNAL_ERROR', 'data': {}, 'msg': 'Inner server error', 'success': False, 'traceId': '3GHU1LBISTP32PDBREVMJTVRDB'}
Below is the corresponding code:
order_id = 525616357736200192 stock = 'EPM' price = 4.600 action = 'SELL' orderType = 'STP' enforce = 'GTC' quant = 14 outsideRegularTradingHour = True
Would you mind taking a look to see what I am doing wrong? Thank you!