This video literally came out a few hours ago and someone already disliked it? This is an INCREDIBLY niche subject, that they took the time to wait for your upload to down vote it. Some people are entitled. : / Grateful you are providing much needed examples and clarification on the topic, man. :D
Great content as always. Just a few helpful tips for anyone watching this who downloaded the library recently through pip: In the TDClient object, update the following variable names to the ones on the right: consumer_id -> client_id json_path -> credentials_path Luckily, Sigma provided Intellicode snippets in VSCode so this was simple to figure out, buy others may be having trouble authenticating through the client. Thanks again!
This is such a niche subject, this is so awesome that you took the time to go through the (piss poor) documentation and made a REALLY functional library. If i've got a problem with the library its really easy for me to go into the code and look at the section im trying to use and see how its supposed to be used because you have made such well documented code, and made it so readable. Seriously, thank you.
OMG! Thanks for making this video! This video is so detailed for newbies like me. Very helpful! Every other video just says, "Download this and download that," and I'm like, "Download to where and how do you download it?"
Thanks for sharing! I have an app with hundreds of users and I can't afford to take the app down every 90 days. How can I automate the token renewal process?
Has anyone had any difficulties with calling the TDClient() instance? Apparently consumer_id and redirect_uri don't exist? Would love some help here, thanks!
The example files in github have changed a LOT since this video was made. I wish the videos matched the source code more. I have trouble mapping your terminology to the terminology of Tim Paine, Alex Golec, and the TD Ameritrade APIs themselves. Different terms are used to refer to the same things, like access_token, refresh_token, client_id, and so on. Could someone please provide a terminology mapping table for these different TDA API wrappers?
Hello Incredible video. I am building my first api with an extremly knowledgeable programmer. He is concerned about security abd would prefer if we made the API read only. For my purpose that is ok because I still want to trade in the TD ap or web or tos. So my question is there a read only key for TD? Or is there a view only username? Or is the streaming api read only ?
Hello. Thank you for the video. A single question. I have change consumer_id -> client and json_path -> credentials. On line 134 of client.py changed init to _init_ but getting an error that states: Traceback (most recent call last): File "d:/Users/b/hello/td/using_td_library.py", line 9, in td_client = TDClient.login() TypeError: login() missing 1 required positional argument: 'self' Any thoughts?
Hi, Alex! In this video, the process to login and get the access token is still fairly manual, but earlier videos already show an automated process for getting tokens. Why is it not used here?
24:38 isn't working for me. I'm getting C:\Users\Sam>C:\Users\Sam\OptionBot\TDAmeritrade\SP500Bot.py Traceback (most recent call last): File "C:\Users\Sam\OptionBot\TDAmeritrade\SP500Bot.py", line 2, in from td.client import TDClient ModuleNotFoundError: No module named 'td.client'
Thank you so much for this! I have a couple of questions: 1) I tried to use my paper trading account number but it didn't work for 'get positions and orders' and 'get transactions' part. Is there a way to connect the paper trading account? It'd be great to test out strategies. 2) When I change the TD_ACCOUNT variable from my paper account to my real account, everything runs smooth except the 'get transactions' part, I get this error message: File "C:\Python39\lib\site-packages\td\client.py", line 1239, in get_transactions return self._make_request(method='get', endpoint=endpoint, params=params) File "C:\Python39\lib\site-packages\td\client.py", line 621, in _make_request raise ForbidError(message=response.text) td.exceptions.ForbidError: { "error" : "You don't have permission to access this resource."
Does this code still work w/ the latest library? one thing i noticed is that when creating a TDClient, what you refer to as consumer_id is now client_id, and i think json_path must now be credentials_path (not sure). Also, after creating the TDClient, calling the login method results in an exception for me: "Exception has occurred: OSError [Errno 22] Invalid argument"
Very nice and Thanks for the detailed video. I keep getting the pip error you got when trying to install td-ameritrade-python-api. This is the error: "ERROR: Could not find a version that satisfies the requirement td-ameritrade-python-api (from versions: none) ERROR: No matching distribution found for td-ameritrade-python-api". I have the latest pip installed and latest wheel and setuptools. Anyone else have that issue and if so, what did you do to solve it? Thanks.
Are you installing it using Anaconda? If you are keep in mind it's not hosted on Anaconda, so you won't be able to install it from there. Instead, you need to install it from PyPi. Here is the command to install it from PyPi: *pip install td-ameritrade-python-api*
@@SigmaCoding I have anaconda installed but was using that command (pip install td-ameritrade-python-api) from the windows command prompt (not the anaconda prompt). I will try again today.
Am new to this. I am following the video...have the 3 statements...it is giving an error on the 3rd from td_config import CONSUMER_KEY, REDIRECT_URI, JSON_PATH from td_acct import ACCOUNT_NUMBER from td.client import TDClient Traceback (most recent call last): File "C:\Users\santo\PycharmProjects\pythonProject\td_get_historical.py", line 3, in from td.client import TDClient ModuleNotFoundError: No module named 'td' Appreciate any guidance.
Hi do you know why I would be seeing a permission denied in the library? PermissionError: [Errno 13] Permission denied: 'C:\\Users\\me\\.virtualenvs\\app-gRPm7x1S\\lib\\site-packages\\td'
I'm trying to create the JSON file that holds the access information but I'm not having any success. td_client.login() is returning true and td_client.authorized=true but td_client.logged_in=false after I successfully login through the link that it gives to authorize your account and paste the link back into the command prompt. I know the json file doesn't exist in a different folder than what I'm specifying because every single time I run the program it has me attempt to recreate the json file that holds the access information again. And then afterwards when I try to use td_client.get_quotes(), it throws an exception stating that I'm not authorized. Would you happen to know what I am doing wrong? EDIT: For some reason when I was running the Python script through the debugger in Visual Studio it wasn't generating the JSON file. But when I ran the script outside of Visual Studio through the command prompt it was able to generate the JSON file. The script functions normally otherwise within Visual Studio, so I have no idea why this is happening. If anyone has insight into why this would occur it would be greatly appreciated if you could share it with me.
Has anyone else ever gotten this error? ModuleNotFoundError: No module named 'td.utils.user_preferences'; 'td.utils' is not a package How have you resolved it? Thanks!
@Afshin Zarechian not really. It’s really funky for me. Sometimes it’ll work then sometimes it’ll give me some really whacky errors. Not sure why it does it.
At the 24:36 mark right before commencing the 'authorization', it was not clear when you right-clicked. Did you just simply ran the program? If so, I tried doing and got the following error below. I also previously successfully installed the "pip install td-ameritrade-python-api " command under the terminal screen. I'm using Pycharm. Error messg: File "C:/Users/ignc/PycharmProjects/TDAmeritrade/using_td_library.py", line 1 pip install td-ameritrade-python-api ^ SyntaxError: invalid syntax
Hi, in this video i can get all the way to the JSON creation after authentication but i am getting the following error IsADirectoryError: [Errno 21] Is a directory: '/Users/sebtac/Documents/AutoTrader/td-ameritrade' and it does not create the JSON nor does it allow me to do subsequent steps (returns "Validation was unsuccessful.") any idea why? i am on MAC if it makes a difference. (i tried different folders including just "" too.
ok solved!; learning for other viewers, the JSON_PATH is not just a PATH but also needs to specify the JSON file itself - this worked: JSON_PATH = "/Users/sebtac/Documents/AutoTrader/td-ameritrade/td_state.json"
Basically I just want to testify about Mr Franklin, He is an account manager with differences, I have been trading with him for much longer than i can say and he has turned my life around, when I was about to loose my house to the bank, he introduced me to a strategy and software that helped me to make over $50,000 in forex market, I can boast with earnings from Mr Franklin trading experience, I don't depend on my salary anymore and I'm living the comfortable life, contact him on Franklinhambj11@gmail.com if you need help!
Hi, while installing it through pip on my terminal it throws the following error in pycharm. '''Could not find a version that satisfies the requirement td-ameritrade-python-api (from versions: ) No matching distribution found for td-ameritrade-python-api'''
I keep getting status code 403 when following along the video at the point where you attempt to get orders & positions using the get_accounts "error" : "You don't have permission to access this resource." I have checked the td_state.json and it appears to be creating that correctly & populating it. It seems to have no issue getting quotes & using the other APIs that don't require authentication. Any suggestions?
Basically I just want to testify about Mr Franklin, He is an account manager with differences, I have been trading with him for much longer than i can say and he has turned my life around, when I was about to loose my house to the bank, he introduced me to a strategy and software that helped me to make over $50,000 in forex market, I can boast with earnings from Mr Franklin trading experience, I don't depend on my salary anymore and I'm living the comfortable life, contact him on Franklinhambj11@gmail.com if you need help!
Hey can you help me out? After installing and running, I get this error: Traceback (most recent call last): File "/Users/me/Desktop/Projects/API Project/td_ameritrade.py", line 2, in from td.client import TDClient ImportError: No module named td.client I saw the other comment of the guy with the same issue but I don't understand how he fixed it.
Did you install it to the right location? Sometimes when you run pip install it will install it in a different version of python. I've had that happen with people who have multiple versions of python installed.
Hi, Thanks for the video. However after installing with pip (pip install td-ameritrade-python-api), When trying to import TDClient ( from td.client import TDClient ), I have this error: === --------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) in 1 TD_ACCOUNT = "D-17784975" 2 ----> 3 from td.client import TDClient 4 TDClient 5 C:\ProgramData\Anaconda3\lib\site-packages\td\client.py in 18 from td.fields import VALID_CHART_VALUES 19 from td.fields import ENDPOINT_ARGUMENTS ---> 20 from td.app.auth import FlaskTDAuth 21 from td.oauth import run 22 from td.oauth import shutdown ModuleNotFoundError: No module named 'td.app' === Am I missing something? yk
@@SigmaCoding - Thanks for the info. I 'pip uninstall td-ameritrade-python-api' and 'pip --no-cache-dir install td-ameritrade-python-api' And it works. Well I thought I could get away without having to set a json file. Will work through this.
I keep getting the "invalid_grant" error response when simply trying to do the login method. The API documentation says that this is due to requesting an access code when you already have one or a refresh code when you don't have an access code. The other reasoning they give is that the auth code is not decoded properly. When I take the code from the URL and decode it and put all the same info on the web API, I get a good access token and refresh token. Can someone confirm that the auth code gets decoded before being posted to the API URL? I'm also using PyCharm and a virtual environment. Don't know if that matters, all the dependencies should have installed.
Yes, the Authorization Code that's returned to you needs to be decoded before you make a request for the access token. Have you recently installed the latest library? That one has made some changes that should resolve that access token endpoints.
@@SigmaCoding I just got it to work properly in VS Code. It looks like it was a virtual env error with PyCharm and Anaconda. Thanks for this great work, can't wait for the trading algo videos!
If anyone ever see's this, I was pointing the JSON file to a misspelled directory. The link this program generates is only valid once per runtime. Don't copy the contents from the previous run and paste for the response. Double checking the json files final location (shouldnt need to exist), then pasting the redirect from the current runtime, I was able to successfully create the JSON file. Only took me a couple hours --- **facepalm**
After installing the api successfully I get the following: using_td_library.py", line 7, in from td.client import TDClient ModuleNotFoundError: No module named 'td'
@@SigmaCoding I had a Python conflict between conda and brew installation, explicitly using conda version to resolve issue. Thanks. Now it runs, but one question. Can I skip the login and give the API key as a parameter? Somehow I get stuck at the login prompt to enter Please go to URL provided authorize your account: auth.tdameritrade.com/auth/?response_type=code&redirect_uri=https%3A%2F%2Flocalhost&client_id=xxxxxxxxxxxxxxxxxx%40AMER.OAUTHAP Paste the full URL redirect here: No matter what I paste it doesn't do anything... Last but not least it seems the API has evolved since you recorded this. I had to rename some of the login params. Please advise on best API version to use for this example. Thanks
@@kuntazulu If you're on Mac there is a bug with pasting the URL into the terminal in VS Code. For whatever reason, if it's over 1024 characters, it won't take it. There are a few ways around this. Run the script outside of VS Code or run the code multiple times until you get a redirect code that is less than 1024 characters. Regarding the code itself, yet it is changed dramatically since I made this video. If you go to the GitHub repo you'll see the latest version. If you want to install the latest version then do the following command pip install td-ameritrade-python-api==0.2.8
When I try to run this: transactions = td_client.get_transactions(account = 'all', transaction_type='BUY_ONLY', symbol='MSFT', start_date = '2020-01-01', end_date = '2020-04-01'), I get this error output: {'error': "You don't have permission to access this resource."} Does something need to be enabled in the account? Note: Everything else seems to work fine.
For the `get_transactions` endpoint, you can't use the `all` argument. That's only for the `get_accounts` endpoint. I'll probably have to add a new argument called `all` which is a boolen. That way it doesn't confuse people.
Wait a second... you start this series of videos with notes that say "At this point, we should have a pretty clear understanding of how the TD Ameritrade API works, how the library was built, and the different things the library can do" At what point this is video number one, shouldn't you put those notes on video number three or four etc?
This video literally came out a few hours ago and someone already disliked it?
This is an INCREDIBLY niche subject, that they took the time to wait for your upload to down vote it.
Some people are entitled. : /
Grateful you are providing much needed examples and clarification on the topic, man. :D
the dislike was prob from someone who can't get their redirect uri to work or json path :P
Great content as always. Just a few helpful tips for anyone watching this who downloaded the library recently through pip:
In the TDClient object, update the following variable names to the ones on the right:
consumer_id -> client_id
json_path -> credentials_path
Luckily, Sigma provided Intellicode snippets in VSCode so this was simple to figure out, buy others may be having trouble authenticating through the client.
Thanks again!
Thank you!!! Easy to miss
bossman brotherman brotherman
Thank you!!!!!!!!
Got stumped and your comment was the life line!
This is such a niche subject, this is so awesome that you took the time to go through the (piss poor) documentation and made a REALLY functional library. If i've got a problem with the library its really easy for me to go into the code and look at the section im trying to use and see how its supposed to be used because you have made such well documented code, and made it so readable.
Seriously, thank you.
OMG! Thanks for making this video! This video is so detailed for newbies like me. Very helpful! Every other video just says, "Download this and download that," and I'm like, "Download to where and how do you download it?"
This is the most under rated channel on RUclips. You should have way more views. We appreciate you. Thank you for your content!!!!! 💝
Muchas Gracias Panita!!! realmente aprecio mucho la información que nos regalas aquí, tan bien explicada!!
Great Video. Waiting for the streaming data part!
Thanks so much. Some parameters have changed since you posted, but able to figure it out. Working great so far!
I embed videos in notion so that I can take effective notes on the same page as the video. I think you should allow people to embed your videos.
So easy to understand! Thank you thank you thank you!
How do you fix the "no module named 'td' error?
Thanks for sharing! I have an app with hundreds of users and I can't afford to take the app down every 90 days. How can I automate the token renewal process?
Has anyone had any difficulties with calling the TDClient() instance? Apparently consumer_id and redirect_uri don't exist? Would love some help here, thanks!
The example files in github have changed a LOT since this video was made. I wish the videos matched the source code more. I have trouble mapping your terminology to the terminology of Tim Paine, Alex Golec, and the TD Ameritrade APIs themselves. Different terms are used to refer to the same things, like access_token, refresh_token, client_id, and so on. Could someone please provide a terminology mapping table for these different TDA API wrappers?
Hello
Incredible video. I am building my first api with an extremly knowledgeable programmer. He is concerned about security abd would prefer if we made the API read only. For my purpose that is ok because I still want to trade in the TD ap or web or tos. So my question is there a read only key for TD? Or is there a view only username? Or is the streaming api read only ?
I like your videos, I want a confirmation is TD Ameritrade not support the OrderPlace request in WebSocket(faster way to send a request)?
Fantastic video good sir.
little confused on the callback url I am not tech savy and just wanted to follow along with this project
Hello. Thank you for the video. A single question. I have change consumer_id -> client and json_path -> credentials. On line 134 of client.py changed init to _init_ but getting an error that states:
Traceback (most recent call last):
File "d:/Users/b/hello/td/using_td_library.py", line 9, in
td_client = TDClient.login()
TypeError: login() missing 1 required positional argument: 'self'
Any thoughts?
Thank you for the video. They seem to have changed the login process. It keeps directing me to a login help screen that I can’t get past.
Excellent video and a new sub
The blue & red is a little hard to read on my screen. Where can I find the source code to your stock app?
Great, once I decide to follow up this tutorial the Ameritrade API doesn't allow new registers due to charles schwab integration.
Hi, Thanks a lot for your videos!! Much appreciate it!
Glad you like them!
Hi, Alex! In this video, the process to login and get the access token is still fairly manual, but earlier videos already show an automated process for getting tokens. Why is it not used here?
Excellent, thanks!
You're welcome!
Man you the best!
24:38 isn't working for me. I'm getting
C:\Users\Sam>C:\Users\Sam\OptionBot\TDAmeritrade\SP500Bot.py
Traceback (most recent call last):
File "C:\Users\Sam\OptionBot\TDAmeritrade\SP500Bot.py", line 2, in
from td.client import TDClient
ModuleNotFoundError: No module named 'td.client'
Got a question: from td.client import TDClient
Where is the td.client? Because my VSC says: import could not be resolved.
I'm having an error code "no module named config". What should I do?
How do you get a quote on options on futures (bid/ask)? can't get that through the quote method...
So with Futures Options, I was never able to get that one to work. It doesn't appear that it is supported.
Thank you so much for this! I have a couple of questions:
1) I tried to use my paper trading account number but it didn't work for 'get positions and orders' and 'get transactions' part. Is there a way to connect the paper trading account? It'd be great to test out strategies.
2) When I change the TD_ACCOUNT variable from my paper account to my real account, everything runs smooth except the 'get transactions' part, I get this error message:
File "C:\Python39\lib\site-packages\td\client.py", line 1239, in get_transactions
return self._make_request(method='get', endpoint=endpoint, params=params)
File "C:\Python39\lib\site-packages\td\client.py", line 621, in _make_request
raise ForbidError(message=response.text)
td.exceptions.ForbidError: {
"error" : "You don't have permission to access this resource."
Does this code still work w/ the latest library? one thing i noticed is that when creating a TDClient, what you refer to as consumer_id is now client_id, and i think json_path must now be credentials_path (not sure). Also, after creating the TDClient, calling the login method results in an exception for me: "Exception has occurred: OSError
[Errno 22] Invalid argument"
Thanks for pointing that out, Mike. When I changed consumer_id to client_id, and json_path to credentials_path, it worked.
Can the thinkorswim account use on develop td-american?
When I run it I get an exception thrown at td_client.login() is
"error" : "invalid_grant"
any idea why that is?
Is this the first time you've logged in using the library? It'll help me isolate the possible issue.
Very nice and Thanks for the detailed video. I keep getting the pip error you got when trying to install td-ameritrade-python-api. This is the error: "ERROR: Could not find a version that satisfies the requirement td-ameritrade-python-api (from versions: none) ERROR: No matching distribution found for td-ameritrade-python-api". I have the latest pip installed and latest wheel and setuptools. Anyone else have that issue and if so, what did you do to solve it? Thanks.
Are you installing it using Anaconda? If you are keep in mind it's not hosted on Anaconda, so you won't be able to install it from there. Instead, you need to install it from PyPi.
Here is the command to install it from PyPi:
*pip install td-ameritrade-python-api*
@@SigmaCoding I have anaconda installed but was using that command (pip install td-ameritrade-python-api) from the windows command prompt (not the anaconda prompt). I will try again today.
Hi, thanks for the helpful video. is there a way to retrieve the token details without requiring the user to copy and paste the full redirect link ?
Am new to this. I am following the video...have the 3 statements...it is giving an error on the 3rd
from td_config import CONSUMER_KEY, REDIRECT_URI, JSON_PATH
from td_acct import ACCOUNT_NUMBER
from td.client import TDClient
Traceback (most recent call last):
File "C:\Users\santo\PycharmProjects\pythonProject\td_get_historical.py", line 3, in
from td.client import TDClient
ModuleNotFoundError: No module named 'td'
Appreciate any guidance.
Hi do you know why I would be seeing a permission denied in the library?
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\me\\.virtualenvs\\app-gRPm7x1S\\lib\\site-packages\\td'
I'm trying to create the JSON file that holds the access information but I'm not having any success. td_client.login() is returning true and td_client.authorized=true but td_client.logged_in=false after I successfully login through the link that it gives to authorize your account and paste the link back into the command prompt. I know the json file doesn't exist in a different folder than what I'm specifying because every single time I run the program it has me attempt to recreate the json file that holds the access information again. And then afterwards when I try to use td_client.get_quotes(), it throws an exception stating that I'm not authorized. Would you happen to know what I am doing wrong?
EDIT: For some reason when I was running the Python script through the debugger in Visual Studio it wasn't generating the JSON file. But when I ran the script outside of Visual Studio through the command prompt it was able to generate the JSON file. The script functions normally otherwise within Visual Studio, so I have no idea why this is happening. If anyone has insight into why this would occur it would be greatly appreciated if you could share it with me.
Has anyone else ever gotten this error?
ModuleNotFoundError: No module named 'td.utils.user_preferences'; 'td.utils' is not a package
How have you resolved it? Thanks!
@Afshin Zarechian not really. It’s really funky for me. Sometimes it’ll work then sometimes it’ll give me some really whacky errors. Not sure why it does it.
is "td.client" not working for anybody else? im 3 lines in and stuff isnt working.
At the 24:36 mark right before commencing the 'authorization', it was not clear when you right-clicked. Did you just simply ran the program? If so, I tried doing and got the following error below. I also previously successfully installed the "pip install td-ameritrade-python-api
" command under the terminal screen. I'm using Pycharm.
Error messg:
File "C:/Users/ignc/PycharmProjects/TDAmeritrade/using_td_library.py", line 1
pip install td-ameritrade-python-api
^
SyntaxError: invalid syntax
So, I don't use PyCharm but when you call pip install, do you need to lead it with "python pip install"? In Windows, I sometimes must do that.
@@SigmaCoding Thank you. Will try that as well.
Hi, in this video i can get all the way to the JSON creation after authentication but i am getting the following error
IsADirectoryError: [Errno 21] Is a directory: '/Users/sebtac/Documents/AutoTrader/td-ameritrade'
and it does not create the JSON nor does it allow me to do subsequent steps (returns "Validation was unsuccessful.")
any idea why? i am on MAC if it makes a difference. (i tried different folders including just "" too.
ok solved!; learning for other viewers, the JSON_PATH is not just a PATH but also needs to specify the JSON file itself - this worked: JSON_PATH = "/Users/sebtac/Documents/AutoTrader/td-ameritrade/td_state.json"
Are there any pros/cons to using environment variables instead of a config file?
Basically I just want to testify about Mr Franklin, He is an account manager with differences, I have been trading with him for much longer than i can say and he has turned my life around, when I was about to loose my house to the bank, he introduced me to a strategy and software that helped me to make over $50,000 in forex market, I can boast with earnings from Mr Franklin trading experience, I don't depend on my salary anymore and I'm living the comfortable life, contact him on Franklinhambj11@gmail.com if you need help!
Hey, how does your VS code autocomplete all the various functions for your API?
Ah never mind, installing pylance over microsoft's own language server helped out. Thanks anyways :)
Hi,
I am following your code but when I run the code, it does not create the json file. Any ways to fix this?
Thanks
Did you specify a file path in your TDClient object?
Hi, while installing it through pip on my terminal it throws the following error in pycharm.
'''Could not find a version that satisfies the requirement td-ameritrade-python-api (from versions: )
No matching distribution found for td-ameritrade-python-api'''
Well that's odd, what was the full command you wrote?
You likely do not have the correct python version...>3.7
hi I know this is an older video but just started coding was wondering if you could help me out
I keep getting status code 403 when following along the video at the point where you attempt to get orders & positions using the get_accounts
"error" : "You don't have permission to access this resource."
I have checked the td_state.json and it appears to be creating that correctly & populating it. It seems to have no issue getting quotes & using the other APIs that don't require authentication.
Any suggestions?
Is the account number you're passing through match what is on your TD profile?
@@SigmaCoding It was an issue with my old Scottrade Account # vs TDAmeritrade Account #
TD seems to be blocking the url used for activation. Is this a new issue?
Basically I just want to testify about Mr Franklin, He is an account manager with differences, I have been trading with him for much longer than i can say and he has turned my life around, when I was about to loose my house to the bank, he introduced me to a strategy and software that helped me to make over $50,000 in forex market, I can boast with earnings from Mr Franklin trading experience, I don't depend on my salary anymore and I'm living the comfortable life, contact him on Franklinhambj11@gmail.com if you need help!
Hey can you help me out?
After installing and running, I get this error:
Traceback (most recent call last):
File "/Users/me/Desktop/Projects/API Project/td_ameritrade.py", line 2, in
from td.client import TDClient
ImportError: No module named td.client
I saw the other comment of the guy with the same issue but I don't understand how he fixed it.
Did you install it to the right location? Sometimes when you run pip install it will install it in a different version of python. I've had that happen with people who have multiple versions of python installed.
@@SigmaCoding Can you be more clear in your answer ? What 's the right location ? What ' s the right version of python here ?
Hi, Thanks for the video. However after installing with pip (pip install td-ameritrade-python-api),
When trying to import TDClient ( from td.client import TDClient
), I have this error:
===
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
in
1 TD_ACCOUNT = "D-17784975"
2
----> 3 from td.client import TDClient
4 TDClient
5
C:\ProgramData\Anaconda3\lib\site-packages\td\client.py in
18 from td.fields import VALID_CHART_VALUES
19 from td.fields import ENDPOINT_ARGUMENTS
---> 20 from td.app.auth import FlaskTDAuth
21 from td.oauth import run
22 from td.oauth import shutdown
ModuleNotFoundError: No module named 'td.app'
===
Am I missing something?
yk
Update it to version 0.2.8 this was a bug in my latest update.
@@SigmaCoding -
Thanks for the info.
I 'pip uninstall td-ameritrade-python-api'
and 'pip --no-cache-dir install td-ameritrade-python-api'
And it works. Well I thought I could get away without having to set a json file.
Will work through this.
I keep getting the "invalid_grant" error response when simply trying to do the login method. The API documentation says that this is due to requesting an access code when you already have one or a refresh code when you don't have an access code. The other reasoning they give is that the auth code is not decoded properly. When I take the code from the URL and decode it and put all the same info on the web API, I get a good access token and refresh token. Can someone confirm that the auth code gets decoded before being posted to the API URL? I'm also using PyCharm and a virtual environment. Don't know if that matters, all the dependencies should have installed.
Yes, the Authorization Code that's returned to you needs to be decoded before you make a request for the access token. Have you recently installed the latest library? That one has made some changes that should resolve that access token endpoints.
@@SigmaCoding I just got it to work properly in VS Code. It looks like it was a virtual env error with PyCharm and Anaconda. Thanks for this great work, can't wait for the trading algo videos!
If anyone ever see's this, I was pointing the JSON file to a misspelled directory. The link this program generates is only valid once per runtime. Don't copy the contents from the previous run and paste for the response. Double checking the json files final location (shouldnt need to exist), then pasting the redirect from the current runtime, I was able to successfully create the JSON file. Only took me a couple hours --- **facepalm**
this was for the "invalid_grant" response
how can i speak whit you please?
After installing the api successfully I get the following:
using_td_library.py", line 7, in
from td.client import TDClient
ModuleNotFoundError: No module named 'td'
Did you install it to the right environment?
@@SigmaCoding I had a Python conflict between conda and brew installation, explicitly using conda version to resolve issue. Thanks. Now it runs, but one question. Can I skip the login and give the API key as a parameter? Somehow I get stuck at the login prompt to enter
Please go to URL provided authorize your account: auth.tdameritrade.com/auth/?response_type=code&redirect_uri=https%3A%2F%2Flocalhost&client_id=xxxxxxxxxxxxxxxxxx%40AMER.OAUTHAP
Paste the full URL redirect here:
No matter what I paste it doesn't do anything...
Last but not least it seems the API has evolved since you recorded this. I had to rename some of the login params. Please advise on best API version to use for this example.
Thanks
@@kuntazulu If you're on Mac there is a bug with pasting the URL into the terminal in VS Code. For whatever reason, if it's over 1024 characters, it won't take it. There are a few ways around this. Run the script outside of VS Code or run the code multiple times until you get a redirect code that is less than 1024 characters.
Regarding the code itself, yet it is changed dramatically since I made this video. If you go to the GitHub repo you'll see the latest version. If you want to install the latest version then do the following command
pip install td-ameritrade-python-api==0.2.8
@@SigmaCoding I love you man! Ping me when you in DC area post covid. I owe you lunch. Thanks a bunch.
@@kuntazulu @Sigma Coding, where is td.client coming from ?
We got a NEGATIVE NANCY here with the "dislike". Don't be that guy!
When I try to run this:
transactions = td_client.get_transactions(account = 'all', transaction_type='BUY_ONLY', symbol='MSFT', start_date = '2020-01-01', end_date = '2020-04-01'),
I get this error output:
{'error': "You don't have permission to access this resource."}
Does something need to be enabled in the account?
Note: Everything else seems to work fine.
Figured it out. Need to put in an account number for the account argument. 'all' doesn't seem to work.
@@skimdt1 I think 'ALL' is also trying to access your forex account. I was getting the same thing.
For the `get_transactions` endpoint, you can't use the `all` argument. That's only for the `get_accounts` endpoint. I'll probably have to add a new argument called `all` which is a boolen. That way it doesn't confuse people.
Wait a second... you start this series of videos with notes that say "At this point, we should have a pretty clear understanding of how the TD Ameritrade API works, how the library was built, and the different things the library can do"
At what point this is video number one, shouldn't you put those notes on video number three or four etc?