How To Automate Multi-Asset Trading Strategies In Python

Поділитися
Вставка
  • Опубліковано 11 вер 2024
  • In this video, we explore multi-asset trading automation in Python, demonstrating how to test and optimize a trading strategy across various assets. Using Python, we backtest strategies on major Forex pairs and Gold to enhance win rates and total returns. We cover setting up a trailing stop on the daily timeframe to maximize profits, using moving averages to detect trends, and utilizing Bollinger bands for entry signals.
    Follow along as we code the strategy in Python, automate the backtesting process, and optimize the parameters efficiently. This video provides a comprehensive guide to multi-asset trading automation, making it easier for you to implement and enhance your own trading strategies.
    This approach on multi-asset trading automation in Python will provide valuable insights and practical steps to improve trading strategies and backtest on different markets.
    °°° Discount Vouchers for my Algorithmic Trading and Python courses:
    💲 Algorithmic Trading: bit.ly/CouponA...
    💲 Data Analysis with Numpy and Pandas: bit.ly/CouponD...
    💲 Machine Learning Methods In Algorithmic Trading: bit.ly/CouponM...
    Live Trading Bot Example:
    • Live Trading Bot Strat...
    To rerun the tests on your own data you can download the Python code from the link:
    drive.google.c...
    And the data files I used:
    drive.google.c...

КОМЕНТАРІ • 62

  • @LoOP-oi4qm
    @LoOP-oi4qm Місяць тому +8

    this channel is a gem

  • @lunghunglin5729
    @lunghunglin5729 4 дні тому +1

    Thank you very much as always for the turtorials!

    • @CodeTradingCafe
      @CodeTradingCafe  День тому

      Glad you like them! Thanks a lot for your support.

  • @bongoseakhoa5092
    @bongoseakhoa5092 Місяць тому +2

    Hi Ziad, thank you for the content you put out you have had a real impact in my life focussing my passion for data science which even led to a job teaching fintech with edX. It has been amazing watching you over the past 2 years and growing my skillset I truely wish you everything great in life. Please continue producing great content!
    Sidenote to anyone else reading this comment never made any money with automated trading and that is mostly on me, just loved the learning part of it and still continue to.

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому +3

      Great to hear! Thank you for leaving this comment. Even if you didn't make money trading you already did a lot by being consistent these last 2 years and you grew your skills for sure this is already a big win. On the other hand, medallion, renaissance technologies, the all time and space wizards of automated trading are averaging 60% returns per year, so keep this in your math if you ever wonder how good should a system be, I would say anything above 10% per year is excellent (not getting rich though :) ). I think I will have to make a video about this to raise awareness.

  • @vassiliscapsis5828
    @vassiliscapsis5828 Місяць тому +1

    Hi Ziad. Just watched the video and is (once again) a real gem, both for traders and coders. It has everything I wished for (lol). I hope you and your family are and stay safe

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому +1

      Hey Vassilis thank you so much. So far so good for the situation hopefully it will not escalate, meanwhile we can still code :)

  • @STSamurai
    @STSamurai 16 днів тому +1

    I have implemented this whole strategy will run it for the next couple of months and might update here if good things happen

    • @CodeTradingCafe
      @CodeTradingCafe  13 днів тому +1

      Thank you, it would be of great help :)

    • @piphunter
      @piphunter 13 днів тому

      Would you consider testing on the 4hr bar and 60m bar for shorter time frames for more of a swing model?

  • @ezequielperez5724
    @ezequielperez5724 Місяць тому +3

    Very good analysis. But you cannot consider a statistically robust model with only 80 events! Minimum 1000, optimal 2500, ideal 10,000, at that point, all the indicators you have used stop being profitable. You may have taken small segments, which randomly, give positive returns with 80 events. Like when you toss a coin, at one point you may get 80 heads in 100 attempts, but in the long run, 10,000 events, it will be 50/50. That is why robustness is necessary in the analysis. I invite you to do the backtest in H4 over a period of 20 years for 10 assets, with your programming capacity you can do it and there the commercial indicators perish. You have to look for other "little things" to be profitable, which is clearly possible! Great work colleague!

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому +1

      Hi, thank you. I agree statistically 80 events are still short somehow. But at the same time the test was on 7 assets and I think around 7 years each. So that's a lot of candles already I assume I could include cryptos and stocks and increase this to around 300 events max considering the data. Now about using the strategy on the 4H timeframe I am not sure it would still work as well simply because a daily rejection is stronger than a 4H rejection. What do you think?

    • @ezequielperez5724
      @ezequielperez5724 Місяць тому +2

      If the statistical advantage exists, it should be able to be expressed in any time frame, from W1 to M1. Considering that the shorter the time frame, the greater the impact of commissions, the model must be balanced in that direction for it to be profitable. Another way to check if this combination of indicators you used works is to measure it in the number of suitable events, 2500, for which you should include about 220 assets, taking into account that if you filter, and that number drops to 600 events for example, you are still short of events, and you should re-measure that new filtered scenario in more products. Perhaps in the end you will end up with a portfolio of 700-1000 assets and its operation, if it is not completely automated, I doubt it can be done.

  • @ahmedbadal3795
    @ahmedbadal3795 Місяць тому +1

    as beginner i dont know were to start i will stick with learning the thoery for forex first and am now then comeback here any thanks for long list mate

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому +1

      Give yourself time (months) you will start feeling comfortable soon enough. Good luck!

    • @ahmedbadal3795
      @ahmedbadal3795 22 дні тому

      ​@@CodeTradingCafe okey thank you

  • @nandoribas
    @nandoribas Місяць тому +2

    Realy good work, nice video.

  • @haass...9065
    @haass...9065 Місяць тому +2

    Saw this live 🔥🔥

  • @STSamurai
    @STSamurai 17 днів тому +2

    I love your videos been watching non stop as i learn! There is one small thing i don't get in the video and hope some one can explain the take profit and stop loss numbers i don't understand what the numbers mean are they percent ? Moreover, if i want to make a higher take profit or a bigger stop loss what should i input. Last thing in mysize = 0.1 does this mean 10% of capital ? please help :D

    • @CodeTradingCafe
      @CodeTradingCafe  13 днів тому +1

      Hi, yes 0.1 lot size means 10% of equity. and for SL and TP these are the price levels where you want to exit.

  • @mayurdoifode6745
    @mayurdoifode6745 14 днів тому +1

    Great video! I was looking for a multi-asset trading straterg but for intraday on 5min timeframes.
    Will this stratergy work for the same? Any other stratergy you can recommend for the same?

    • @CodeTradingCafe
      @CodeTradingCafe  13 днів тому

      Hi, no actually the strategy I used is just an example I didn't test it thoroughly enough.

  • @Sam-tg4ii
    @Sam-tg4ii 27 днів тому +1

    13:45. Thanks for the awesome videos. Can you elaborate on how to choose a commission value? Is that a fraction of trade PnL? Let's say the commission for trading SPY is 0 but the commission to trade emini ES is $5. How to choose the commission number in the code to simulate $5 per round trade?

    • @CodeTradingCafe
      @CodeTradingCafe  25 днів тому +1

      Hi, thank you for your support. The commission implementation depends on the library we use. Here Backtesting.py uses commission in pips units not in currency unit so it's hard to simulate exactly 5$. In their documentation they mentioned for Forex as an example 0.0002 is a good number to simulate spread so that's 2 pips per trade. I hope this clarifies a bit, but I understand the way you need to apply it is a bit different I will look again into their documentation maybe I have missed another way for commissions.

  • @2casperik
    @2casperik Місяць тому +2

    Hi. Nice channael. Can you write a script for nadaraya watson envelope?

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому

      Yes sure, I will try soon enough, but might take some time.

  • @agxgaming2327
    @agxgaming2327 Місяць тому +1

    bro you tell about best platform for learn this advance like strategy by using python and which platform is best and where how to learn all think which course is best for make this own strategy .

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому

      Hi I have some courses on Udemy check the coupons in the description. And follow my channel :)

  • @deekshitpatel4647
    @deekshitpatel4647 Місяць тому +1

    Hello sir
    We can code indicators and male a strategy but can you please make a video on
    VOLATILITY CONTRACTION PATTERN OF MARK MIVERNI IN PYTHON

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому

      Hi I will add it to the list, thank you for the idea.

  • @SalemAdedipe-j4z
    @SalemAdedipe-j4z Місяць тому +1

    Hello?
    Trust you're doing good?
    Good work here.
    Please I have a request.
    Been trying for months now to create an automated trading system strictly and focused on ICT model
    Technically ICT is wide but [ Time of the day and silver bullet strategy ] is enough for intraday trading.
    I really appreciate if you do something towards this two strategies
    No matter what method you use, I will follow as long as it works.
    Thank you

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому +1

      Hi, thank you. I will add it to my list it has been requested before.

  • @rotherhiteboy
    @rotherhiteboy Місяць тому +4

    What software and broker are you using?

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому +2

      I use python, with VSCode for the coding interface. Broker is Oanda for testing the strategies using their python API for live trading.

    • @rotherhiteboy
      @rotherhiteboy Місяць тому

      @@CodeTradingCafe are you using the oanda's trading platform?

    • @rotherhiteboy
      @rotherhiteboy Місяць тому +1

      @@CodeTradingCafe are you using the oanda's trading platform?

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому

      Yes for Python strategies testing

  • @kazutokirigaya6820
    @kazutokirigaya6820 Місяць тому +1

    Do these strategies work on daily candles, i use a simple strategy using bbands and vwap, it's profitable but showing only 5-6 trades in a year for one stock. I am thinking of selecting 10 stocks. What do you suggest, will this many signals normal when using daily candles?

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому

      Hi, yes I agree some good selective signals are not as frequent you can run the same strategy on let's say 20 assets in parallel so you get more signals. For sure you need to backtest it first. Just one thing using VWAP on the daily timeframe you might need to adjust the volume reset duration.

  • @popescugeorgebogdan5766
    @popescugeorgebogdan5766 21 день тому +1

    0.0002% comission where do you get that comission?

    • @CodeTradingCafe
      @CodeTradingCafe  21 день тому

      Hi, from backtesting documentation (it's on their webpage) this is an average estimate of spread difference only so it doesn't really include trading fees except for price differences.

    • @popescugeorgebogdan5766
      @popescugeorgebogdan5766 20 днів тому

      @@CodeTradingCafe YES, the total fees are much higher than 0.0002% I test my strategies with 0.3% wich tradingview backtesting charges twice that fee at open and at close which is normal, so total fee 0.6% per trade. I don`t know if your python strategy charges it twice (running bots with limit orders and only for opening of the trade it`s not a good ideea, tested that), you have fees for opening the trade (4$ per lot in average), funding fees (or SWAP fees), and spread to take into account. If I open a trade in my funded account with 100$ stop loss the unrealized profit is from the start -8$ in average.

  • @nkwebikarome4764
    @nkwebikarome4764 Місяць тому +2

    💥

  • @hepsser7399
    @hepsser7399 Місяць тому +1

    where can i find the .CSV files?

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому +1

      I just added a link for the data in the description, let me know if it works.

    • @hepsser7399
      @hepsser7399 Місяць тому +1

      @@CodeTradingCafe it worked, thank you so much!

  • @bertstroobant6020
    @bertstroobant6020 Місяць тому +1

    Anyone has some good documentation about simulated annealing for financial data. Been reading some thesisses about the subject but no in depth information

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому +1

      Hi, this is a challenging topic, it's possible to conquer but the questions is always is it worth the effort"? what do you think?

    • @bertstroobant6020
      @bertstroobant6020 Місяць тому +1

      @@CodeTradingCafe i would say it's worth the effort. You will (very likely) have no positive result but the knowledge, the way if thinking you learn during your research is possible worth more than the result.

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому

      I agree with this, plus I learned that "you never really know" sometimes we can be surprised.

  • @Dark_vibez...
    @Dark_vibez... Місяць тому +1

    Bro tell me a quotex api please

  • @Developers63
    @Developers63 Місяць тому +1

    النبي عيسى سوف ينزل في المسجد القصى و وساحته تعتبر كافية لجيشه

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому

      No doubt... maybe... but until then I will be coding strategies :)

    • @Developers63
      @Developers63 Місяць тому

      @@CodeTradingCafe 😂😂😂😂 no this video ,i don't know how

  • @artnone1257
    @artnone1257 Місяць тому +1

    How about crypto currencies? Is that indicator gonna work well with them? I want to to try similar strategy with multiple crypto assets

    • @CodeTradingCafe
      @CodeTradingCafe  Місяць тому

      Hi, you can try it, I actually could involve some crypto in coming videos, might be interesting.