Just an FYI to everyone, I'll be releasing more content on the TD Ameritrade API in the next week. On Friday, they seemed to release a significant update to their API, and it now gives us the ability to stream different forms of data using WebSockets. I was able to get a basic request going, so it does work, but it will require users to use different libraries than the ones covered in this video.
@jayhuang37545 жыл бұрын
hello, I am curious if these APIs can interface with Thinkoswim? like getting the indicators? Thank you.
@Vishnuxgod3 жыл бұрын
Hello.. will the price history dataset be stored in csv format after running all the codes ?
@saniok97912 жыл бұрын
Hi Alex, can you please do a video on how to connect to tradestation thru API on python? I have an API key and other information but have difficulty to connect. THank you so much
@abdullahatallah97594 жыл бұрын
I have to say, i've seen trading bot videos and API stuff on ALOT of channels for several exchanges and markets, but this one is just a freakin gold mine because i actually understand what's going on ! thank you.
@drteeth115 жыл бұрын
1K! Congrats! Keep up the awesome videos!
@SigmaCoding5 жыл бұрын
We did it!
@TheBourse2 жыл бұрын
I would like to thank you for your channel on KZbin. It is very much appreciated
@LesDunaway5 жыл бұрын
Excellent job of leading through api use!
@retrofutur1st3 жыл бұрын
beautiful video, thank you! I got it to work after watching many other ones and failing, yours was pretty straight forward and easy to follow.
@lancefree75444 жыл бұрын
Great presentation! Just register your channel to support you
@SigmaCoding4 жыл бұрын
Thanks and welcome!
@cocoon7574 жыл бұрын
What should I put in callback URL when applying for the app?
@monkyspnk7773 жыл бұрын
You seem to give a good balance between showing the detail of the steps and walking through it with some personality keep making videos this is good
@momchi23 жыл бұрын
Awesome initiative with this API library, thumbs up!
@h.h.12665 жыл бұрын
Just discovered this channel - wow! Thanks a lot for putting the effort in to make these videos, very helpful. I was curious to explore these topics as a hobby but now I can just watch your channel and cut my learning curve short! 👍
@SigmaCoding5 жыл бұрын
Glad you're finding them helpful! :)
@jonathanhooker89734 жыл бұрын
GREAT video! Excited to start using these applications.
@SigmaCoding4 жыл бұрын
Glad it was helpful!
@connorpage61473 жыл бұрын
Hey Alex have you found a way to format symbols for options on futures? I can't seem to figure out the naming conventions for the symbol in getting the quotes via the quotes endpoint or in the options chain endpoint. Any help would be appreciated.
@Stillshot102003 жыл бұрын
Great video. I'm using Golang and was able to get build this API in Go. Well done explaining it because I've never used python.
@muji9913 жыл бұрын
I usually don't like and subscribe, but man this was beautiful and so helpful, I had to like & sub. Thank you!!!!
@SigmaCoding3 жыл бұрын
Thanks for the sub!
@aceDrumPiano2 жыл бұрын
Just started learning python 2 days ago but able to follow your video and extract the live quote. This is so exciting :-) My goal is to use google sheet and get the stock last done price/option price via API (Don't want to run Parallels, windows and MS Excel just to get the data via DLL). Would appreciate if you could create a tutorial on how to achieve it. If not, is fine as that's the reason I wanted to learn python, TDAmeritrade API (not sure it is still available after integrating with Charles Schwab app), json, google sheet. A lot of things to learn :-). Thank you so much for creating all these videos.
@viveksomani3765 жыл бұрын
I kept getting this as output : {'candles': [ ], 'symbol': 'GOOG', 'empty': True} . Then I removed endDate from params and was able to get the output correctly. Any idea whey it didn't work with dates in the params ?
@SigmaCoding5 жыл бұрын
Do you happen to have a snipped of the code? My first guess is maybe you didn't enter the data correctly. The only reason I say that is I kept inputting it incorrectly and it was screwing everything up.
@FabledNarrative5 жыл бұрын
I had the same issue and removed "endDate" and it started working. Don't know why, but still, thank you for posting issue with solution.
@jamesjetland69805 жыл бұрын
I had the same issues as well. Removed endDate as recommended and it fixed the issue.
@jasoncheck11085 жыл бұрын
My guess is it's overconstrained. If you look at the api 'endDate' description it says "... If startDate and endDate are provided, period should not be provided..." Same for startDate
@nathanb72694 жыл бұрын
I had this same problem, then I realized I needed the epoch time in milliseconds. That fixed my problem perfectly. Hope that helps!
@tradertube2 жыл бұрын
Great video! Just discovered this channel and finding all this good stuff. Very helpful indeed.
@sledziu325 жыл бұрын
greate video! waiting for more
@GQElvie3 жыл бұрын
Hello, thanks for posting. at about 9:20, you import requests. what is requests? was that something you earlier created? thanks John
@dougrobinson20245 жыл бұрын
Outstanding!! Thank you!! :)
@Birlank3 жыл бұрын
Quick question, so at 18:04 when you execute to get the returned data for google with everything typed out exact, I am getting no data returned. {'candles': [], 'symbol': 'GOOG', 'empty': True} Is this expected? I am passing my client_id from a config file. Any help would be greatly appreciated.
@gavinngo24885 жыл бұрын
Hey Alex, Question in regards to the limits of end date and start date. For example, if I were using the criteria below.. 'periodType': 'day', 'frequencyType': 'minute', 'frequency': '1', Does TDAmeritrade limit you to how far back you can pull? I am having issues pulling data for daily one minute data for the entire month of October. It seems like the furthest historical I can pull is sometime in November. Thanks!
@SigmaCoding5 жыл бұрын
Yeah, I had someone reach out about this, and for the historical data, at least at the minute level, I can't say the same for other durations, it's only the last 30 or 60 days if I remember correctly. I'd have to look at the comments again. Also, keep in mind the historical data is delayed 15 minutes. That means if you're pulling this real-time during market hours, you don't get the last 15 minutes. I found this out when I was working with one of my clients, he was doing real-time trading with a trading robot I built for him, and I was building in some redundancies to "pick up where he left off" if he lost internet connection or something. I realized that we couldn't do it with the TD API, so we supplemented the Alpha Vantage API instead.
@gavinngo24885 жыл бұрын
@@SigmaCoding Thank you so much for this information. I would of spent so much time continuing on playing with TDAmeritrade's API just to find out that intra day data is delayed. Will look to try Alpha Vantage API and see how it goes. I also did some Googling and find that worldtradingdata is an option also. Do you have any experience with them?
@Lakesider4 жыл бұрын
Thanks, really appreciate your effort. TD is always a good tool for quant trading, especially after it made nearly all transaction fees ZERO.
@SigmaCoding4 жыл бұрын
Couldn't agree more!
@hppeng5 жыл бұрын
Thank you very much. Very useful.
@bluecrystalpowder6514 жыл бұрын
Liked, subscribed, and commenting to help you out, great video!
@SigmaCoding4 жыл бұрын
Much appreciated!
@SoylentGreenEatIt4 жыл бұрын
Hey Sigma, would I be able to "symbol map" from thinkorswim to an external broker like Lightspeed? Basically I want to input a ticker symbol into TOS and have it auto link to Lightspeed.
@SigmaCoding4 жыл бұрын
It depends on Lightspeed. I've never used them, so I'm not sure what they offer in terms of data, but if they give you access to something called a CUSIP (Committee on Uniform Securities Identification Procedures) you'll be fine. The CSUIP as defined by the sec: "Identifies most financial instruments, including stocks of all registered U.S. and Canadian companies, commercial paper, and U.S. government and municipal bonds." You can use this to map a security from one platform to another. Here is a data source, offered by the SEC, that shows all the CUSIP numbers by quarter for all the "Section 13(f) securities". It's not a list of every instrument out there, but it's a great starting point. The only downside is it's updated once a quarter, and it's in a PDF file. Link: www.sec.gov/divisions/investment/13flists.htm
@HJoubert15 жыл бұрын
Great video, thank you. Quick question, is it possible to request historical prices for currency pairs, say EUR/USD? I have no problem with most symbols like GOOG, AAPL, SPX, PINS, but the symbols with special characters like EUR/USD, /ZT etc. seems to mess with the endpoint url. Is there any way around this, or maybe alias symbols they use for the url?
@SigmaCoding5 жыл бұрын
So I've done some research and I can't really find a solution, they don't provide any examples on how to request currency pairs and no one online has any examples. I'll keep looking, but it's not looking good at this point.
@elevatedideas5 жыл бұрын
@@SigmaCoding Your video is great but I'm also having an issue trying to pull Futures price history. Been working on for over a month. I'm looking for /ES mini SP futures data and have been unable to find a solution. Also I am unable to get real time price history. Is that because I'm not logged in via token OAUTH?
@SigmaCoding5 жыл бұрын
If you'd like you can send me your code and I can see if I can get it to work. Send it over facebook or discord: facebook.com/codingsigma Discord: areed1192 #2801
@HJoubert15 жыл бұрын
@@SigmaCoding Thank you for spending time looking into this. I also could not find a solution researching, but I will contact Ameritrade directly to ask if they may have a solution for this then.
@SigmaCoding5 жыл бұрын
@@HJoubert1 Just an FYI, they released an update to their API on Friday so we now have access to streaming data. I saw a section for currencies so there might be a good chance we can get the data.
@bluehorseshoe4444 жыл бұрын
I'm very new to coding and don't understand how to setup a callback URL... would you mind explaining?
@princesa_fugitiva4 жыл бұрын
Hi, just watched this. So helpful !!! Planning to watch the other TD vids and the Random Forest predictor vid. I'm wondering which API you think is more useful, TD or Interactive Brokers? Know a place to get historical data by second? Thanks again!
@stevesmith97464 жыл бұрын
Liked, Subbed, Commented. Thanks, this was helpful.
@chaddsmith33543 жыл бұрын
Thank you for the video! It’s really helpful!
@kamikaze57674 жыл бұрын
How do you make that initial config file that you mentioned which holds your client info
@SigmaCoding4 жыл бұрын
I have a sample of it on my GitHub repo, here is the link: github.com/areed1192/sigma_coding_youtube/tree/master/python/python-finance/td-ameritrade
@billmanj19793 жыл бұрын
Alex, great tutorial. I was able to get it to function and I know squat about programming outside some assembly/C 20 yrs ago in college. One question is, the JSON response has 'xyz' instead of "xyz" as shown on the price history end point response summary. Thus when I'm trying to convert that JSON string to CSV, I get errors. Would you elaborate on how one might resolve this?
@SigmaCoding3 жыл бұрын
Did you verify it was a string? It sounds like it might have been parsed to a dictionary already. If it isn't then all you do is just take your response and call the `.json()` method. Hopefully that makes sense.
@billmanj19793 жыл бұрын
@@SigmaCoding Alex, thank you for the reply, I found the reply in my spam folder - thanks google products - today. I figured out how to use pandas to write a csv and name it after the ticker. I cannot say what I did wrong but was able get my ultimate goal of writing it to csv.
@ivan203020304 жыл бұрын
Hi, what's the best way to make adjustment on start datetime to avoid issues with holidays and weekends?
@SigmaCoding4 жыл бұрын
you could just parse it and then use timedelta to adjust it.
@craigsnyder31365 жыл бұрын
Do you have your code on github? Quick search for sigmacoding didn't look like it was yours
@craigsnyder31365 жыл бұрын
Never mind. Found it. For anyone else looking: github.com/areed1192/sigma_coding_youtube
@SigmaCoding5 жыл бұрын
That would be it.
@SMai-to3ux4 жыл бұрын
Will TD API still be usable after the Charles Schwab acquisition?
@ZhiminHe4 жыл бұрын
Another question, it seems there is no way to get the trade price and trade date of a position i am holding via api. Is that correct? thank you !
@rickoeriksson99054 жыл бұрын
Would you use HTTP or HTTPS for the callback URL ? Using HTTP TD gives you a warning message. Is there a difference?
@digitaljetset5 жыл бұрын
Very instructive video. I have a question, can the API be accessed by using any type of account? even the ones with no commissions?
@SigmaCoding5 жыл бұрын
TD Ameritrade is very broad on this topic, if you read the official website all the say is, "Access your TD Ameritrade account through our powerful Application Programming Interfaces (APIs) to create your own experiences." I have no idea if this includes ones that would offer free commission, but my gut says yes. The only type of account that I know people can't use is a Paper Trading account.
@hamad.learns4 жыл бұрын
can you get historical fundamental data from TD Ameritrade?
@liveandlearn17025 жыл бұрын
First of all, LOVING your channel and series! Amazing work and thank you kindly for sharing! I am curious if there is a way (just to make it more interesting) to access custom studies and/or indicators via the API? Say for example, the RSI or ATR or perhaps even a custom study? Or even a moving average would be awesome!
@SigmaCoding5 жыл бұрын
Unfortunately, the TD Ameritrade API doesn't offer indicators in their API. The best option we have at this point is writing the functions ourselves.
@AlexWinkler4 жыл бұрын
Awesome video, I can see you really like trading and coding lol
@SigmaCoding4 жыл бұрын
It's where all the fun is!
@ki5ngau4 жыл бұрын
You rocked, bro.
@SEnricoPIndiogine5 жыл бұрын
I noticed that the quotes return JSON string has 'delayed': True Is that the case also for pricehistory and quote? Is it possible to have not delayed data? What is the delay? Thanks.
@andrewjbidlen13255 жыл бұрын
You get delayed data if you make an unauthenticated request. If you make an authenticated request, you should get real-time data.
@jflow56014 жыл бұрын
Is it just me or are quotes being provided by the Get Quotes API delayed by up to 10 minutes or more? I am making the request once/minute for a single stock and am receiving responses, but the data appears to be stale by up to 10 minutes or more. Is there a limitation or upper limit that I am violating?
@SigmaCoding4 жыл бұрын
To get real time quotes you need to provide an access token in the headers and I usually keep my client ID in the URL parameters.
@jflow56014 жыл бұрын
@@SigmaCoding I am making unauthenticated requests using the apikey (Consumer Key) in the request, and am getting these delayed quotes. OK so you are referring to the Authorization token in the headers. Got it.
@jflow56014 жыл бұрын
@@SigmaCoding Hi. I am finally using the Get Quotes request with an Access Token to periodically get price data on a given equity (once every 30 seconds). I am still finding that data returned is about a minute behind what is being reported on TOS platform. Would it be better to use TDA streaming api to get real-time price data that is more current?
@jflow56014 жыл бұрын
Hi. I am trying to use the TOS API with a python program I am writing. When I use the API to get quotes about once a minute, I am finding that the price data returned is about 1-2 minutes behind current price data (compared to TOS platform for example). Do I need to use some other type of API to get near real-time quotes? such as streaming. A lot can happen in that minute lag. In addition, when I use the price history API, to get the day's historical data for the current day: period: 1 periodType: day frequency: 1 frequencyType: min endDate: the data returned is always missing the last 17 minutes from the current time. Do you have the same experience with this or is it just me? Thanks for any feedback. I am still looking for a contact to pose these questions to the TDAmeritrade folks.
@cjoshmartin3 жыл бұрын
Thanks for the video
@marvantheamerican36034 жыл бұрын
Is it possible to get options sweeps data from tos api?
@SigmaCoding4 жыл бұрын
Not to my knowledge.
@Luis_Ramos_Grip4 жыл бұрын
Where did you get the libraries that you imported from I didn't get that part getting an error that says No module named 'config'
@SigmaCoding4 жыл бұрын
You need to create the config file yourself. Here is a link to a sample file: github.com/areed1192/sigma_coding_youtube/blob/master/python/python-finance/td-ameritrade/config.py
@ThomasDeMoivre3 жыл бұрын
@@SigmaCoding I had a similar issue. The mistake on my part was just use "from config import client_id" I had used "from config.py import client_id" WRONG!
@JohnSmith-zs1bf5 жыл бұрын
Just wonder, is the 1 minute level data only available for the past 10 days, or can you grab any 10 days? I know with the "OnDemand" option in thinkorswim you can grab 1 minute data going very far back. Using the seconds since epoch can you grab 10 days of 1 minute data, from say 3 years ago? I don't know if it's just not allowed, or if I'm not doing it right. Thanks again for all of this!
@SigmaCoding5 жыл бұрын
Hey John, you can request more than ten days' worth of data, and you can go back to 3 years. The building of the request can be quite confusing, so it was one of the things I worked on heavily when building the TDClient library. In your situation, here is how you would build your request. First, since you're going beyond the default values (i.e., you're not specifying one of the default period values), you'll need to make a custom request. If you wanted the last 15 days' worth of 1-minute candle data, here is how the request would look. 'You want the entire day for the day. periodType: 'day' 'You want minute candle data. frequencyType: 'minute' 'You want the minute candle data to cover 1 minute. frequency: 1 Here's the tricky part, you need to provide the startDate and EndDate as milliseconds since epoch. The keyword here is milliseconds. Here are the milliseconds since Epoch for Oct 15, 2016, at 1:00 PM. 1476561600000 This also serves as your 'endDate' Here are the milliseconds since Epoch for Oct 01, 2016, at 1:00 PM. 1475352000000 This also serves as your 'startDate' Try those arguments out, and let me know if it works. I tried it on my end and got a successful response. Please be careful with how much data you're requesting at once. The last thing you want to do is overload your system by trying to ask for three years worth of 1-minute data. I'm not even sure if TD Ameritrade would allow for this type of request.
@JohnSmith-zs1bf5 жыл бұрын
@@SigmaCoding Thanks for the reply. This is exactly how I have it: payload = {'apikey': client_id, 'periodType': 'day', 'frequencyType': 'minute', 'frequency': '1', 'endDate': '1476561600000', 'startDate': '1475352000000', 'needExtendedHoursData': 'false'} and I also tried leaving out the needExtendedHours line, and what I get back is {'candles': [], 'symbol': 'AAPL', 'empty': True} I also tried not using quotes around the integer values and it still returns the same {'candles': [], 'symbol': 'AAPL', 'empty': True} Any idea what I could be doing wrong?
@SigmaCoding5 жыл бұрын
@@JohnSmith-zs1bf Well, I am officially confused because I ran it this morning before the markets opened, and I got a successful response with data. My only guess would be that it has to do with something when the markets versus when they're closed. I made a request from 10/1/19 to 10/15/19, and I was fine, but when I did 9/1/2019 to 9/15/2019, it still said it was successful, just no data. They probably only will get historical data back to the beginning of the month during market hours, and then aftermarket hours, you can request data from further back. I really wish they would clear this up in the documentation because no where does it say you can only request historical data at certain times.
@JohnSmith-zs1bf5 жыл бұрын
@@SigmaCoding Hm that's an interesting theory. Yea I'm not getting a bad request either it's just coming up blank. I'll have to try again after hours. Thanks.
@SigmaCoding5 жыл бұрын
Hey John, I did a little bit more testing, and here is what I've determined when it comes to minute level price data. You can get a maximum of 30 days worth of data starting from the current date. That means if I request it on 10/27/19 the most, the API will return only from 09/27/19 to 10/27/19. Unfortunately, it doesn't look like you can get minute level data beyond the 30 day period. However, you can get daily level data going back as far as you like. Hopefully, that clears up your question.
@SajjadKhan-cn6mv2 жыл бұрын
how do you use the quotes endpoint with futures contracts like CL (WTI futures)?
@spacecapitalism71524 жыл бұрын
I wonder what the rate limits are for price history? like how many requests can i send per hour?
@SigmaCoding4 жыл бұрын
You get 120 requests per minute for the data APIs.
@catharinesykes62694 жыл бұрын
Great video
@SigmaCoding4 жыл бұрын
Thanks!
@aaronj12113 жыл бұрын
Thanks. Can you be logged into the API and the GUI trading app at the same time?
@migueduarte773 жыл бұрын
Great info, thanks. One advice, I think it would be better if you hide your email from the user section using a video mask, just in case, for your safety.
@taylorbommarito94974 жыл бұрын
Also is the client_id the api key?
@josephrunco64995 жыл бұрын
How do you create a callback URL? I am stuck on that step of app creation.
@SigmaCoding5 жыл бұрын
When you select "Add new App," there is a section called "Callback URL" in that section you need to provide your callback URL. In most cases, since this isn't an app that you'll be releasing, you can just use your Local Host address. However, in my video, I only use the callback URL "localhost/test." Any point forward in the API that requires a callback URL sometimes called "callback URI" you would just pass through that URL.
@josephrunco64995 жыл бұрын
@@SigmaCoding Appreciate the response. In my callback url i am pasting localhost/98.X.XX.XXX where the X's are my IP address and it is giving me the error "ipAddress field is required". I am very new to programming/networking and I can't seem to figure out what i need to do to get a working callback url. Are there steps I need to take to set up a local host or is this a paste and go situation? Thanks again
@bertbrecht75405 жыл бұрын
@@SigmaCoding I am having the same question as Joseph. I do not know how to find "my" callback url and Google searches for "what is my callback url" (or anything like this) do not point me in the correct direction. Is it just a matter of placing "localhost/test." in the "Callback URL" text box?
@josephshimonov79575 жыл бұрын
Hey Joseph, if you are still wondering how to make a callback URL to your localhost, if you go run Jupyter Notebooks online, it'll tell you to run some prompts in your cmd line or terminal. After you run those lines, you'll have access to a localhost:8888. you can use that localhost as your callback URL. I hope that helps.
@ivan203020304 жыл бұрын
Hi, I'm using you library and run into some issue. What is the earliest time API can return for pre-market price history? I'm getting 7AM EST, however thinkorswim app shows 4AM. Do you know why is it so or am I missing something? Couldn't find it in their support. Thanks!
@thiensu19582 жыл бұрын
Hi Larry, are you thinking make a video on using tradovate api in near future ?
@nathanb72693 жыл бұрын
Thanks a bunch for this awesome video! I am trying to pull minuet data for stocks and save lists with the price data, but I am encountering an odd issue where the number of minuet candles are different day by day (I am just taking the len() of the list). If do 5 minuet candles they are the same but not the one minuet candles. Does anyone have a clue as to why this may be, or how to fix it?
@theforexcartel68935 жыл бұрын
@Sigma Coding I would like to reverse my forex trades from my TDA paper account to my TDA live account. Is this possible? Thanks
@SigmaCoding4 жыл бұрын
Unfortunately, the TD API does not give the ability to manipulate a paper account using their API. Hopefully, that is a feature they add in the future.
@mattcarlson7083 жыл бұрын
So does your config file hold the same account login information required to login to your TD ameritrade developer account? or does it hold the info for a seperate account?
@203bigd4 жыл бұрын
bro, great video. Did you call epoch epcot??
@SigmaCoding4 жыл бұрын
For the first comment, I'm glad you liked it! For the second comment, I plead the fifth.
@pedrodiaz70174 жыл бұрын
Is there a way of getting the historic quotes (or fundamental) data? Thank you!
@ergazipp4 жыл бұрын
a very clearly instructed video, thank you. Do you known the rate limit ? couldn't find anywhere online.
@SigmaCoding4 жыл бұрын
The rate limit is 120 requests for minute.
@JohnSmith-zs1bf5 жыл бұрын
Hey first of all thanks so much for this - there isn't a lot of help when it comes to using TD API. I would like to know, without leaking any of your personal data of course, how to format that config.py where the username and password are stored. Of course, I have my own usernames and passwords (for dev account and TDA), but I'm pretty new to this and don't know how I would write the config.py. Could you expand like, which account and password do I need to save in there (TDA or developer, or both, and under what variable names? Maybe you go over it later in the video - still watching.
@SigmaCoding5 жыл бұрын
For "config.py" file, it's a pretty simple layout. Here is how the inside of my "config.py" file looks like: account_password = "My_Account_Password" account_username = "My_Account_Username" client_id = "My_Client_ID" Once you've written the "config.py" file, save it in the directory where you plan to use your "TdScript.py". For example, if that's on your desktop it would look like the following for both files: C:\User\Desktop\TdScript.py C:\User\Desktop\config.py After that, you can import the variables from the "config.py" file into your "TdScript.py" file like so: from config import account_password, account_username, client_id You should then be good to go.
@JohnSmith-zs1bf5 жыл бұрын
@@SigmaCoding Thanks for the quick reply man! Gonna try it out later tonight.
@hanialadmaai55964 жыл бұрын
Hi; thank you for the informative video. Is it possible to connect to AmeriTrade Paper Trade side? It seems that I fail to do that for testing. Thank you.
@SigmaCoding4 жыл бұрын
No it's not possible at this point.
@hanialadmaai55964 жыл бұрын
Sigma Coding ya I figured that, what are other alternatives l, if you please, with powerful charting similar to Thinkorswim? Thank you.
@flyerwolftang4 жыл бұрын
Is it possible to get ITM or OTM probability from the options chain?
@SigmaCoding4 жыл бұрын
These are some of the Greek values that you have access to. "netChange": 0, "volatility": 0, "delta": 0, "gamma": 0, "theta": 0, "vega": 0, "rho": 0, "timeValue": 0, "openInterest": 0, "isInTheMoney": false, "theoreticalOptionValue": 0, "theoreticalVolatility": 0,
@flyerwolftang4 жыл бұрын
@@SigmaCoding Right. It is not included, but I figured out (eg. I store this dictionary into a pd.DataFrame called tblCallsAll, then): tblCallsAll['d1'] = norm.ppf(tblCallsAll['delta']) # ppf is inverse cdf tblCallsAll['ITM_Prob'] = norm.cdf(tblCallsAll['d1'] - tblCallsAll['volatility']/100*np.sqrt(tblCallsAll['daysToExpiration']/365))
@collinjohnson34582 жыл бұрын
How did you open the jupyter window? I can’t figure out how to get mine like that. Do you have to type it on jupyter or can I type it in thinkscript?
@robertcameron42883 жыл бұрын
Can you tell the api to sell at a specific volume as ive figured out volume prediction for different market caps
@micahclarke98194 жыл бұрын
Solid video!
@andreschneider68623 жыл бұрын
Sigma, do you offer your services to people who need to automate a thinkorscript strategy? Thank you
@tysonbentford35253 жыл бұрын
Whats the advantage to that? Thank you
@FabledNarrative5 жыл бұрын
@ 21:28 "Ass Size." :D Keep up the great work, man!
@payamism4 жыл бұрын
Any good video tutorial for learning ThinkScript?
@user-tk5ir1hg7l3 жыл бұрын
At the end of the quote it says delayed: True, is there a way to make it not delayed?
@SigmaCoding3 жыл бұрын
You need to pass through your access token when you make your request. That way they know you're authenticated with an account.
@pdxshadow98195 жыл бұрын
So I am trying to follow your tutorial in the windows command line. Whenever I run the exact code, I get a error. When I test apikey on the td ameritrade API pages, everything works. Any help?
@SigmaCoding5 жыл бұрын
Which part are you receiving the error?
@pdxshadow98195 жыл бұрын
@@SigmaCoding Nevermind! I accidentally deleted my file and redid your tutorial and it works not. Probably had a typo in the URL or something. Thank you for the quick reply.
@SigmaCoding5 жыл бұрын
Hey Everyone, I've had quite a few people reach out regarding issues with the TD Ameritrade API. After going through a couple, I wanted to share something that might cause a problem with the API. I'll also be posting this on all three videos. Some of the requests you make, mainly those related to creating and saving orders, might fail if your account is set up incorrectly. *If your account has Advanced features enabled, then you will have an issue. Not a major one, but it's something that you'll have to decide whether you want to be enabled or not.* If you're not sure whether your account has Advanced Features enabled, then go to the link provided below and read through the instructions. Here is a link to a PDF file that goes over how to find the advanced features setting on your account: www.tdameritrade.com/retail-en_us/resources/pdf/TDA133.pdf If it is enabled, it will say "Enabled," and if it does not say that, then you do not have advanced features enabled. *IF IT IS NOT ENABLED, DO NOT ENABLE IT!!* With all that being said, what's the big deal with Advanced features being enabled or not? If an account is provisioned to be Advanced Features enabled, you will only be able to submit these types of orders through the ThinkOrSwim platform. Advanced Features refers to having more capabilities within ThinkOrSwim. Unfortunately, the only way to allow for these types of orders is to turn off Advanced Features on the account. That's why, more than likely, you can't create saved orders or do any requests related to orders and trades. It's because you may have advanced features enabled restricting you to only making those type of order and trades through ThinkOrSwim, not the API.
@magicronn4 жыл бұрын
This note just saved me hours of debug time as I was about to start on that. Big Thanks!
@briankennedy8174 жыл бұрын
Great video! I'm new to Python and using APIs and this was very easy to follow. Although, I'm looking for some help on how to write this information to a csv file. I'm struggling to write a for loop to extract the quotes data for multiple tickers at once. Any help would be appreciated!
@briankennedy8174 жыл бұрын
Was able to export the results using the code below import pandas as pd df = pd.DataFrame(data) dft = df.transpose() dft.to_csv(r"#filepathandname#.csv")
@314sn54 жыл бұрын
I found this video super helpful. Thanks. You mentioned running the script to get quotes and save in database to analyze data. Would you make a video on something like that? Or can you please mention the tools you would recommend for this use case? I am familiar with python and pandas etc. But, I don't know anything about databases.
@SigmaCoding4 жыл бұрын
Initially, when I created this series I demonstrated in a very simple example using the Streaming API how to insert the data into a SQL database. Using the database in tandem with some type of database service is a highly requested topic so I will be doing a series on it. However, at this point I unfortunately don't have much content on the topic give or take a few lines of code. If you'd like to see the little bit I do have, feel free to visit this file on my GitHub repo (github.com/areed1192/sigma_coding_youtube/blob/master/python/python-finance/td-ameritrade/TD%20Streaming%20API.ipynb) If you go down close to the bottom you'll see a section of the WebSocketClient class that has a "database_connect", and "database_insert" method that shows how I was connecting and inserting data into the database.
@314sn54 жыл бұрын
@@SigmaCoding what do you think of this ?medium.com/@aroussi/fast-data-store-for-pandas-time-series-data-using-pystore-89d9caeef4e2
@Catala48 ай бұрын
Now that the TD API is being sunsetted (May 10...) can you show us how to get authenticated and used the Schwabb API. Your videos are very helpful.
@tinevra4 жыл бұрын
Is there a way to prevent the requests from being visible over the local network?
@SigmaCoding4 жыл бұрын
I'm not sure about that, I would imagine it would be a pretty hard thing to achieve but it might be possible.
@wyattbiker5 жыл бұрын
Is there a way to get other stock information not related to trades? Example. Earnings Date, Dividend, Ex Div Date, Market Cap, P/E, etc
@SigmaCoding5 жыл бұрын
Yes if you use the GetInstruments endpoint that will return fundamental data related to a specific instrument. I believe I cover that endpoint in part two. Here is the link to the documentation: developer.tdameritrade.com/instruments/apis/get/instruments/%7Bcusip%7D
@equalprotection4 жыл бұрын
The first example is incorrect. Per API documentation for price history... If startDate and endDate are provided, period should not be provided. Had to remove start and end dates to get it to work.
@hanialadmaai55964 жыл бұрын
Thank you for this great video. I have one question if you please. I have a modified scanner, is it possible to retrieve the tickers from this scanner using API, thank you.
@equityspeculator46015 жыл бұрын
could you make a video series on the coinbase pro API? I have only watched this one video so far. i believe you could help me and others learn to use that API also.
@SigmaCoding5 жыл бұрын
I'll put it on the list, luckily I have an account with them.
@sujayjavali94613 жыл бұрын
can we do Algo trading without using IBridgePy in TD Ameritrade...? If yes can we do Algo trading using only Jupyter notebook as you shown in above video.. please tell the difference bcoz I am new to Algo trading.. waiting for reply...
@pedrosotomayor84673 жыл бұрын
When registering an app, what should I put where it says callback url? Thanks in advance
@Red-nx2zt4 жыл бұрын
Hi Alex, Thank you for great video. It is simple and easy to follow. I got this error code, ImportError: cannot import name 'client_id' from 'config', and i noticed that the file path/location is wrong. How do I change the path location so that the code can get the information from the correct file. Thank you.
@kennethbassett63304 жыл бұрын
You have to make a file called config and save it in the same folder as your python file (or jupyter notebook) like he did.
@314sn54 жыл бұрын
Quick Question: Suppose want to save data for hundreds of tickers. What is the best way to go about this? I was looking at asyncio for this. Would I run into any problem with hitting their limit ?
@SigmaCoding4 жыл бұрын
Well the API lets you pass through 500 symbols at a time. You could use asyncio for this but be careful because you can only make 120 requests per minute, so add some pauses. Personally, I would just have a while loop where you make a request to the get quotes endpoint and then write the response to a CSV file.
@7ofx5983 жыл бұрын
Hey Alex, Great videos, and code! I have a test loop running which simply logs in and then retrieves quotes. After it runs for some amount of time (maybe 10 minutes to a few hours) it generates a 'TimeoutError: [WinError 10060] exception in connection.py line 86. I haven't gone into the connection.py code to catch it and handle it. Have you or anyone already dealt with this? The loop timing is set to 0.5 seconds, so i suppose it's possible that it is exceeding the 120 requests per minute limit that TD has? Also, Wondering about thoughts on the merger with Schwab and how that may impact the API world? Don Fry
@SigmaCoding3 жыл бұрын
So more than likely it's the 120-request threshold, if you do it with quotes you need to keep in under that. As for the whole Schwab Merger, I can't imagine a crazy amount will change. There seems to be a lot of investment in the ThinkOrSwim platform so I can't imagine them doing all that and then just deciding to get rid of it.
@nyc78614634 жыл бұрын
Can you please do a video on tdameratrade get order data. Meaning what order is open what order is close.
@arisdhaftvani72103 жыл бұрын
Do you know why I am getting "Unauthorized" error on api commands like (Get User Principals) with Refresh Token? It works with Access token though but it expires in 30 min
@muellepatagonico12442 жыл бұрын
fantastic content! Thank you! you would help me a lot if you answered a question! I am about to develop an automatic trading bot in TD ameritrade, I already have all the indications written, and tested. my question is: will it be possible for you to recognize moving averages in 1-minute temporality?and if the price is above or below them? I need to use 3 moving averages. from now on thank you very much and god bless you greetings from Argentina!
@ThomasDeMoivre4 жыл бұрын
You rock. This was a wonderful destressor. Fairly new to Python, I definitely needed some holes filled. I'm using VS code after your suggestion in another video, and have yet another learning curve. But hey, I was able to get multiple equity quotes. Though I do not see the nice output you get. Maybe because you ran from Jupyter? All my equity data was written as a long string. Is there a way to print out something like a structure from VS code? Which is what you get by issuing "data" in Jupyter.
@SigmaCoding4 жыл бұрын
Use the `pprint` module that will make the JSON content more human readable.
@outlaw40164 жыл бұрын
Hi man, thanks for this video! So, we can use this API to automatically create buy/sell orders with an automated stock trading program is that correct? I made a stock program in python, and am looking for a broker with an API that I can create buy/sell orders with. Also, is there any catch to using this API? Assuming it works with cash accounts. Thank You
@SigmaCoding4 жыл бұрын
Hi Zach, Orders: Yes, you can create buy and sell orders using this API and incorporate that functionality into an automated trading program that you build. Now automated trading is a complex process, so there are lots of details to take into consideration, but you can do it. API Usage: The thing to keep in mind with the TD API is that it requires you have an active TD Ameritrade Account to use the API. You cannot use the TD API to control Think Or Swim, and because you cannot use the API to control Think or Swim, you cannot use the Paper Account found in Think or Swim. Hopefully, those answer your questions.
@outlaw40164 жыл бұрын
@@SigmaCoding Thanks man, that answers my questions. Really appreciate this video.. Also, I am using alphavantage to pull from their technical indicators, and making my own sort of algorithm. I get 30 api calls per min for $30 month. So I can pull stock prices, as well as their technical indicators by the minute. If the most recent stock data matches my algorithms conditions, then I put in a buy order. Then, the algorithm looks to sell. And goes back and forth between buy and sell orders. The most time consuming thing is backtesting everything to ensure your algo doesn't lose you money! Haha
@outlaw40164 жыл бұрын
@@SigmaCoding One more quick question, is there a way to delete all of the saved orderID's at once? I am making several saved orders per day, however, when it comes time to delete them, I have to pass a the specific ID one by one which is cumbersome. Is there a delete all function?
@SigmaCoding4 жыл бұрын
@@outlaw4016, In that case, you would need to query the `get_saved_orders` endpoint and then loop through each order, grab the order ID, and then call the `cancel_order` endpoint to delete the order.
@roymakkar4 жыл бұрын
I am using Sublime Text to write my python code. When I build/run my code, the outcome is all in one sentence. In other words, it doesn't come out as neat as yours where every statistic (like askSize, askId, etc.) is on a new line. Do you know any way I can fix this just to see a visually better outcome?
@SigmaCoding4 жыл бұрын
In my video I was using the pprint module, that makes the output more human readable.
@MPW5814 жыл бұрын
Fantastic tutorial!! I dont have a coding background but I can follow well enough... Really quality explanations.. I really appreciate the time and effort put in it.. N.B. has anyone found a way to request futures data?. I struggle due to the fact that futures symbols start with a forward slash e.g. /ES for S&P. The endpoint code will not return the correct data for ES.
@SigmaCoding4 жыл бұрын
If you're trying to get real-time quotes with Futures data, then you should be able to use "/ES" when making the request. Are you trying to get real-time quotes?
@juanmanuelmillansanchez81654 жыл бұрын
Hello, what previous knowledge is recommended for understanding this?
@phillipotey97364 жыл бұрын
Python, api's, HTML requests like POST and GET
@juanmanuelmillansanchez81654 жыл бұрын
@@phillipotey9736 thank u!
@omprakashkolluri11362 жыл бұрын
I just discovered this video. I have an account at td ameritrade.. My question is do I get an api key from the developer site and am i supposed to use my account login and password to get the api key and manage my account using that app I create? Thank you Om
@ignacioa36985 жыл бұрын
Quick questions: Can you show how you wrote the instructions/codes for the "config import client_id" folder to retrieve one's sign-on info? And that reference folder you have it saved under the same Jupyter app, correct? where you house your python saved folders for future retrieval? I'm coming in on tail end of these API videos, so I probably missed that part. If you can direct me to which prior video would show that? Thank you, SigmaC !
@SigmaCoding5 жыл бұрын
So the config file is just a python file that exist in the same folder as the Jupyter Notebook. If you were to open the config file all you would see are three variables: account_number = 'YOUR ACCOUNT NUMBER' password = 'YOUR PASSWORD' client_id = 'YOUR CLIENT ID' So all I'm doing in my script is importing those three variables from that file.
@ignacioa36985 жыл бұрын
@@SigmaCoding wow! Ok simple enough...was expecting more elaborate code lines. Thank you!!!