The Most Realistic Automated Trading Analysis Using Python

Поделиться
HTML-код
  • Опубликовано: 3 май 2024
  • Join us as we dive into the most realistic automated trading analysis using Python on today's episode of Codetrading! If you've been following our journey, you know we've built a basic trading strategy, optimized parameters, and conducted extensive backtests. But the real challenge was launching our live automated trading bot on AWS for an entire month. Today, we reveal the results of our Python-based trading bot, covering every trade, our equity curve, and overall performance in almost one month of live trading.
    Our strategy is simple yet effective, utilizing dual moving averages to gauge market trends and Bollinger bands for precise entry signals. Whether you're new to algorithmic trading or looking to refine your skills, we provide Python code, data files, and links to essential resources right in the video description. Dive into the core of automated trading analysis using Python with us!
    We meticulously analyzed trade data downloaded from our broker, leveraging pandas DataFrames to dissect entry positions, exit times, commissions, fees, and the crucial profit and loss figures. By focusing only on rows with tangible profit or loss, we ensure clarity and relevance in our analysis, adhering strictly to the principles of automated trading analysis using Python.
    Admittedly, our experiment faced limitations. Trades were confined to the hours between 8 AM and 7 PM GMT+2, potentially skewing results by excluding overnight movements. Additionally, our optimization was based on data from two years prior, underlining the importance of recent data for strategy fitting. Our next steps involve refining our approach, including an automated optimization process every Sunday, to align our trading parameters with the latest market data.
    Despite these challenges, we affirm the potential of our chosen indicators for automated trading analysis using Python. The primary area for improvement lies in trade management, where we aim to enhance our strategy's sophistication.
    Share your thoughts, questions, or experiences in the comments below. Your insights enrich our community and help guide future content. For more in-depth tutorials, strategy discussions, and live trading results, subscribe to Codetrading. Trade safely, and until next time, keep analyzing and optimizing your automated trading strategies with Python!
    Previous videos related to the same strategy:
    • Trading with Python: S...
    • Live Trading Bot Strat...
    • How To Improve A Live ...
    Discount Vouchers for my Algorithmic Trading and Python courses:
    💲 Algorithmic Trading: bit.ly/CouponAlgorithmicTrading
    💲 Data Analysis with Numpy and Pandas: bit.ly/CouponDataAnalysis
    💲 Machine Learning Methods In Algorithmic Trading: bit.ly/CouponMachineLearningT...
    The code and the data I used in this video:
    drive.google.com/file/d/12uLn...
    drive.google.com/file/d/1nk_J...
    Enjoy Coding!

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

  • @MartinPleasant-ty1rw
    @MartinPleasant-ty1rw Месяц назад +5

    I’m now going to watch all of your videos. I’ve just came across your channel and your videos… they are amazing. I’m just starting my journey in algorithmic trading/ learning python and you are the best most straightforward channel on RUclips in this area. These tutorials and guides you are sharing are so informative please keep doing your thing, there is so much value to the information you are sharing and it gives me hope that I can learn these things. Thank you so much. You’re the Best!

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

      Welcome aboard! I hope you will enjoy coding as much as I do.

  • @christophermatthews4896
    @christophermatthews4896 Месяц назад +7

    Great to finally see some results! i love the usage of statistical analysis for tests. i also like the concept of retraining the bot every Sunday, thats a concept i haven’t seen put into practice yet. great video!!!

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

      Glad you liked it! Thanks for the support, I deployed the updated version already, just need to wait, I will also be re-verifying the code for some bugs, it might happen!

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

      Can’t wait to see the updates!!

  • @MasamuneX
    @MasamuneX День назад +1

    trailing stops and exponental position times outs to allow for market conditions to change into more favorable ones after a losing trade by the system.

    • @CodeTradingCafe
      @CodeTradingCafe  День назад

      Hi, saw your other comment, helpful thank you!

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

    great results analysis.thanks

  • @Newbie-dv9gc
    @Newbie-dv9gc Месяц назад +30

    If you change signals.(for example,sell to buy and buy to sell.)This strategy is promising 😂😂😂

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

      😅

    • @CodeTradingCafe
      @CodeTradingCafe  Месяц назад +3

      Lol 😅, actually it doesn't work either, but ... you reminded of an idea I tried some time ago, use the Bollinger Bands a bit wider to detect a change or break of the trend, it has good results on EURUSD even with spread fees. It does work the opposite way though because it's detecting reversals instead of trading with the trend, same indicators but completely different strategy.

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

      I came to realize most indicators confirm to you when the trend is completed so when you enter on a sell its actually a buy😂.
      I dont know the effect if aglo trading is limited to cetain hours of the day to avoid those false signals which may increase the profitability.

    • @a-m-vclips9653
      @a-m-vclips9653 Месяц назад +1

      I actually did the same for my live demo bot(with this strategy) it worked pretty well, but in long term I just keep losing because of commission fees and tight stoploss

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

      @@a-m-vclips9653 undoubtebly the commisions will fail you.
      Probably design a trading strategy that fails extremely well such that you trade the opposite

  • @muhireinnocent2371
    @muhireinnocent2371 Месяц назад +2

    I deployed a similar bot on aws and its almost blowing up my demo account. Thanks for your content though i have learnt alot from your algo trading tutorials.

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

      however i have found that if you use Bollinger bands ,rsi and stochastic indicator on 1h chart we can get nice price reversal movement positions and with high return on investment, low maximum drawn down and higher win rate. but the trades are limited, i have tried to increase the number of trades by looping through many currency pairs

    • @CodeTradingCafe
      @CodeTradingCafe  Месяц назад +2

      I am still skeptical the difference between backtesting, forward testing and live exceeded my expectations I am suspecting a small bug somewhere... will have to re-verify.

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

    Great.... Thank for your share.

  • @derhut6560
    @derhut6560 Месяц назад +5

    Thanks for sharing. Did you run the backtest script over this live-trading month for comparison? Might be interesting to identify analyze differences to the life account, maybe also finding errors in the implementation or backtesting?

    • @CodeTradingCafe
      @CodeTradingCafe  Месяц назад +6

      I haven't ... I should, maybe I will check it out this week, but it's a great idea to compare live results with backtesting results over the same period. Will keep us posted.

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

    Loving this series! I've learned a lot from it!
    I've been trying to optimize this strategy myself and I have noticed that perhaps the problem lies in not accounting for commission during the backtest. Just adding commission changes the results a lot. I assume that backtesting without commission favors strategies that involve a very high number of trades (such as this one). I would love to see you backtesting this strategy while considering commission and spread. Thanks!

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

      Hi, thanks I agree, I usually discard commissions to test the indicator effect, later if results are good I add commissions but Trade management has to be up to the level. Will test with commissions but must increase timeframe.

    • @OsirisHorscow
      @OsirisHorscow 13 дней назад

      @@CodeTradingCafe Do you have any update on this tested with commissions ? For Oanda Core pricing (what I believe you use here on the demo account) do you put in the total 0.0001 for the backtesting commission value or do you put in the 0.00005 that is per trade order?

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

    Hi. thank you for the work that you do. Is there any way that you could test Smoothed Heiken Ashi indicator on different time frames ?

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

      Hi, I understand the idea, but I never got good results with Heiken Ashi, I don't even know how anyone is making money using these (out of curiosity), the way they are computed they add lag and twisted/smoothed prices.

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

    Love there feedback !!

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

    Great stuff. What period will the automated optimisation be run over Zian? The previous weeks data?

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

      For now it fits on the last 3 weeks, I might increase to 4 weeks, see how it works.

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

    Hey! Interesting video, thanks for that.
    One addition or consideration that I am interested in: if you take the month of price data and runned it against your backtest. Would your simulated results be really close to your actual results? This to prevent that you are overlooking things not considered in the backtest (e.g. Fill price, exits and so on).
    Thanks! Stan

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

      Ah sorry… i just saw someone else already had the same suggestion as well👍🏼

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

      No problem, I think it's very important suggestion, I will put it on the priorities list, I am also suspecting an edge case bug in the live version (last candle might be skipped and we are maybe using the candle before it... I need to verify this as well). Thank you for your comment, I will keep us posted.

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

    Thanks for sharing. I believe you should also try backtesting your strategy using the same period as shown in your video.
    I highly suspect that it's a slippage problem or something related to the execution part, rather than an issue with the time frame as you mentioned. I have traded with this kind of CFD brokerage before and found that the performance of my strategy varied between different brokerages.

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

      Yes, this was proposed yesterday as well, I think we need to verify this.

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

      @@CodeTradingCafeCFD isn't regulated. test on a regulated exchange.

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

    great vid! can you do a video explaining why you buy 3000 units? and if possible, explain how to calculate this figure. thanks!

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

      Hi, in forex standard lot is 100 000 units so 3000 is like 0.03 on metatrader, no particular reason for choosing this sum, I just wanted to be consistent for comparison and kept using 3000, I will make a video on different lot sizing methods.

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

      ty. very excited!

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

    Good day Sir, your RUclips video is impressive and great! May I ask if I can edit the strategies? And also, to use any API Trading Platforms and to test Crypto? Can it be used as paper trading? Thank you so much Sir.

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

      Yes absolutely, you just need to know your way around Python, check this video for live trading ruclips.net/video/bZhtvvFm17A/видео.html

  • @haritdey430
    @haritdey430 Месяц назад +2

    Dr Ziad Francis is very genuine, i had his udemy lecture its a good insight to algo trading

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

      Thank you Harit for your support, glad you liked the course.

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

    would really love to see the automated optimisation process and ideally code when done please?!

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

      It's deployed already I just need to make a video.

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

      @@CodeTradingCafe amazing, look forward to it for sure

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

    when building a NN, how do you select the perfect hyperparameters (layers and units per layer) without overfitting?

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

      Do not use NN

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

      It's a long technical answer, but the short one is NN don't really work this way for trading.

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

      why?@@lucastorres394

  • @user-dh5un9zv6z
    @user-dh5un9zv6z Месяц назад +2

    thanks great content
    how can i automate my trading system

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

      Hi check my latest videos about this strategy for automation.

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

    Hello, I advise you to compare those trades with backtests results, and focus on comparing open trades time - this is the key for success, I checked your code with backtest and in my opinion you have a 1hour leak. Maybe the good idea would be to create your own backtest code instead of using library? Its helpful to be able to know details of every trade - with your own backtest algorithm you can control it

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

      Hi, thank you, can you point me out to the "leak" so I can verify on my end. I just need to avoid building a whole library from scratch.

  • @user-co6eg3ot3c
    @user-co6eg3ot3c Месяц назад +1

    @CodeTrading
    when i run
    import pandas as pd
    df = pd.read_csv("transactions.csv")
    it shows this error :
    ModuleNotFoundError Traceback (most recent call last)
    Cell In[4], line 1
    ----> 1 import pandas as pd
    3 df = pd.read_csv("transactions.csv")
    ModuleNotFoundError: No module named 'pandas'
    what is wrong?

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

      Seems that you don't have pandas installed, try in the notebook the following command !pip install pandas

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

    i am waiting for your next machine learnign and algorithmic trading udemy course . i laerned a lot from it please create a advance version of it.

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

      Thank you for your kind support! It's going to take some time for this, I haven't even planned the curriculum yet.

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

    Hi, if possible can you guide how to deploy the code in was server

  • @b.kvinaykumar391
    @b.kvinaykumar391 Месяц назад +1

    Can you make a strategy for Indian market for derivatives it is a humble request

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

      Hi, thank you for your comment. The strategies I post here are generic purely technical so any strategy that works in here should also work on any market theoretically, you can take any code and just test is on Indian market data.

  • @seguidor777
    @seguidor777 Месяц назад +2

    Hello, do you have a patreon page?

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

      Hi, no patreon sorry, just these videos for now :) thanks a lot for your support.

  • @m.agussantoso
    @m.agussantoso Месяц назад +1

    Is there any update on this?

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

      I checked yesterday, sorry to disappoint, … it has been an honor trading with you :)
      Joking aside it's failing when the market is not trending, even with the updates, I will make another video anyway to show I did the updates.

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

    great video.
    can you also test on crypto please?
    thanks

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

      Now that BTC is climbing yes let's test next strategies on crypto :)

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

      @@CodeTradingCafe
      Great!
      Thank you

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

    Try longer time frames, where maybe you could capitalize on the trend so the hourly and the 4 hourly, okay I maybe be spitballing here but it could be worth trying

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

      Actually you are absolutely right, higher timeframes are much easier to auto trade, somehow this channel dragged me down to lower timeframes and new experiments, my preference though is the daily tf.

  • @poisonza
    @poisonza Месяц назад +2

    If you keep adding more constraints to improve it, isn't there a risk of overfitting? Good luck 😅

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

      It depends, in this case note really, because we are not fitting the indicators, so we can't really overfit from this perspective, we are just fitting the trade management part: the SL and TP, the rest remains the same. Anyway, the only mod I might add is simply the dynamic fitting every week, it's still reasonable in my opinion.

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

    If i have a good idea for trade bot very good can i tell about it

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

      Only if it's a good idea 😀

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

      @@CodeTradingCafe don't Don't worry it is good idea 100% we going to make profit and i have many ideas but how can i contact with you do you have discord or Facebook

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

      😊Yes it is we going make profit 100% and i have many ideas but how can i contact with you do you have discord or Facebook

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

      No discord, Just email for now codingntrading gmail com

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

      @@CodeTradingCafe i send to you a email did you see it

  • @RohitGupta-ys6bl
    @RohitGupta-ys6bl Месяц назад +1

    Hi , sir ❤❤❤ Iove from India .
    I have one statergy if will create in indian stock market using any Indian broker api .
    It is very help full for me ❤❤❤❤

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

      Glad this video is of help, good luck for your coding.

  • @jasonreviews
    @jasonreviews Месяц назад +2

    it's just coin flip. Just make random small trades everyday. it's literally too random.

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

      Yes and no, the backtest doesn't show positive results for random tossing but it does for this indicator, and it's clear that extreme values detected outside of BB indicate a price bouncing and converging to the center of the band, makes sense. But there is still a detail messing up the trades, and it would be great to find it... and correct it.

  • @AhmedAli-go7wx
    @AhmedAli-go7wx Месяц назад +1

    graet work , I am wating new news

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

    I would love to collaborate with you on this project, how can I contact you,I'm a developer also

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

      Hi, let me know what's your plan.

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

      i am a developer aswell. can we have a common forum for developers please

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

    hey , loved ur content ,want to contact you , any gmail etc?

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

      Hey, thank you, my email is in the about section of this channel codingntrading at gmail com