tdameritrade | Python interface to TD Ameritrade | Cryptocurrency library
kandi X-RAY | tdameritrade Summary
kandi X-RAY | tdameritrade Summary
Python interface to TD Ameritrade Api.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Authenticate with a client
- Retrieve the options for a given symbol
- This endpoint allows you to deal with multiple options
- Raise appropriate error response
- Make a HTTP request
- Builds buy limit order order
- Creates an OrderLeg
- Builds a custom option spread order
- Builds a buy option order
- Get all orders for a given account
- Build a buy market order
- Create an Equity OrderLeg
- Returns all saved orders
- Returns all movers for a given index
- Get a list of watchlists
- Get the preferences for a given account
- Replaces a saved order
- Replaces a watchlist
- Updates a watchlist
- Retrieve a pandas DataFrame of all transactions in the DataFrame
- List all transactions for a given account
- Get an access token
- Replace an order
- Update preferences
- Delete a watchlist
- Deletes a saved order
tdameritrade Key Features
tdameritrade Examples and Code Snippets
Community Discussions
Trending Discussions on tdameritrade
QUESTION
I am trying to return the most recent "low" and "high" values into variables and am not sure how to retrieve them.
The code I am running is:
...ANSWER
Answered 2021-May-11 at 04:44Let's say
QUESTION
I am not getting the correct response from the server running the following
...ANSWER
Answered 2021-Mar-18 at 01:14For reasons unknown... changing the --header switch / flag to -H solved the problem. As shown in the following. Spoke with a friend and apparently the shortened form may take different parameters.
QUESTION
Is there a good way to iterate through a deserialized JSON object from last to first? i.e., the following code I can iterate and record 'n' values from first to last until it meets my count condition for further processing:
...ANSWER
Answered 2021-Feb-25 at 03:21You can use the Reverse()
method of the JArray class. Just cast your history["candles"]
JToken
into a JArray
, and call reverse.
QUESTION
Using TDAmeritrade API.
I made the request like this:
...ANSWER
Answered 2021-Feb-17 at 07:47The problem is your data is not in record_path="symbol"
, it's nested inside callExpDateMap
You have to create a new array and iterate through callExpDateMap
and its child json to get the array
QUESTION
I'm implementing an API wrapper for an OAuth API (in particular, TD Ameritrade) and I've encountered an interesting piece of functionality. Unlike most OAuth implementations I've seen, in which refresh token is valid for some time period and then the user has to re-authenticate, this API supports refreshing the refresh token itself.
In particular, if you send a request with the following format to the authentication endpoint, you will be rewarded with a brand new refresh token that's good for 90 days:
...ANSWER
Answered 2021-Feb-11 at 16:21The access_type: offline
parameter is not a standard in OAuth, but it's used e.g. by Google in their token endpoint request - you must pass it to get a refresh token.
On the other refreshing refresh tokens is part of the OAuth standard. The RFC 6749 states that in a response to the token endpoint:
The authorization server MAY issue a new refresh token, in which case the client MUST discard the old refresh token and replace it with the new refresh token. The authorization server MAY revoke the old refresh token after issuing a new refresh token to the client. If a new refresh token is issued, the refresh token scope MUST be identical to that of the refresh token included by the client in the request.
So it is part of the standard to refresh refresh tokens, but it should be done differently than in their API.
QUESTION
So I am using TDAmeritrade API to receive stock data with a C# Winforms program on Visual Studio. It takes the user input stock symbol and searches for the info. I am using HttpClient and Newtonsoft.Json and have been able to successfully perform the GET request and receive a JSON string back, but I do not know how to get all of the information I need out of it.
Here is the JSON: https://drive.google.com/file/d/1TpAUwjyqrHArEXGXMof_K1eQe0hFoaw5/view?usp=sharing
Above is the JSON string sent back to me then formatted. My goal is to record information for each price in "callExpDateMap.2021-02-19:11" and "callExpDateMap.2021-03-19:39". The problem is that for each different stock, the dates that show up in "callExpDateMap" are going to be different.
...ANSWER
Answered 2021-Feb-08 at 20:57This is official documentation of Newtonsoft method you are trying to use.
https://www.newtonsoft.com/json/help/html/Overload_Newtonsoft_Json_JsonConvert_DeserializeObject.htm
If an API's method returns different json propeties and you cannot trust it's property names all the times, then you can try using a deserialize method that returns .Net object, for example: JsonConvert.DeserializeObject Method (String) https://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_JsonConvert_DeserializeObject.htm
That method's signature is this: public static Object DeserializeObject(string value)
Parameter is: value of type json string.
Return Value is: Object of type object.
If you do not want an Object, then you can of course use a .Net type you have. Such as this method: JsonConvert.DeserializeObject Method (String)
Any property that you have in both (the .net type and json object) will get populated. If .net type has properties that do not exist in json object, then those will be ignored. If json object has properties that do not exist in.net, then those will be ignored too.
Here's an example of a .Net type
QUESTION
Is there a good way to dynamically pass a string variable in place of a deserialized object definition? How I mean, is that the code snippet below is proper syntax to deserialize the JSON response object in order to store the returned data types in a database for further processing.
...ANSWER
Answered 2021-Feb-07 at 21:27You can deserialize to JObject
which has indexer to perform such dynamic querying:
QUESTION
Using documentation from https://pypi.org/project/td-ameritrade-python-api/
I'm trying to get started with the TD Ameritrade API in Python...
The problem I am having is with authentication of my account which is done via this Url: (note: client_id has been changed b/c it is private)
So everything works:
- I get the login screen
- After successful login, I get the permissions page
EXCEPT...
When everything is completed I get this error from FireFox (or Chrome, whatever)
Unable to connect
Firefox can’t establish a connection to the server at 127.0.0.1.
Given the above issue, I search Google for info and did the following:
- Cleared Cache
- Made sure correct IIS settings were configured
It does not work at this point.
I have no idea what is going on. Any help would be greatly appreciated.
...ANSWER
Answered 2020-Dec-14 at 06:08This is probably one of the few times when getting an error message like you did is actually part of the process to authenticate your account. At the very bottom of the PyPi page for that library he explains that you're supposed to copy and paste the resulting url of the error page you're currently on into your terminal. It was confusing for me aswell and it took me awhile to really understand what's going on so I will explain it as best as I can.
Alex Reed is the guy who made the library TD Ameritrade API and he has an awesome YouTube channel called Sigma Coding. One of his video series guides you through the whole process of directly connecting to the TD Ameritrade API without the use of his API library, and another series about building the library itself.
In this video How to Use the TD Ameritrade API | Part 2 he is demonstrating how to access the API. The link should have a time stamp of 16:36 if not skip ahead to that section and you will see a similar error to what you are experiencing except he is using Chrome, not Firefox so the error is the same but worded differently.
Here's a picture to better explain the rest:
What he does next is copy and paste the current url of the page with the error, which contains the code needed for the next step. The url in the picture starts with https://localhost/test?code=siVrfqPLdQ...
and you can see that the url has code=
following a very long access code that TD Ameritrade needs to generate your access token.
Your url should have a similar structure, don't worry if it doesn't have /test
after localhost, he made a specific folder for the video series. Just copy and paste the whole thing in your terminal where you should have a line that says:
Paste the full redirect url here:
QUESTION
I'm trying to request hour information from the TD Ameritrade API. Is there any way I could get the hours for the New York Stock Exchange?
Here is the link to the API: https://developer.tdameritrade.com/
...ANSWER
Answered 2020-Dec-23 at 06:37TD Ameritrade's API provides an endpoint for market hours however you can't specify which exchange to check, only which market (BOND, EQUITY, ETF etc..).
For some reason, it allows you to specify which date but it only accepts the current date. Providing an access token doesn't do anything so I won't be including a header with the token in my example.
QUESTION
I'm trying to use AWS to automate some procedures, and need to authenticate myself with the API I'm using. The issue is, its way too slow. I'm using a selenium headless chrome browser to connect to the page, fill in the information I need and submit the form (according to other sources I found the TD Ameritrade API only accepts the browser route so there is no way to do it just with requests, if you know otherwise that would be great too). Finding the element on the page takes about 20 seconds, sending the keys maybe a full minute, and trying to submit the form it times out after 5 minutes. Is this an issue with my implementation of selenium, or is it something to do with AWS or the API I'm connecting to? My code is as shown below and the error:
...ANSWER
Answered 2020-Nov-18 at 22:38A bit of more details about your usecase would have helped us to analyze the reason behind the program executing too slow. Here are a few considerations:
- A common cause for Chrome to crash during startup is running Chrome as
root
user (administrator
) on Linux. While it is possible to work around this issue by passing --no-sandbox flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged. You need to configure your environment to run Chrome as a regular user instead. So you may need to drop the--no-sandbox
option.
Here is the link to the Sandbox story.
- While using
--headless
option you won't be able to use--window-size=1280x1696
due to certain constraints.
You can find a couple of relevant detailed discussion in:
- The argument
--disable-gpu
was to enable google-chrome-headless on windows platform. It was needed as SwiftShader fails an assert on Windows in headless mode earlier. This issue was resolved through Headless: make --disable-gpu flag unnecessary
You can find a relevant detailed discussion in ERROR:gpu_process_transport_factory.cc(1007)-Lost UI shared context : while initializing Chrome browser through ChromeDriver in Headless mode
- Further you haven't mentioned any specific requirement of using
--hide-scrollbars
,--enable-logging
,--log-level=0
,--v=99
,--single-process
,--data-path=tmp/data-path
,--homedir=tmp
,--disk-cache-dir=tmp/cache-dir
,--no-proxy-server
,--proxy-server='direct://'
and--proxy-bypass-list=*
arguments which you opt to drop for the time being and add them back as per your Test Specification.
You can find a couple of relevant detailed discussions in:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install tdameritrade
You can use tdameritrade like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page