tatsath / fin-ml

This github repository of "Machine Learning and Data Science Blueprints for Finance". Please star.
805 stars 395 forks source link

Chapter 7, Do the portfolio's which have negative weights for stocks like weights[1] mean to sell those? #5

Open cody-vandervoort opened 3 years ago

cody-vandervoort commented 3 years ago

Hi i just wanted to clarify if for example portfolio 2 / weights[2] which has negative weights does that mean in the portfolio its meant to be a sell with such a weight?

example : weights WMT 154.600 HD 98.409 WBA 83.098 INTC 73.599 MRK 70.360 PG 69.292 VZ 67.323 KO 63.387 CSCO 59.287 PFE 57.201 MSFT 54.698 JNJ 50.306 MCD 50.279 IBM 39.230 NKE 32.219 AAPL 26.293 DIS 26.185 AXP -3.605 TRV -16.914 UNH -32.764 JPM -35.070 GS -53.526 MMM -64.635 BA -78.023 UTX -83.237 CAT -133.755 XOM -225.916 CVX -248.319

or do the negative numbers just mean do nothing with them?

cody-vandervoort commented 3 years ago

Also when looking at the returns for weights[1] Current Eigen-Portfolio: Return = 99.80% Volatility = 58.34% Sharpe = 1.71

on the actual chart the graph goes all the way up to 8+ on the y axis, therefore I am confused how this 8 aligns with the 99% return, is this a 99% return year over year resulting in 8x return? or how do i define this clearer?

cody-vandervoort commented 3 years ago

Also a question about the linear regression stock predictions, is there a way to convert the returns into the actual predicted number/price for the specific time period, from what im thinking one could multiply the starting price by each row im just unsure how to write the code to do this, im just thinking in order to fit the problem to smaller time scales, but i guess i could just use a calculator manually but would be cool to automate the process ie; (2020-05-01 1.003 2020-05-08 1.013 2020-05-15 1.014 2020-05-22 1.025 2020-06-02 1.037 2020-06-09 1.051 2020-06-16 1.053 2020-06-23 1.058 2020-06-30 1.066 2020-07-08 1.070 2020-07-16 1.082 2020-07-23 1.092 2020-07-30 1.099 2020-08-06 1.114 2020-08-13 1.121 2020-08-20 1.126 2020-08-27 1.137 2020-09-03 1.143 2020-09-11 1.150 2020-09-21 1.155 2020-09-28 1.166 2020-10-05 1.176 2020-10-13 1.188 2020-10-21 1.186 2020-10-28 1.187 2020-11-04 1.193 2020-11-12 1.202 2020-11-20 1.210 2020-12-01 1.218 2020-12-10 1.230 2020-12-17 1.244 2020-12-28 1.251 2021-01-06 1.263 2021-01-14 1.274 2021-01-26 1.277 2021-02-03 1.275 2021-02-10 1.288 2021-02-18 1.295 2021-02-26 1.300 2021-03-05 1.306 2021-03-12 1.324 2021-03-19 1.332 2021-03-26 1.347 2021-04-05 1.353 2021-04-13 1.364

cody-vandervoort commented 3 years ago

does this mean to short the negatives or not include them completely in the portfolio? also could i please reference your book in my book, I have been granted permission from Dr Yves Hilspisch to use a couple quotes from his books in mine, would you mind if i did the same with yours, as I feel this book was of a high standard versus what is currently on the market and i would like to pull a few quotes from your introductory section if possible, while also pointing readers to your book for further reference would that be okay?

weiqingren commented 2 years ago

eigen_prti_returns = np.dot(X_train_raw.loc[:, eigen_prtfi.index], pc_w)

after sorting the indices in eigen_prtfi.index (in the previous step), the stocks in X_train_raw.loc[:, eigen_prtfi.index] don't match with the weights in pc_w. Don't understand this.

This way the results depend on how the stocks are arranged in the dataset.