The ultimate Interactive Brokers API Tutorial Part 1

Поделиться
HTML-код
  • Опубликовано: 21 сен 2024
  • The ultimate Interactive Brokers API Tutorial Part 1 using ib-async formerly known as ib_insync

Комментарии • 80

  • @MLAlgoTrader
    @MLAlgoTrader  3 месяца назад +7

    Code Here: github.com/adidror005/youtube-videos/blob/main/hello_ib_async_actual.ipynb

  • @TradingSuccessCoach
    @TradingSuccessCoach 2 месяца назад +4

    Man, whoever said you couldn't explain things properly never paid attention - this is a really great tutorial and mini-series. I highly appreciate your effort and time you took to make it - give my love to your family and if I may say so: KEEP UP THE GREAT WORK!

    • @MLAlgoTrader
      @MLAlgoTrader  2 месяца назад +1

      Much appreciated! Love the support brother

  • @edzme
    @edzme 23 дня назад

    I really like that you don't cut out all the problems that you've run into.... that is what coding is actually like and it's helpful and useful to see you debug it in real time.

    • @MLAlgoTrader
      @MLAlgoTrader  23 дня назад +1

      I cut some of them lol thanks

    • @edzme
      @edzme 23 дня назад

      @@MLAlgoTrader haha ok but just some of them. btw is part 2 of this video up? i cant find it in your videos, thanks!

    • @MLAlgoTrader
      @MLAlgoTrader  22 дня назад

      I need to do it sorry. I got one on Bollinger bands in meantime I think

    • @edzme
      @edzme 22 дня назад

      @@MLAlgoTrader ahh cool cool no worries. appreciate all your great content!

  • @elianj.gonzalez3886
    @elianj.gonzalez3886 2 дня назад +1

    TRADE MAMBA YOU ARE UP ON MY WALL WITH THE WORD GOAT NEXT TO IT

    • @MLAlgoTrader
      @MLAlgoTrader  2 дня назад

      Near Kobe and MJ? Lol 🤣 MJ flew game is how I'm feeling now. Appreciate your kind words

  • @justinb8602
    @justinb8602 Месяц назад

    Thanks for doing this. It was very helpful. I enjoyed your somewhat unscripted style. Seeing you do trial and error makes it more real and easier to relate to. Thanks again.

    • @MLAlgoTrader
      @MLAlgoTrader  Месяц назад

      Thanks! Anything else you want to see?

    • @justinb8602
      @justinb8602 Месяц назад

      @@MLAlgoTrader more on order management please. For example, how to specify order start time for different types of orders.

  • @PSVDEVAN22
    @PSVDEVAN22 3 месяца назад +1

    Thank you for sharing, your new subscriber .Just started my journey exploring TWS API ,your video really helps in my learning journey .

    • @MLAlgoTrader
      @MLAlgoTrader  3 месяца назад +2

      Thanks market is closed now so tomorrow video will be more useful haha 😂

    • @PSVDEVAN22
      @PSVDEVAN22 3 месяца назад

      @@MLAlgoTrader Thank you

  • @yyxi6255
    @yyxi6255 5 дней назад

    Thank you so much for this!

    • @MLAlgoTrader
      @MLAlgoTrader  4 дня назад

      Thanks for the kind words. Please subscribe and share if you can lol. Any topic you would be interested in in the future?

  • @chentomerify
    @chentomerify 10 дней назад

    Great vid brother!
    Thank you

    • @MLAlgoTrader
      @MLAlgoTrader  10 дней назад

      Thanks a lot.. I just recently learned that my videos have been in 720P. Do you think I need to redo a video like this or quality is ok enough to understand? Thanks a lot and share video if you can! LOL

  • @yvesdance2306
    @yvesdance2306 Месяц назад

    Great job! Thank you so much for your dedication to sharing your knowledge. Make it a great day 🎉

    • @MLAlgoTrader
      @MLAlgoTrader  Месяц назад

      Thanks sorry for late response!!!!! I am back

  • @heyitsbt
    @heyitsbt 27 дней назад

    Is part 2 out yet? Thanks so much for this! SUPER helpful!

    • @MLAlgoTrader
      @MLAlgoTrader  27 дней назад +1

      Ehh it is a lot of work cuz I need to explain about asynchronous programming. What specifically are you interested in seeing I might be able to make it more custom. I have like Bollinger band examples and catboost example for example . Soon will have pairs trading

    • @heyitsbt
      @heyitsbt 27 дней назад

      @@MLAlgoTrader I'm sure it's a ton of work! Very appreciated!! I'm just getting started and learning about both trading strategies and coding in general, so I don't have real specific questions just yet, but just excited to learn as much as possible!
      The first thing I'm going to be working on, which may change once I understand the API better, is capturing periodic data to a local database so I can look at options chains bid/ask/open interest data after hours (when I have time so I can analyze and learn more). Haven't had any luck being able to access that data after hours (and I don't have any data subsciptions yet, which I'm going to sign up ASAP.) Ideally heading towards making an options trading bot.
      Just keep doing what you're doing! I'm excited to check out your other videos! This one was so helpful in learning how to interact with the API and what is possible! Thanks again!

  • @MrBillyClanton
    @MrBillyClanton 2 месяца назад

    Great tutorial - +1 on doing Pandas vids, and also Jupyter shortcuts you are using

    • @MLAlgoTrader
      @MLAlgoTrader  2 месяца назад +1

      Sounds good!!! Yeah been meaning to do one on pandas. You prefer a from scratch or just some cool tricks?

    • @MrBillyClanton
      @MrBillyClanton Месяц назад

      @@MLAlgoTrader Cool tricks!

  • @ooofootball
    @ooofootball Месяц назад

    Thank you for this great video.
    Can you point me to other videos where you dive into the asynchronous and event driven formats?
    Thank !

    • @MLAlgoTrader
      @MLAlgoTrader  Месяц назад +1

      Hey sorry for late reply, I didn't have time for anything. I will make videos on it soon I hope thanks for reminding me.

    • @ooofootball
      @ooofootball Месяц назад

      @@MLAlgoTrader ok cool, thank you!

    • @MLAlgoTrader
      @MLAlgoTrader  Месяц назад

      Anything specific you want to see ?

    • @ooofootball
      @ooofootball Месяц назад

      @@MLAlgoTrader yea.
      I suppose that all the ordinary users (the ones not understanding async programming) are probably unintentionally blocking.
      I have a trading system which analyzes data on every tick, i would like to understand how to not block the loop.
      It is a little bit tricky for newbies with async and I believe that it was resolved on the ib_async level. So if you can dive into this it will be great!!
      ערוץ מגניב! תודה על התוכן

  • @PrashantJain-uq8mu
    @PrashantJain-uq8mu 3 месяца назад

    Great stuff. Do you have something for absolute beginners like setting up python, libraries, Ibkr API and creating an option dashboard to track gamma levels. It would be great if you could make one or point me to a resource. Thanks for sharing your knowledge.

    • @MLAlgoTrader
      @MLAlgoTrader  3 месяца назад

      I would love to but don't know when I will have time. I recommend maybe getting started with anaconda ? The gamma stuff isn't begginers haha 😂 but yeah noted your request on to do list eventually I get to everything

  • @junli2581
    @junli2581 2 месяца назад

    Great ! It helps me a lot

  • @Aaron-zv2sx
    @Aaron-zv2sx 3 месяца назад

    This is amazing!

  • @sebastiandeanda2085
    @sebastiandeanda2085 Месяц назад

    I appreciate your file folders names on your desktop

    • @MLAlgoTrader
      @MLAlgoTrader  Месяц назад

      Are being sarcastic should I blur it out ?

    • @sebastiandeanda2085
      @sebastiandeanda2085 Месяц назад

      @@MLAlgoTrader no bro I genuinely found it funny. I have a bunch of random folders named outlandish things too.

    • @sebastiandeanda2085
      @sebastiandeanda2085 Месяц назад

      @@MLAlgoTrader but real good content tho. I tried to using the tws api using there code given in the official website tutorials and I couldn’t get it to work.

    • @sebastiandeanda2085
      @sebastiandeanda2085 Месяц назад

      @@MLAlgoTrader got yours to work first time tho

    • @MLAlgoTrader
      @MLAlgoTrader  Месяц назад

      @sebastiandeanda2085 oh haha you scared me for a second

  • @vetriselvannatarajan6750
    @vetriselvannatarajan6750 2 месяца назад

    Hello Trade Mamba,
    Thank you for sharing this informative video. It's unfortunate to hear about the passing of Ewald de Wit, the original author of IB_insync, but it's heartening to see the async project and your videos on it. I have a couple of queries as I am already developing a code using ib_insync.
    1. Is it sufficient to simply replace "insync" with "async" in the import statement?
    2. You mentioned that the paper trading account exhibits some peculiar behavior in comparison to a live trading account. Currently, I am testing the code in paper trading mode and sometimes encountering issues such as data disconnections and No market data permission messages despite having the subscription. Would it be advisable for me to test with a live account, perhaps with a non-funded live account?
    Thank you for your time and for addressing these queries.
    Best,
    Vetri

    • @MLAlgoTrader
      @MLAlgoTrader  2 месяца назад +1

      Hello,
      Yes very sad about Ewald De Wit's passing. Very sad.
      1) Yes
      2) Don't move to a live account yet. What data disconnections are you getting? Are you also using the IB app on your phone? There is no such thing as a non-funded live account lol. I guess you can make tiny trade for penny stocks that will always lose due to commissions, but maybe if I see the error I can better help you.

    • @vetriselvannatarajan6750
      @vetriselvannatarajan6750 2 месяца назад

      @@MLAlgoTrader Thank you for your response. Here's some background information:
      The main goal is to have the code run autonomously and only require a weekly login for maintenance.
      Components:
      1. IBC
      2. IB Gateway
      3. Python code - It runs continuously, but the logic is only checked during market hours.
      4. Code snippet:
      ```
      self.index_data = self.ib.reqMktData(self.index_contract)
      self.ib.sleep(10)
      self.index_price = self.index_data.marketPrice()
      ```
      This snippet retrieves the market price of SPX, which is then used to obtain option strikes. Occasionally, it randomly returns "nan" despite using a high sleep time. It works fine at other times. I'm unsure what is causing this inconsistency.
      Can you provide any potential solutions? Thanks in advance

    • @MLAlgoTrader
      @MLAlgoTrader  2 месяца назад

      Sorry for the timing the last post of mine has nothing to do with you lol. I would not do it like this..
      Just do it one time
      self.index_data = self.ib.reqMktData(self.index_contract,"",False,False)
      self.ib.sleep(10)
      YOUR_TRADE_LOGIC_OR_CODE.....
      WHILE I AM TRADING:
      self.index_price = self.index_data.marketPrice()
      No need to run ib.reqMktData a few times...

    • @MLAlgoTrader
      @MLAlgoTrader  2 месяца назад +1

      Sorry that format was bad. What I mean is big picture you only need to call ib.reqMktData just one time! The third param is snapshot. If set to False then it keeps updating it with fresh data...

    • @vetriselvannatarajan6750
      @vetriselvannatarajan6750 2 месяца назад

      @@MLAlgoTrader Thank you for your reply. So, if I understand correctly, I just need to use `reqMktData` with the `snapshot` parameter set to false, call it once, and then access the market price whenever needed. Am I correct?

  • @MichaelZus
    @MichaelZus 3 месяца назад

    This is a great video, thank you for publishing it.
    Have a question, I want everyday to get an open price of all s&p500 stocks asap at the market open time, which way do you suggest to do it? maybe you have some video that might help me?

    • @MLAlgoTrader
      @MLAlgoTrader  3 месяца назад +1

      Thank you for your kind words. To be honest my channel traffic kinda died for some reason so if you can like and share the video I would be grateful.
      With Polygon.io this is easy:) with Interactive it isn't as easy since there is a limit for most people...
      I can show you how to do it, but you might only be able to do it for 100 tickers. I can do it for 500 since I pay a ton of commissions a month LOL
      By default you only get 100 market data subscriptions unless you buy a subscription booster, or have a giant account, or pay a lot of commissions you get more.
      See here...
      www.interactivebrokers.com/en/index.php?f=14193
      They write,
      "How Market Data is Allocated
      In order to receive real-time market data, customers must be a subscriber to market data. All clients initially receive 100 concurrent lines of real-time market data (which can be displayed in TWS or via the API) and always have a minimum of 100 lines of data. After the first month of trading, the quantity of market data is allocated using the greater value of:
      USD monthly commissions divided by 8
      USD equity multiplied by 100 divided by $1,000,000
      (rounded down to the nearest integer)
      100
      Example 1:
      In month two, your account shows the following values: USD Monthly Commissions: $16, USD Equity: $950,000
      Using the calculations above, you would still receive the minimum 100 lines of data, since: $16/8 = 2
      $950,000 x 100 / $1,000,000 = 95
      Example 2:
      In month three, your account shows the following values: USD Monthly Commissions: $500, USD Equity: $1,245,000
      Using the calculations above, you would receive 124 lines of data, since: $500/8 = 62.5
      $1,245,000 x 100 / $1,000,000 = 124.5, rounded down to 124."
      So in my account since I pay so much commission say I pay 4k in commission a month. I can get 4k/8 = 500 subscriptions.

    • @MLAlgoTrader
      @MLAlgoTrader  3 месяца назад

      There might be another way. Do you need the exact open price or if it is up or down ? Cuz then you can use a scanner. Maybe if you give me an idea what you are trying to do I can think of a solution

    • @MichaelZus
      @MichaelZus 3 месяца назад

      @@MLAlgoTrader no, just want open price every day, all. other stuff I can get with historical data without an issue. I want to check stuff like sma/ema crossing etc, and make decisions for exist positions based only on "open" prices.

    • @MLAlgoTrader
      @MLAlgoTrader  3 месяца назад +1

      You mean you just want the 500 open proved and that is it? This is easy you can do it with yahoo finance. Latency might not be bad.

    • @MLAlgoTrader
      @MLAlgoTrader  3 месяца назад

      ruclips.net/video/nSFZBkAwzoo/видео.html can adapt this .

  • @konturgestalter
    @konturgestalter 3 месяца назад

    love it

    • @MLAlgoTrader
      @MLAlgoTrader  3 месяца назад +4

      😂😂 You couldn't have watched it yet lol.

    • @konturgestalter
      @konturgestalter 3 месяца назад

      @@MLAlgoTrader correct!! 😂 but it is exactly the topic I was looking for😂

  • @Solopreneu
    @Solopreneu 3 месяца назад

    Hey what If I want dynamically retrieve all the stocks listed in the exchange is it possible to do so?

    • @MLAlgoTrader
      @MLAlgoTrader  3 месяца назад

      All the stocks ! You have a max amount of subscriptions but you can use a scanner ? For what purpose ?

    • @Solopreneu
      @Solopreneu 3 месяца назад

      Do I have to take max subscription while doing using scan

    • @MLAlgoTrader
      @MLAlgoTrader  3 месяца назад

      Not sure I understand. Maybe I'll ask it another way. Big picture, what do you want to try to do and I'll see if I have a solution.

    • @Solopreneu
      @Solopreneu 3 месяца назад

      Look I want to retrieve instruments details of stock,future,option from any exchange around so that I can trade in different currency dynamically it should not be hard coded. After the instruments is retrieved it will have shortlist the best performing stocks

    • @Solopreneu
      @Solopreneu 3 месяца назад

      And I am not able to retrieve all the listed instruments from any exchange please help me to do so