Тёмный

How to Backtest Trading Algorithms and Portfolio Metrics with Python and QuantStats 

Matt Macarty
Подписаться 28 тыс.
Просмотров 11 тыс.
50% 1

Опубликовано:

 

8 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 26   
@xt8382
@xt8382 Год назад
Very high quality video, great job Sir!!
@MattMacarty
@MattMacarty Год назад
Glad you liked it!
@aarondelarosa3146
@aarondelarosa3146 Год назад
Excellent.
@MattMacarty
@MattMacarty Год назад
Glad it helped.
@gabrielbarwick9547
@gabrielbarwick9547 2 месяца назад
Hi, great video, for the last one, would you need to add shift() after the mean() so that it doesnt use future data?
@MattMacarty
@MattMacarty Месяц назад
Glad it helped. I don't thinnk there is any look ahead bias there.
@ngoduyvu
@ngoduyvu Год назад
Very interesting
@MattMacarty
@MattMacarty Год назад
Glad it helped
@jordanfong4255
@jordanfong4255 Год назад
love the content, keep it up! :)
@MattMacarty
@MattMacarty Год назад
Thank you
@kuatroka
@kuatroka Год назад
Thanks for the tut. One question, is there a way to get portfolio metrics calculated on a list of actual transactions? Like a csv with date, ticker, buy/sell, price, quantity...
@MattMacarty
@MattMacarty Год назад
Yes, when you call the metrics function you can set display=False
@kuatroka
@kuatroka Год назад
@@MattMacarty thanks and where I could I see the csv format so I can tailor mine and in which function to load it?
@revenge9431
@revenge9431 Год назад
Thanks for the video, I cut and pasted your Strategy file from github into Jupyter notebook and here is what i am getting: TypeError: string indices must be integers Any ideas, how to fix this? thanks!
@MattMacarty
@MattMacarty Год назад
This probably doesn't work well in a notebook. So I would use something like PyCharm or VS Code. For the error it looks like Yahoo has changed their API (again) and the datareader hasn't caught up. Replace data reader with yfinance: import yfinance as yf then instead of pdr.get_data_yahoo(... use yf.download(... I will update the code. You will probably need to install yfinance
@OrchidMacro
@OrchidMacro 2 месяца назад
Awesome, can you share the Jupyter notebook?
@tracywang1
@tracywang1 6 месяцев назад
Thanks for sharing. However, I got a question: In your gold fast slow strategy, you short gld when fast below slow and records the negative daily return. Say day 1 the stock goes up 10%, day 2 goes up 10% agian, then long position is (1+10%)*(1+10*) that's correct however, if I short, then my cumulative return is not (1-10%)*(1-10%) it should be somethinglike (1-10%)* (1-12%) I found a lot of tutorials do it this way while I think is wrong, can you shed some light? Thanks!
@MattMacarty
@MattMacarty 6 месяцев назад
So you should actually use the natural log of .9 to get the correct answer. You are right the traditional percent change learned in school only works for a single day. Percent change is always more optimistic than the LN, or instantaneous rate of return.
@user-ws9xl1gk4k
@user-ws9xl1gk4k Год назад
how to change the risk free rate in the report/calculation?
@MattMacarty
@MattMacarty Год назад
I think it's in metrics. Something like metrics['Risk-Free Rate %'] = xx
@jaspernooten1639
@jaspernooten1639 Год назад
why do you take the logarithm of the difference in Closing prices?(in your last example).
@MattMacarty
@MattMacarty Год назад
That's called the instantaeous rate of return and is used in pricing/valuing securities
@jaspernooten1639
@jaspernooten1639 Год назад
@@MattMacarty thanks! and I think in the last example, the strategy cumulative returns graph is shifted downwards (by the cumulate return of the first 21 days) because strategy starts 21 days later. So the strategy-benchmark comparison is not truly fair as it covers a different time period. I think also the calculation of the slow and fast mean by dataframe.rolling() needs to be shifted by 1, because now the strategy for the current day is calculated based on the closing price from that same day, making the algorithm clairvoyant. (e.g. when the 'fast' mean approaches 1 day the returns increase)
@Jopena-hf5qv
@Jopena-hf5qv Год назад
should be better without black board
@MattMacarty
@MattMacarty Год назад
Do you mean the color scheme in the IDE? The file is on Github if you want to run it on your machine: github.com/mjmacarty/algorithmic-trading
Далее
QuantStats: Portfolio Analytics with Python Tutorial
37:20
Прохожу маску ЭМОЦИИ🙀 #юмор
00:59
Сказала дочке НЕТ!
00:24
Просмотров 1,1 млн
Backtestiing From Scratch
50:44
Просмотров 2,3 тыс.
Прохожу маску ЭМОЦИИ🙀 #юмор
00:59