pyetrade icon indicating copy to clipboard operation
pyetrade copied to clipboard

Invalid Order Requests

Open gbpnkans opened this issue 5 years ago • 1 comments

orders.place_equity_order('json', accountId = 'XX', symbol=symbol, orderAction='SELL_SHORT', clientOrderId=uuid.uuid4().hex, priceType='LIMIT', limitPrice=float(price), quantity=int(float(qty)), marketSession='EXTENDED', orderTerm='GOOD_FOR_DAY')

send: b'{"PreviewOrderRequest": {"orderType": "EQ", "clientOrderId": "d0068a1b51fb46fc94dca56cab49bacd", "Order": {"accountId": "XXX", "symbol": "UCO", "orderAction": "SELL_SHORT", "clientOrderId": "d0068a1b51fb46fc94dca56cab49bacd", "priceType": "LIMIT", "limitPrice": 10.5, "quantity": 10, "marketSession": "EXTENDED", "orderTerm": "GOOD_FOR_DAY", "Instrument": {"Product": {"securityType": "EQ", "symbol": "UCO"}, "orderAction": "SELL_SHORT", "quantityType": "QUANTITY", "quantity": 10}, "stopPrice": ""}}}'

Response from Etrade:

reply: 'HTTP/1.1 400 Bad Request\r\n' header: Date: Mon, 18 May 2020 02:57:24 GMT header: Server: Apache header: Cache-Control: no-cache, no-store header: Pragma: no-cache header: apiServerName: 40w303m5 header: Set-Cookie: JSESSIONID=46B2CF38EC415F7C92ACA45AB9B1E17D.tomcat1;path=/;Secure;HttpOnly header: Cneonction: close header: Transfer-Encoding: chunked header: Content-Type: application/xml DEBUG:urllib3.connectionpool:https://apisb.etrade.com:443 "POST /v1/accounts/XX/orders/preview HTTP/1.1" 400 None DEBUG:pyetrade.order:<Error> 9999 Please validate the input and try again </Error>

Looks like stopPrice is sent irrespective of the order type. Don't know how this module is working to execute trade?

AccountID is obfuscated

Can someone please help if I'm missing something?

gbpnkans avatar May 18 '20 03:05 gbpnkans

I too am having the same problem. I have tried for a day now trying to get an order placed. out of hundreds of trials, somehow the very first one and another one worked, however, all other trials failed. it will be great if someone can please help provide some ideas what to do?

I initially thought maybe the payload generation part is not good as it's missing something like limitPrice, but adding that does not seem to help.

seand168 avatar Jan 26 '21 05:01 seand168