Navigate Select ESC Close

Backtesting Stock Trading Strategies in Python

2022-11-09 Science & Technology
49.8k
1.2k
27
NeuralNine
NeuralNine
476.0k subscribers

Unlock all features

FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.

Description

In this video, we learn how to backtest and evaluate our stock trading strategies in Python. DISCLAIMER: None of this is financial advice. I am not a financial professional and this is a tutorial about programming in Python. I am not responsible for any financial or investing decisions you make. ◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾ 📚 Programming Books & Merch 📚 🐍 The Python Bible Book: https://www.neuralnine.com/books/ 💻 The Algorithm Bible Book: https://www.neuralnine.com/books/ 👕 Programming Merch: https://www.neuralnine.com/shop 🌐 Social Media & Contact 🌐 📱 Website: https://www.neuralnine.com/ 📷 Instagram: https://www.instagram.com/neuralnine 🐦 Twitter: https://twitter.com/neuralnine 🤵 LinkedIn: https://www.linkedin.com/company/neuralnine/ 📁 GitHub: https://github.com/NeuralNine 🎙 Discord: https://discord.gg/JU4xr8U3dm 🎵 Outro Music From: https://www.bensound.com/

Top Comments (10)

@icode7334 2022-11-09

I feel like he is making money from both applying this to his portfolio and YouTube, great videos keep it up

7
@Jxmiecole 2022-11-10

Awesome, been looking for something like this in python for a while. Thanks!🎉

2
@hourglass9 2023-02-15

Great Video! Can you simultaneously do a backtesting on all 4 symbols like for example EURUSD and SPUSD so if I buy on SP500 on 2011-01-07 and sell on 2011-01- 10 then in the next buy this program will recheck the opportunity in EURUSD and SPUSD and automatically matches the buying signal and then buy that stock after 2011-01-10 in this way we can have a full return on investment based on different stocks 😀

1
@vuvu7005 2022-11-30

since i dev trading software, thx for this easy and good tool !

1
@PivotPatTrades 2023-02-19

Wow thanks!

0
@danielngandu8656 2024-01-13

Great video very insightful!

0
@tortue34170 2024-11-17

Thanks for this content. Very nice. I'm not sure to understand, you say "the triangle pointing down is a buy", but if I deactivate the part of the strategy doing "sells" (meaning, I only should have buy trades) I have only triangles pointing up.. Are you sure about the orientation of the triangles ?? What did I miss

0
@lellel3767 2024-09-08

Hey super helpful vid, about the commissions part you set 0.002 per trade but aren’t most brokers today commision free? Do you have to pay for each trade?

0
@raphaelarguello5020 2024-04-07

Great content, thanks for your work! I am struggling with the size of the position for the backtesting. I am trying to risk 1% of the available cash per position so I enter the sl and size = 0.01. However, the risk is completely off and it only risk 0.014% And in your code, you don't enter any size, do you know how much is risked per trade? Would you maybe have a solution please? Thanks for your help!

0
@TracyChen-k7g 2025-06-10

Great intro to backtesting with Python! Backtesting has really helped me refine my strategies — I usually run my initial setups on FastBull to check for consistency across different market phases. Pairing code with a structured simulation platform makes the process even more insightful. Looking forward to more tutorials like this!

0

Unlock the Data Inside
Turn Videos into Knowledge

  • Get FREE 10/day: transcripts, summaries, chats
  • Chat with videos, export text & PDF
  • $1 free API credit for RAG, chatbots & research

Free forever plan • All features unlocked

App screenshot