Skip to content

Commit

Permalink
code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
henryzhangpku committed Jun 27, 2023
1 parent d05b869 commit f39ca92
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions robin_stocks/robinhood/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,24 +846,27 @@ def order(symbol, quantity, side, limitPrice=None, stopPrice=None, account_numbe
'trigger': trigger,
'side': side,
'market_hours': "regular_hours",
'extended_hours': extendedHours
'extended_hours': extendedHours,
'order_form_version': 4
}
if orderType == 'market' and side == 'sell':
del payload['price']
del payload['stop_price']
if orderType == 'market' and side == 'buy':
del payload['stop_price']
payload['type'] = 'limit'

# BEGIN PATCH FOR NEW ROBINHOOD BUY FORM (GuitarGuyChrisB 5/26/2023)
if side == "buy":
payload['order_form_version'] = 4
payload['preset_percent_limit'] = "0.05"
# END PATCH FOR NEW ROBINHOOD BUY FORM (GuitarGuyChrisB 5/26/2023)


if orderType == 'market' and side == 'buy':
del payload['stop_price']
del payload['extended_hours']
payload['type'] = 'limit'

if orderType == 'market' and side == 'sell':
del payload['price']
del payload['stop_price']
del payload['extended_hours']

url = orders_url()


data = request_post(url, payload, jsonify_data=jsonify)

return(data)
Expand Down

0 comments on commit f39ca92

Please sign in to comment.