opentaps / open-climate-investing

Application and data for analyzing and structuring portfolios for climate investing.
https://climate-investing-book.opensourcestrategies.com/v/main/book
GNU Affero General Public License v3.0
42 stars 14 forks source link

modify bulk_script.py to generate results for list of stocks #3

Closed sichen1234 closed 2 years ago

sichen1234 commented 2 years ago

Modify the bulk_script.py to generate results for list of stocks.

It can be a list of stock tickers either in a CSV file or embedded in bulk_script.py as an array for now. (We'll eventually hook it up to a database and backend.)

The output can be the same as now, statistics for each stock separated by a header.

mattbowler commented 2 years ago

Changes to allow for tickers to be used is in 1c01eb2 An example ticker file is stock_tickers.csv

mattbowler commented 2 years ago

Hardcoding has now been allowed in ed672d4 Lines 33 & 34 are used for hardcoding

sichen1234 commented 2 years ago

@mattbowler This is great. Just running off a list of 7 Best Oil Stocks to Buy and 7 Renewable Energy Stocks and ETFs got good results:

Screen Shot 2021-08-27 at 2 06 29 PM

Look at the carbon betas on Chevron (CVX), Schlumberger (SLB), Pioneer Natural Resources (PXD) and the negative beta on VWDRY (Vestas Window). Interestingly SLB and PXD are exploration companies and have much higher carbon risk betas than the oil companies.

For the output, could you please also get the other statistics that are relevant for the regression such as r2?

mattbowler commented 2 years ago

Added the Durbin-Watson (autocorrelation), Breusch-Pagan (heteroskedasticity) & Jarques-Bera (normality) statistics to the table, as well as

sichen1234 commented 2 years ago

@mattbowler Do you think in addition to the P>|t| it would be also useful to get the t-statistics for each of the coefficients?

Also, in the attached screenshot, there are 2 rows of Jarque-Bera and Breusch-Pagan statistics, one for the coefficients and one for the P>|t|. What do the different numbers mean? Screen Shot 2021-09-07 at 3 39 13 PM

mattbowler commented 2 years ago

@sichen1234 committed the changes to include standard error & t-statistic in the output table. I also included an option to use default values

sichen1234 commented 2 years ago

@mattbowler How do I run it with standard values?

mattbowler commented 2 years ago

@sichen1234 I only added that option to factor_regression.py. I have now added it to bulk_script.py. I will clean up the code so that factor_regression.py & bulk_script.py use the same user input function so that changes made are made to both

sichen1234 commented 2 years ago

Now it works. Thanks!