Awesome - thanks for your great videos :) This is exactly what I was looking for. I would be very happy if you could create even more videos for the 'Python for Finance' playlist
Thanks a lot for your comment. Great to hear :-) Happy to announce that there will be more videos in the future for the Python for finance playlist. Best regards
@@Algovibes I'm trying to understand your code also from a theoretical point of view. However, I have some problems (e.g., why are the returns calculated as you show). Do you know a good reference? Maybe in a tutorial style? I skimmed through the original paper by Fama and French, and it was not detailed enough for me :-/
Thanks mate :-) The MOM factor can be found on Ken Frenchs page. You will need to add it as an additional column and run the regression again. BTW I have some videos on momentum. You might find them interesting as well.
Great video man, very straightforward & easy to digest your stuffs :). I have concerns about the case if all three beta of 3 factors are significant (p-value
Thanks man, appreciate your kind words. Regarding your questions: They are all covered with examples here -> www.efficientfrontier.com/ef/101/roll101.htm Additionally: The higher (positive) the alpha - the better.
@@Algovibes Thanks for the link, I can easily answer myself after reading it :). Could you make a video about combining other alpha such as momentum, mean reversion with the 3FM
Hi, perhaps a silly question, but do you have a video/resources as to how someone can make the factors data from raw data (price data, size, etc.)? I am referring to the SMB, HML F_F dataset that you have downloaded with directly with the DataReader? - Thank you in advance
Thanks for the video, clear explanation. One question. Do you think we consider more variables in the model? Let's think about Amazon, we can add features like number of products sold per month, number of positive reviews per month, and so on? So the theory could be to expand the model with new features not related with finance.
Welcome man! Thanks for watching. Sure, but then it wouldn't be the Fama French model anymore :P There are already extensions to the model (Carhart, FF5, etc.) but ofc you can build a regression model with other factors. Let me know when you find a good one! ;-)
Thank you for your video! Is this code applicable to a separate stock (not fund)? If I am doing this for AAPL, for example, the SMB factor becomes insignificant
Thanks for your fantastic video, which fully explained the Fama-french coding in python. However, do you mind digging deeper into the interpretation of the OLS results?
@@Algovibes the coding is perfect, I’m just wondering if you can talk more about the last part of your video which is the interpretation of the OLS result. Because I found it difficult to analyze and interpret the result. For example, what is the meaning of 275.3 on F-statistics? Why the p values of Mkt-RF and HML are zero?...
@@WaiWaiG0r Thanks a lot :) I noted a video on the interpretation for the OLS regression. Might take some time as I am planning on some other stuff before but I think that could be pretty interesting. The p-values show that both the market and the HML factor are highly significant. In general it holds: The lower the p-value the more significant a coefficient. As we try to explain the return of the funds at least our pulled data suggests that it is nearly impossible to say that we have 0 effect on the return considering these two coefficients. So why are they zero in simple words? Because they have an effect on the assets (funds) return.
Thank you for a great video! However I have some questions. I'm currently doing a project where I'm going to test the model on two market conditions, unstable and stable on the Swedish Stock Market. Unlike you I will not use an ETF but instead I want to use returns of individual assets (about 200-250 per year) who are listed on the Large Cap list of Stockholm. The factor-values will be obtained from Stockholm School of Economics data base (SHoFDB). My question is, how do I get all of this stock returns in to Python? And when I have the stock returns in python, can I follow the steps in your video or will the procedure looks different? Again, thanks for a great video!
Hi, thanks a lot for watching and your kind comment :-) Your project sounds really cool. To get the returns you could work with a SQL database maybe? Use the return files (I assume they are csvs), read them in with pandas and store them in a DB. Or just read them in within the script but this will be pretty inefficient. Regarding the intersection between python and SQL you can check out my vid on building a finance database: ua-cam.com/video/5bUn-D4eL4k/v-deo.html Without knowing what exactly your approach will be: the steps should be pretty similar if you have the factor values yes. Only thing you would need to amend is to functionalize it so that you can run the regression for every stock in a loop or similar.
Hi, could you explain to me how to find all the available datasets (not only this one from Fama-French) using the get_available function? Thank you very much!!
@@Algovibes Thank you for your help! Learning a lot of new things, very useful reading and trying to understand documentations for every package. Could you please consider making a video on trading strategies with multiple conditions for signals (like entry trigger, take profit, and SL)?
Never apologize for a question and this question is not necessarily an easy one! We set up an equation which is explaining the return of an asset. The return can be explained by the factors but also with an unexplained part which is the alpha. In Asset Management this alpha is important as it basically shows how the funds manager was doing his job. To break it down really simple: If he was performing well it could be due to the fact that the market performed good (Market factor). But it could also be due to the fact he overweighted growth stocks or small caps (the other two factors). But if he generated alpha even though we account for those factors he would probably doing a pretty good job. I hope this makes sense to you!
@@Algovibes So your saying is that (to put it to the extreme,) if the market didn't performed well and he didn't overweighted growth stocks nor the small caps and yet if there was still an excess return, this excess return is explained by the alpha? Thank you so much for this amazing video. Can't wait for more contents:)
Hi , First of all thanks a loot for your videos. Second , would like to know about the fama French factors are they always to the same values of factors (of course depending on the number of factors...). In other terms , can I use the same factor data for other assets involving 3 factors fama French , is it like a fixed data that we could use with any asset ..? Thanks for your help. ps: Great content and very good explanations..;)
Thanks a lot for watching and your kind comment. Appreciate it :-) Usually you need to calculate the factors yourself. As the FDGRX is mainly invested in American stocks I am going the easy way and take the factors provided by Ken French. These factors are calculated over all CRSP stocks (more info: www.crsp.org/resources/data). To be 100% correct you would need to calculate the factors for a given dataset (in this case the FDGRX components). Taking a broad ETF mainly invested in America you can take Ken French factors as an estimate. The results will be comparable. Best regards
Hello there, first of all, thank you very much for this demonstration! It is very helpful. I do have a problem, though. When I type fundsret_mtl, I do not get the name of the company as you do. How can I fix this problem?
Hi Mustafa :-) Thanks a lot for your kind comment. Totally happy that it was helpful! The solution to both of your problems: When you are requesting the data do it with a list. So in my example you see that I am using funds = ["^FDGRX"] right under defining the start and end date in the very beginning. If you are not doing that you are getting a Series instead of a Dataframe and getting the undesired consequences. Please let me know if that was solving your problem. Best regards :)
So if I want to annualize the alpha of the fund I just multiply the value of the constant by 12, because it is monthly data? And if I would have made the regression with daily data I would have to multiply the value of the constant with the number of the trading days in the year?
Hi there. need some help! I'm following your script to the letter with Python 3.8 Not sure why when I call famafench it doesn't call the file "reader.DataReader('F-F_Reasearch_Data_Factors', 'famafrench', start, end)" gives me an error: "RemoteDataError: Unable to read URL: mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Reasearch_Data_Factors_CSV.zip" perhaps, explain the data reader call, it may have changed source or name. I couldn't figure it out!
Hi mate, I just checked your problem and rewrote the code myself : No problems. Try using this exact syntax and check if you are getting the table: import pandas_datareader.data as reader import datetime as dt end = dt.date(2020,12,31) start = dt.date(end.year - 5, end.month, end.day) reader.DataReader('F-F_Research_Data_Factors','famafrench', start, end)[0] Please let me know if you still have problems. Sometimes it is btw just that you have no internet connection. Experienced that many times. best regards and thank you very much for watching :-)
@@Algovibes Below is the whole thing and try it again and same error. I gather that It cannot read the file for some reason. Perhaps I am missing a module??? ****************** CODE ************************ import pandas_datareader.data as reader import pandas as pd import datetime as dt import statsmodels.api as sm end = dt.date(2020,12,31) start = dt.date(end.year - 5, end.month, end.day) fund = ['FDGRX'] fundsret = reader.get_data_yahoo(fund, start, end)['Adj Close'].pct_change() fundsret_mtl = fundsret.resample('M').agg(lambda x: (x+1).prod() - 1) # up to here all runs good! factors = reader.DataReader('F-F_Reasearch_Data_Factors', 'famafrench', start, end) ****************** CODE ************************ OUTPUT: Traceback (most recent call last): File "", line 1, in factors = reader.DataReader('F-F_Reasearch_Data_Factors', 'famafrench', start, end) File "C:\Users\andres\anaconda3\lib\site-packages\pandas\util\_decorators.py", line 199, in wrapper return func(*args, **kwargs) File "C:\Users\andres\anaconda3\lib\site-packages\pandas_datareader\data.py", line 465, in DataReader return FamaFrenchReader( File "C:\Users\andres\anaconda3\lib\site-packages\pandas_datareader\famafrench.py", line 75, in read return super(FamaFrenchReader, self).read() File "C:\Users\andres\anaconda3\lib\site-packages\pandas_datareader\base.py", line 100, in read return self._read_one_data(self.url, self.params) File "C:\Users\andres\anaconda3\lib\site-packages\pandas_datareader\famafrench.py", line 101, in _read_one_data data = self._read_zipfile(url) File "C:\Users\andres\anaconda3\lib\site-packages\pandas_datareader\famafrench.py", line 55, in _read_zipfile raw = self._get_response(url).content File "C:\Users\andres\anaconda3\lib\site-packages\pandas_datareader\base.py", line 181, in _get_response raise RemoteDataError(msg) RemoteDataError: Unable to read URL: mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Reasearch_Data_Factors_CSV.zip Response Text: b'
404 - File or directory not found.
Server Error
404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
@@andreso4116 First of all sorry for the inconveniences you experienced but I think you just have a typo in your syntax: factors = reader.DataReader('F-F_Reasearch_Data_Factors', 'famafrench', start, end) -> get rid of the a -> Research_Data_Factors Let me know if this has solved your issue.
hey, any idea how we could create the SMB HML factors on our own (in python) from a excel spreadsheet with the relevant firm data, instead of copying it from french's website? If you have a tip where i can learn this i would be grateful, thanks
Hi First of all thank you very much for watching. To calculate the factors I would recommend sticking to the procedure from Fama French (alert: this is not going to be easy!). Check this link first: mba.tuck.dartmouth.edu/pages/faculty/ken.french/Data_Library/f-f_factors.html For an exact description of how you are building the portfolios check the paper 'Common risk factors in the returns on stocks and bonds' from Fama French: rady.ucsd.edu/faculty/directory/valkanov/pub/classes/mfe/docs/fama_french_jfe_1993.pdf Page 9 contains a pretty straightforward description on how portfolios are constructed. As a practical tip in Python to form portfolios I would suggest to use quantiles (I actually did that in my most recent video (Momentum strategy) with pandas if you need a technical hint on a very basic level). Would be nice to know if that was a helpful hint for you. I wish you good luck on your project :-) Best regards
@@Algovibes thanks for the answer, i already read the fama french papers and understand the theory, however the practical part is where im having a hard time. i just startet learning python for this and am still not sure how to code a model that sorts the stocks every year new, for multiple years and computes the return. Your momentum stategy video was helpful and i will definitely have a second closer look into the code you used.
I have the problem to import pandas_datareader. On the homepage of "datareader" was explained that pandas_datareader is no longer compatible to retrieve the data from Fama french. Do you have more information and do you have an alternative for me? Thanks in advance
Hi :) Well it works totally fine for me - just checked. Also checked the documentation again - data reader still compatible with Ken French data library. Could you link your source or just show your error message which is popping up? Thanks a lot in advance!
@@Algovibes Thanks for your quick message. Fortunately I was able to solve the problem. I now have a wide problem which I am currently trying to solve. I use several shares and my database is from Excel. All steps have worked so far except for the merge part. Line 50 in minute 14:56 -You write " merge["FDGRX-Rf"=merge.FDGRX-merge.RF My variant: merge ["BAC-RF", "FRD-RF", "FDX-RF", "WMT-RF"]=merge.BAC-merge.RF,merge.FRD-merge.RF,merge.FRD-merge.RF,merge.WMT-merge.RF Here you can see that I use several shares Here I get an error message: ValueError: Length of values does not match length of index localhost:8888/notebooks/Untitled1.ipynb Thanks for your help Johannes
@@johannesambaye7710 Could be a ton of possible reasons but I think in this case it is a simple syntax error. Use double brackets to solve it: merge [["BAC-RF", "FRD-RF", "FDX-RF", "WMT-RF"]] =merge.BAC-merge.RF,merge.FRD-merge.RF,merge.FRD-merge.RF,merge.WMT-merge.RF Please let me know if that has solved your problem. Otherwise share your full code so that I can help you out. Best regards :)
@@Algovibes Hi :), Unfortunately, it did not work. Here is the code and the error message, I hope you can do something with it. Thank you very much for the support. github.com/Johannes-90/Fama-French-/blob/main/Fama%20French%20-Copy1.ipynb
I waited too long for this comment, honestly! This video is pretty old, let me know if I improved on my English on my newer ones. Your feedback is appreciated!
Awesome - thanks for your great videos :) This is exactly what I was looking for. I would be very happy if you could create even more videos for the 'Python for Finance' playlist
Thanks a lot for your comment. Great to hear :-)
Happy to announce that there will be more videos in the future for the Python for finance playlist.
Best regards
@@Algovibes I'm trying to understand your code also from a theoretical point of view. However, I have some problems (e.g., why are the returns calculated as you show). Do you know a good reference? Maybe in a tutorial style? I skimmed through the original paper by Fama and French, and it was not detailed enough for me :-/
Thank you so much for explaining all this! It is a very helpful demonstration!
Thank you very much for your kind comment :) I am glad it was helpful.
Hello, I'm doing this regression on my strategy today. Very easy to undestand. Thanks you, master !
_________coef std err t P>|t| [0.025 0.975]
const 0.0475 0.010 4.764 0.000 0.028 0.067
quaterly results. pretty good
Thx a lot rraul
Followed the video and was able to replicate it. Thanks very much!
Awesome, thanks a lot for the feedback Lisa.
Amazing!
Thanks bud
Thanks so much for this! added to my favourites haha
Thanks for watching :-)
great video. thak you very much for your sharing.
Welcome mate!
what a g. great video man.
Hi mate,
thank you very much for your kind comment. Very happy that you like it :-)
very good work ... thank you
Thanks a lot for watching and your comment. I appreciate it :-)
really good video! well explained and not leaving out any details
Hi Jens,
thank you so much for your feedback!
Happy to have you on my channel :)
Amazing work, is it possible to also create a time series graph of the factor loading?
Thanks buddy. Sure, you could just plot the columns containing the factors.
wonderful video. can you please suggest the python codes to add MOM factor into this (Carhart model)
Thanks mate :-)
The MOM factor can be found on Ken Frenchs page. You will need to add it as an additional column and run the regression again.
BTW I have some videos on momentum. You might find them interesting as well.
@@Algovibes Thanks brother.
Great video man, very straightforward & easy to digest your stuffs :).
I have concerns about the case if all three beta of 3 factors are significant (p-value
Thanks man, appreciate your kind words.
Regarding your questions: They are all covered with examples here -> www.efficientfrontier.com/ef/101/roll101.htm
Additionally: The higher (positive) the alpha - the better.
@@Algovibes Thanks for the link, I can easily answer myself after reading it :).
Could you make a video about combining other alpha such as momentum, mean reversion with the 3FM
Hi, perhaps a silly question, but do you have a video/resources as to how someone can make the factors data from raw data (price data, size, etc.)? I am referring to the SMB, HML F_F dataset that you have downloaded with directly with the DataReader? - Thank you in advance
I don't but I keep my fingers crossed you setting this up. That would be quite interesting!
Thank you!
привет and thanks for watching!
пожалуйста :-)
When the data is time series, can we use normal regression for performing this analysis?
Not quite sure about the question as the data shown in the video is a time series. Can you elaborate?
Hey could you maybe send me the code, Im really struggling and I really need it for my thesis, thanks in advance, I would really appreciate your help
Thanks for the video, clear explanation.
One question. Do you think we consider more variables in the model? Let's think about Amazon, we can add features like number of products sold per month, number of positive reviews per month, and so on? So the theory could be to expand the model with new features not related with finance.
Welcome man! Thanks for watching. Sure, but then it wouldn't be the Fama French model anymore :P There are already extensions to the model (Carhart, FF5, etc.) but ofc you can build a regression model with other factors. Let me know when you find a good one! ;-)
You are fantastic, thank you 😊
Thanks a lot for your comment. I really appreciate it :-)
Thank you for your video! Is this code applicable to a separate stock (not fund)? If I am doing this for AAPL, for example, the SMB factor becomes insignificant
IS there a simpler version to calculate a monthly stock return other than using resample("M").agg(lambda x:(x+1).prod()-1) ? Thank you.
Yes,
explained that in detail here:
ua-cam.com/video/fWHQwqT3lNY/v-deo.html
cheers buddy
Thanks for your fantastic video, which fully explained the Fama-french coding in python. However, do you mind digging deeper into the interpretation of the OLS results?
Thanks a lot for watching and your kind comment :-)
Sure, what do you want to know or where did I not go into deep enough?
@@Algovibes the coding is perfect, I’m just wondering if you can talk more about the last part of your video which is the interpretation of the OLS result. Because I found it difficult to analyze and interpret the result. For example, what is the meaning of 275.3 on F-statistics? Why the p values of Mkt-RF and HML are zero?...
@@WaiWaiG0r Thanks a lot :)
I noted a video on the interpretation for the OLS regression. Might take some time as I am planning on some other stuff before but I think that could be pretty interesting.
The p-values show that both the market and the HML factor are highly significant.
In general it holds: The lower the p-value the more significant a coefficient.
As we try to explain the return of the funds at least our pulled data suggests that it is nearly impossible to say that we have 0 effect on the return considering these two coefficients.
So why are they zero in simple words? Because they have an effect on the assets (funds) return.
Thank you for a great video!
However I have some questions. I'm currently doing a project where I'm going to test the model on two market conditions, unstable and stable on the Swedish Stock Market. Unlike you I will not use an ETF but instead I want to use returns of individual assets (about 200-250 per year) who are listed on the Large Cap list of Stockholm. The factor-values will be obtained from Stockholm School of Economics data base (SHoFDB). My question is, how do I get all of this stock returns in to Python? And when I have the stock returns in python, can I follow the steps in your video or will the procedure looks different?
Again, thanks for a great video!
Hi, thanks a lot for watching and your kind comment :-)
Your project sounds really cool. To get the returns you could work with a SQL database maybe? Use the return files (I assume they are csvs), read them in with pandas and store them in a DB. Or just read them in within the script but this will be pretty inefficient.
Regarding the intersection between python and SQL you can check out my vid on building a finance database: ua-cam.com/video/5bUn-D4eL4k/v-deo.html
Without knowing what exactly your approach will be: the steps should be pretty similar if you have the factor values yes.
Only thing you would need to amend is to functionalize it so that you can run the regression for every stock in a loop or similar.
Thank you for your answear!
Is it possible for me to contact you via email?
@@marcuseinstulen2655 Not yet but I will set up a mail in the info tab soon.
Hi, could you explain to me how to find all the available datasets (not only this one from Fama-French) using the get_available function? Thank you very much!!
Jep they are listed in the docs. Chapter 2.1.8 buildmedia.readthedocs.org/media/pdf/pandas-datareader/latest/pandas-datareader.pdf
@@Algovibes Thank you for your help! Learning a lot of new things, very useful reading and trying to understand documentations for every package. Could you please consider making a video on trading strategies with multiple conditions for signals (like entry trigger, take profit, and SL)?
sorry for the simple question, but can you explain more about the alpha? my algorithm came out alpha negative. What does it imply??
what does it mean to have "a positive performance over the risk of 3 fama-french factor"?
Never apologize for a question and this question is not necessarily an easy one!
We set up an equation which is explaining the return of an asset. The return can be explained by the factors but also with an unexplained part which is the alpha.
In Asset Management this alpha is important as it basically shows how the funds manager was doing his job.
To break it down really simple: If he was performing well it could be due to the fact that the market performed good (Market factor). But it could also be due to the fact he overweighted growth stocks or small caps (the other two factors). But if he generated alpha even though we account for those factors he would probably doing a pretty good job.
I hope this makes sense to you!
@@Algovibes So your saying is that (to put it to the extreme,) if the market didn't performed well and he didn't overweighted growth stocks nor the small caps and yet if there was still an excess return, this excess return is explained by the alpha? Thank you so much for this amazing video. Can't wait for more contents:)
Hi ,
First of all thanks a loot for your videos.
Second , would like to know about the fama French factors are they always to the same values of factors (of course depending on the number of factors...). In other terms , can I use the same factor data for other assets involving 3 factors fama French , is it like a fixed data that we could use with any asset ..?
Thanks for your help.
ps: Great content and very good explanations..;)
Thanks a lot for watching and your kind comment. Appreciate it :-)
Usually you need to calculate the factors yourself. As the FDGRX is mainly invested in American stocks I am going the easy way and take the factors provided by Ken French. These factors are calculated over all CRSP stocks (more info: www.crsp.org/resources/data). To be 100% correct you would need to calculate the factors for a given dataset (in this case the FDGRX components). Taking a broad ETF mainly invested in America you can take Ken French factors as an estimate. The results will be comparable.
Best regards
@@Algovibes "Usually you need to calculate the factors yourself"
@@ihebbibani7122 ? :-D
Hello, thanks for the video ! I have tested several ticker but I keep having a R² below 50% :( Any idea how to improve the model ?
Super generous
:-) Thanks for watching and your comment. Appreciate it!
Hello there, first of all, thank you very much for this demonstration! It is very helpful.
I do have a problem, though. When I type fundsret_mtl, I do not get the name of the company as you do. How can I fix this problem?
And also, when I type Merge I get Adj Close instead of the stock name
Hi Mustafa :-)
Thanks a lot for your kind comment. Totally happy that it was helpful!
The solution to both of your problems:
When you are requesting the data do it with a list.
So in my example you see that I am using funds = ["^FDGRX"]
right under defining the start and end date in the very beginning.
If you are not doing that you are getting a Series instead of a Dataframe and getting the undesired consequences.
Please let me know if that was solving your problem.
Best regards :)
Thank you very much for the fast reply. I actually managed to fix the problem just after I commented :)
So if I want to annualize the alpha of the fund I just multiply the value of the constant by 12, because it is monthly data? And if I would have made the regression with daily data I would have to multiply the value of the constant with the number of the trading days in the year?
Hi there. need some help!
I'm following your script to the letter with Python 3.8
Not sure why when I call famafench it doesn't call the file
"reader.DataReader('F-F_Reasearch_Data_Factors', 'famafrench', start, end)"
gives me an error:
"RemoteDataError: Unable to read URL: mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Reasearch_Data_Factors_CSV.zip"
perhaps, explain the data reader call, it may have changed source or name. I couldn't figure it out!
Hi mate,
I just checked your problem and rewrote the code myself : No problems.
Try using this exact syntax and check if you are getting the table:
import pandas_datareader.data as reader
import datetime as dt
end = dt.date(2020,12,31)
start = dt.date(end.year - 5, end.month, end.day)
reader.DataReader('F-F_Research_Data_Factors','famafrench', start, end)[0]
Please let me know if you still have problems. Sometimes it is btw just that you have no internet connection. Experienced that many times.
best regards and thank you very much for watching :-)
@@Algovibes
Below is the whole thing and try it again and same error.
I gather that It cannot read the file for some reason. Perhaps I am missing a module???
****************** CODE ************************
import pandas_datareader.data as reader
import pandas as pd
import datetime as dt
import statsmodels.api as sm
end = dt.date(2020,12,31)
start = dt.date(end.year - 5, end.month, end.day)
fund = ['FDGRX']
fundsret = reader.get_data_yahoo(fund, start, end)['Adj Close'].pct_change()
fundsret_mtl = fundsret.resample('M').agg(lambda x: (x+1).prod() - 1)
# up to here all runs good!
factors = reader.DataReader('F-F_Reasearch_Data_Factors', 'famafrench', start, end)
****************** CODE ************************
OUTPUT:
Traceback (most recent call last):
File "", line 1, in
factors = reader.DataReader('F-F_Reasearch_Data_Factors', 'famafrench', start, end)
File "C:\Users\andres\anaconda3\lib\site-packages\pandas\util\_decorators.py", line 199, in wrapper
return func(*args, **kwargs)
File "C:\Users\andres\anaconda3\lib\site-packages\pandas_datareader\data.py", line 465, in DataReader
return FamaFrenchReader(
File "C:\Users\andres\anaconda3\lib\site-packages\pandas_datareader\famafrench.py", line 75, in read
return super(FamaFrenchReader, self).read()
File "C:\Users\andres\anaconda3\lib\site-packages\pandas_datareader\base.py", line 100, in read
return self._read_one_data(self.url, self.params)
File "C:\Users\andres\anaconda3\lib\site-packages\pandas_datareader\famafrench.py", line 101, in _read_one_data
data = self._read_zipfile(url)
File "C:\Users\andres\anaconda3\lib\site-packages\pandas_datareader\famafrench.py", line 55, in _read_zipfile
raw = self._get_response(url).content
File "C:\Users\andres\anaconda3\lib\site-packages\pandas_datareader\base.py", line 181, in _get_response
raise RemoteDataError(msg)
RemoteDataError: Unable to read URL: mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Reasearch_Data_Factors_CSV.zip
Response Text:
b'
404 - File or directory not found.
Server Error
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
'
@@andreso4116
First of all sorry for the inconveniences you experienced but I think you just have a typo in your syntax:
factors = reader.DataReader('F-F_Reasearch_Data_Factors', 'famafrench', start, end)
-> get rid of the a -> Research_Data_Factors
Let me know if this has solved your issue.
hey, any idea how we could create the SMB HML factors on our own (in python) from a excel spreadsheet with the relevant firm data, instead of copying it from french's website? If you have a tip where i can learn this i would be grateful, thanks
Hi
First of all thank you very much for watching.
To calculate the factors I would recommend sticking to the procedure from Fama French (alert: this is not going to be easy!).
Check this link first:
mba.tuck.dartmouth.edu/pages/faculty/ken.french/Data_Library/f-f_factors.html
For an exact description of how you are building the portfolios check the paper 'Common risk factors in the returns on stocks and bonds' from Fama French:
rady.ucsd.edu/faculty/directory/valkanov/pub/classes/mfe/docs/fama_french_jfe_1993.pdf
Page 9 contains a pretty straightforward description on how portfolios are constructed.
As a practical tip in Python to form portfolios I would suggest to use quantiles (I actually did that in my most recent video (Momentum strategy) with pandas if you need a technical hint on a very basic level).
Would be nice to know if that was a helpful hint for you.
I wish you good luck on your project :-)
Best regards
@@Algovibes thanks for the answer, i already read the fama french papers and understand the theory, however the practical part is where im having a hard time. i just startet learning python for this and am still not sure how to code a model that sorts the stocks every year new, for multiple years and computes the return. Your momentum stategy video was helpful and i will definitely have a second closer look into the code you used.
WHY SHOULD WE DO THE FACTORING
Sorry can you elaborate?
I have the problem to import pandas_datareader. On the homepage of "datareader" was explained that pandas_datareader is no longer compatible to retrieve the data from Fama french. Do you have more information and do you have an alternative for me?
Thanks in advance
Hi :)
Well it works totally fine for me - just checked. Also checked the documentation again - data reader still compatible with Ken French data library.
Could you link your source or just show your error message which is popping up?
Thanks a lot in advance!
@@Algovibes
Thanks for your quick message. Fortunately I was able to solve the problem. I now have a wide problem which I am currently trying to solve. I use several shares and my database is from Excel. All steps have worked so far except for the merge part.
Line 50 in minute 14:56 -You write " merge["FDGRX-Rf"=merge.FDGRX-merge.RF
My variant: merge ["BAC-RF", "FRD-RF", "FDX-RF", "WMT-RF"]=merge.BAC-merge.RF,merge.FRD-merge.RF,merge.FRD-merge.RF,merge.WMT-merge.RF
Here you can see that I use several shares
Here I get an error message: ValueError: Length of values does not match length of index
localhost:8888/notebooks/Untitled1.ipynb
Thanks for your help
Johannes
@@johannesambaye7710
Could be a ton of possible reasons but I think in this case it is a simple syntax error.
Use double brackets to solve it:
merge [["BAC-RF", "FRD-RF", "FDX-RF", "WMT-RF"]] =merge.BAC-merge.RF,merge.FRD-merge.RF,merge.FRD-merge.RF,merge.WMT-merge.RF
Please let me know if that has solved your problem. Otherwise share your full code so that I can help you out.
Best regards :)
@@Algovibes
Hi :),
Unfortunately, it did not work. Here is the code and the error message, I hope you can do something with it. Thank you very much for the support.
github.com/Johannes-90/Fama-French-/blob/main/Fama%20French%20-Copy1.ipynb
I have managed to run individual regressions with the different stocks, but packing all stocks into one regression was not possible.
Variable not wariable.
Subtract not substract
I waited too long for this comment, honestly!
This video is pretty old, let me know if I improved on my English on my newer ones.
Your feedback is appreciated!