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...
this channel is a gem
Thank you so much!
Truly is I love his videos
Thank you very much as always for the turtorials!
Glad you like them! Thanks a lot for your support.
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.
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.
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
Hey Vassilis thank you so much. So far so good for the situation hopefully it will not escalate, meanwhile we can still code :)
I have implemented this whole strategy will run it for the next couple of months and might update here if good things happen
Thank you, it would be of great help :)
Would you consider testing on the 4hr bar and 60m bar for shorter time frames for more of a swing model?
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!
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?
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.
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
Give yourself time (months) you will start feeling comfortable soon enough. Good luck!
@@CodeTradingCafe okey thank you
Realy good work, nice video.
Thank you very much! Glad you liked it.
Saw this live 🔥🔥
Thank you for your support
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
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.
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?
Hi, no actually the strategy I used is just an example I didn't test it thoroughly enough.
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?
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.
Hi. Nice channael. Can you write a script for nadaraya watson envelope?
Yes sure, I will try soon enough, but might take some time.
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 .
Hi I have some courses on Udemy check the coupons in the description. And follow my channel :)
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
Hi I will add it to the list, thank you for the idea.
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
Hi, thank you. I will add it to my list it has been requested before.
What software and broker are you using?
I use python, with VSCode for the coding interface. Broker is Oanda for testing the strategies using their python API for live trading.
@@CodeTradingCafe are you using the oanda's trading platform?
@@CodeTradingCafe are you using the oanda's trading platform?
Yes for Python strategies testing
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?
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.
0.0002% comission where do you get that comission?
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.
@@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.
💥
Thank you for your support.
where can i find the .CSV files?
I just added a link for the data in the description, let me know if it works.
@@CodeTradingCafe it worked, thank you so much!
Anyone has some good documentation about simulated annealing for financial data. Been reading some thesisses about the subject but no in depth information
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?
@@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.
I agree with this, plus I learned that "you never really know" sometimes we can be surprised.
Bro tell me a quotex api please
Hi, sorry I don't use quotex
النبي عيسى سوف ينزل في المسجد القصى و وساحته تعتبر كافية لجيشه
No doubt... maybe... but until then I will be coding strategies :)
@@CodeTradingCafe 😂😂😂😂 no this video ,i don't know how
How about crypto currencies? Is that indicator gonna work well with them? I want to to try similar strategy with multiple crypto assets
Hi, you can try it, I actually could involve some crypto in coming videos, might be interesting.