Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

td.exceptions.ForbidError: { "error" : "You don't have permission to access this resource." #241

Open
andyquek opened this issue May 21, 2022 · 2 comments

Comments

@andyquek
Copy link

andyquek commented May 21, 2022

Hi All

I'm trying to place a trade using the paper account, however im getting an error saying i dont have permission to access this resource.

i'm not able to find any info on what could be the problem, does anyone knows what could be causing the error?

import time

from config import CONSUMER_KEY, REDIRECT_URI, JSON_PATH, ACCOUNT_NUMBER
from hqtrades import TD_ACCOUNT
from datetime import datetime
from datetime import timedelta
import pprint
import pandas as pd

# Import the client
from td.client import TDClient

# Create a new session, credentials path is required.
TDSession = TDClient(
    client_id=CONSUMER_KEY,
    redirect_uri=REDIRECT_URI,
    credentials_path='JSON_PATH',
    account_number=ACCOUNT_NUMBER
)

# Login to the session
TDSession.login()

  # Define the Order.
  order_template = buy_limit_enter = {
      "orderType": "LIMIT",
      "session": "NORMAL",
      "duration": "DAY",
      "price": 10.0,
      "orderStrategyType": "SINGLE",
      "orderLegCollection": [
          {
              "instruction": "BUY",
              "quantity": 1,
              "instrument": {
                  "symbol": "MSFT",
                  "assetType": "EQUITY"
              }
          }
      ]
  }

  # Place the Order.
  order_response = TDSession.place_order(
      account=ACCOUNT_NUMBER,
      order=order_template
  )

  # Print the Response.
  pprint.pprint(order_response)

Below are the results:

Traceback (most recent call last):
  File "F:\using_td_library.py", line 145, in <module>
    order_response = TDSession.place_order(
  File "F:\venv\lib\site-packages\td\client.py", line 1925, in place_order
    return self._make_request(method='post', endpoint=endpoint, mode='json', json=order, order_details=True)
  File "F:\venv\lib\site-packages\td\client.py", line 624, in _make_request
    raise ForbidError(message=response.text)
td.exceptions.ForbidError: {
  "error" : "You don't have permission to access this resource."
}

Process finished with exit code 1
@JuanFontana
Copy link

Hello, I have the same problem, could you solve it?

@TamirP
Copy link

TamirP commented Feb 11, 2023

after debugging my issue, seems i passed incorrect account_id in the URL (None instead of the actual account Id), not an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants