Skip to content

Commit

Permalink
Merge pull request #421 from bvandorf/master
Browse files Browse the repository at this point in the history
fix account number and time in force and 400 error
  • Loading branch information
jmfernandes authored Aug 6, 2023
2 parents 3e3d74e + 85a7622 commit 5a5a68f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions robin_stocks/robinhood/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,11 @@ def request_post(url, payload=None, timeout=16, json=False, jsonify_data=True):
'Content-Type', 'application/x-www-form-urlencoded; charset=utf-8')
else:
res = SESSION.post(url, data=payload, timeout=timeout)
if res.status_code in [500,400]:
if res.status_code not in [200, 201, 202, 204, 301, 302, 303, 304, 307, 400, 401, 402, 403]:
raise Exception("Received "+ str(res.status_code))
data = res.json()
except Exception as message:
print("Error in request_post: {0}".format(message), file=get_output())
# Either return response <200,401,etc.> or the data that is returned from requests.
if jsonify_data:
return(data)
else:
Expand Down
4 changes: 2 additions & 2 deletions robin_stocks/robinhood/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ def order_option_credit_spread(price, symbol, quantity, spread, timeInForce='gtc
such as the order id, the state of order (queued, confired, filled, failed, canceled, etc.), \
the price, and the quantity.
"""
return(order_option_spread("credit", price, symbol, quantity, spread, timeInForce, account_number, jsonify))
return(order_option_spread("credit", price, symbol, quantity, spread, account_number, timeInForce, jsonify))


@login_required
Expand Down Expand Up @@ -933,7 +933,7 @@ def order_option_debit_spread(price, symbol, quantity, spread, timeInForce='gtc'
such as the order id, the state of order (queued, confired, filled, failed, canceled, etc.), \
the price, and the quantity.
"""
return(order_option_spread("debit", price, symbol, quantity, spread, timeInForce, account_number, jsonify))
return(order_option_spread("debit", price, symbol, quantity, spread, account_number, timeInForce, jsonify))


@login_required
Expand Down

0 comments on commit 5a5a68f

Please sign in to comment.