pyetrade
pyetrade copied to clipboard
Preview equity order doesn't work
Hi,
I'm trying to preview (and later on place) an equity order. It seems authentication runs and I'm getting tokens. This is the code I'm running (somehow code envioement scrambles the code):
oauth = pyetrade.ETradeOAuth(consumer_key1, consumer_secret1) authorize_url = oauth.get_request_token() webbrowser.open(authorize_url) text_code = input('Please accept agreement and enter text code from browser: ') token1 = oauth.get_access_token(text_code) client_order_id = random.randint(1000000000, 9999999999) order = pyetrade.ETradeOrder(consumer_key1, consumer_secret1, token1['oauth_token'], token1['oauth_token_secret'], dev=False) data = order.preview_equity_order(resp_format='json', accountId=account_id_key1, symbol='F', orderAction='BUY', clientOrderId=client_order_id, priceType='LIMIT', limitPrice=2.1, quantity=3, marketSession='REGULAR', orderTerm='GOOD_UNTIL_CANCEL')
and I'm getting this Traceback:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.1\plugins\python-ce\helpers\pydev\pydevd.py", line 1448, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.1\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/Owner/PycharmProjects/stacky/etrade_api.py", line 94, in
Your help will be greatly appreciated.
I think your issue here is that you are trying to pass your account id key as your account id.
@ortamir did this solve your issue?