Backtesting OVER 500 stocks using VECTORIZATION [Do NOT skip this]

Поделиться
HTML-код
  • Опубликовано: 21 май 2024
  • Sign up to enroll for a 7-day free trial of this course now!
    Google Data Analytics - imp.i384100.net/c/4063581/134...
    Many thanks to @coursera for sponsoring this video!
    In this video I am going over vectorizing the iterative Backtest from the previous video and also taking care of mark to market valuation of the assets. The improvement is roughly 50x speed.
    Get the Notebook/Source code by becoming a Tier-3 Channel member:
    / @algovibes
    Please be so kind supporting the channel by hitting like, subscribe and leaving a comment. Thanks a lot!
    Please check out Part I before:
    • The BIGGEST Backtest &...
    Python for Finance playlist:
    • Python for Finance
    Interested in automated trading? Check out the Cryptobot playlist here:
    • Cryptocurrency Bots / ...
    Disclaimer: This video is not an investment advice and is for educational and entertainment purposes only!
    00:00 - 01:15 Introduction / Disclaimer
    01:15 - 02:37 Awesome Sponsor! :-)
    02:37 - 03:57 Recap on the Backtest function
    03:57 - 06:10 First occurrence of buying signal
    06:10 - 12:42 Finding ALL signals
    12:42 - 15:10 Trades / Comparison with Iterative
    15:10 - 21:50 Mark to Market & Profit calculation
    21:50 - 22:58 Mark to Market iterative approach
    22:58 - 24:57 Wrapping it all in a function
    24:57 - 26:08 Running the Backtest / Speed performance
    #Coursera #CourseraPartner #python #stockmarket #backtest
  • НаукаНаука

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

  • @anilmm2005
    @anilmm2005 Год назад +2

    Excellent one.speed results are astonishing. I will try to follow this vectorized approach in future 😊

    • @Algovibes
      @Algovibes  Год назад +1

      Thanks Anil for watching and leaving a comment!

  • @Asparuh.Emilov
    @Asparuh.Emilov Год назад +4

    Your code is always so straight to the point, the easiest, and most efficient solutions, which is great sign of professionalism and experience! Absolutely lovely to watch your videos bro! You are just the best! 🙌♥️

    • @Algovibes
      @Algovibes  Год назад

      Thank you very much ❤️ Appreciate your comment and having you on board!

  • @joshwilson8501
    @joshwilson8501 Год назад +1

    my brain is sizzling from this one

    • @Algovibes
      @Algovibes  Год назад

      It's an advanced topic and perfectly fine to use the iterative approach as well! I tried my best to explain it in detail 😛

  • @jerrywang3225
    @jerrywang3225 Год назад +1

    great tutorial as always, can you explain why we need to find the first signal separately instead of using the diff() function to get all the signals.

    • @Algovibes
      @Algovibes  Год назад +1

      Thanks mate! Sure: If you do not do it your first signal could be a selling signal. With that you are blowing up your backtest and the profit calculation.

    • @jerrywang3225
      @jerrywang3225 Год назад +1

      @@Algovibes thanks for the explanation.

    • @adriaanborgermans5671
      @adriaanborgermans5671 Год назад

      Can you solve this by using 1 for buys and -1 for sells, instead of True or False.
      Btw thank you for the great content!!

  • @Niko-ie6dh
    @Niko-ie6dh Год назад +1

    would it be possible to use this approach to backtest a portfolio of say 5-10 stocks at a time, where you always spend like 10% of your current balance?

    • @Algovibes
      @Algovibes  Год назад

      Sure, that's definetly possible!

  • @nullhakunamatatabyte8042
    @nullhakunamatatabyte8042 Год назад +1

    can we applied reinforcement learning

    • @Algovibes
      @Algovibes  Год назад

      I wouldn't see the application in this specific case. But RL could learn the best parameters in a realtime trade scenario.

  • @MrPositake
    @MrPositake Год назад +1

    Amazing speed, but for more sophisticated logic(Take Profit, Stop Loss, etc.) I doubt there's any way around iterative approach.
    Unfortunately

    • @Algovibes
      @Algovibes  Год назад

      It actually is possible. The thing with vectorization is: There more complex the trading logic, the harder it get's to design it using a vectorized approach.

    • @MrPositake
      @MrPositake Год назад

      @@Algovibes Wow! I would love to see that!
      This got to be some master wizzard pandas coding +logic

  • @lorenzobaggi161
    @lorenzobaggi161 Год назад +2

    AlgoKing

  •  Год назад +1

    🙋‍♂

  • @rraul
    @rraul Год назад +1

    great! marginal gains like in cycling :-) lol

  • @stephenyip5827
    @stephenyip5827 Год назад +1

    Loop through the df is much easier to understand 😂

    • @Algovibes
      @Algovibes  Год назад

      And perfectly fine to use! Don't worry about it - Vectorization is an advanced topic.

  • @mehdihajari6326
    @mehdihajari6326 Год назад +1

    Great video, as always! I have a request, can you create a video to explain walk-forward backtesting in Python. The topic explained by Kevin J. Davey in "Building Winning Algorithmic Trading System" , also you can find it here en.wikipedia.org/wiki/Walk_forward_optimization

    • @Algovibes
      @Algovibes  Год назад

      Sure! Noted and will be covered somewhen in the upcoming months. Thanks a lot