Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

The Passive Investor

GitHub Sponsors Buy Me a Coffee Twitter LinkedIn Documentation PYPI Version PYPI Downloads

Theories and research about the stock market have stated that the semi-strong form of market efficiency seems to hold. This means that all public information is accurately reflected in the price of a financial instrument. This makes the job of a portfolio manager primarily managing the desired risk appetite of the client and not explicitly trying to outperform the market. This fact in combination with Finance professionals all around the world looking for that 'edge' to make their investment decisions as profitable as possible, makes it so the average joe can not compete.

Therefore, the term 'Passive Investing' is often coined around. This refers to buying funds (either ETFs or Mutual Funds) that follow the index (i.e. S&P 500, Dow Jones Index) or a broad market (Developed Markets, MSCI World) for diversification benefits. This means that a sudden decrease in performance of one stock within the index does not (on average) lead to a significant decline in the index as a whole. This allows the holder to spend limited time monitoring his holdings, therefore the term 'Passive'.

With a large increase in ETFs available (over 5,000 in 2020), it can become difficult to make the best choice in what you wish to invest. There are many different providers (iShares, Vanguard, Invesco) as well as with changes to the underlying stocks (i.e. High Yield, Super Dividends, Equal Weighted). This is quickly reflected when looking for a S&P 500 ETF as there are over 20 different ETFs available. With this package, I wish to make investment decisions easier to make and manage.

An example of the output can be found in the GIF below. This depicts several ETFs collected from the Top ETFs according to Yahoo Finance.

outputExample

Installation

The package can be installed via the following commands:

  1. pip install thepassiveinvestor
    • Alternatively, download this repository.
  2. (within Python) import thepassiveinvestor as pi

The functions within this package are:

  • collect_data(ticker) - collects the most important data for ETFs as listed in the Functionality section.
  • create_ETF_report(tickers, filename, folder=None) - uses collect_data to create an Excel report with data, as depicted in the GIF above, per sheet for each ticker.

Therefore, if you wish to collect data on an ETF or create a report of a selection of ETFs you can use the following example:

import thepassiveinvestor as pi

# Collect data from a specific ETF
vanguard_sp500 = pi.collect_data('VOO')

# Show the data
vanguard_sp500

Which returns the following:

{'long_name': 'Vanguard 500 Index Fund', 'summary': "The fund employs an indexing investment approach designed to track the performance of the Standard & Poor's 500 Index, a widely recognized benchmark of U.S. stock market performance that is dominated by the stocks of large U.S. companies. The advisor attempts to replicate the target index by investing all, or substantially all, of its assets in the stocks that make up the index, holding each stock in approximately the same proportion as its weighting in the index.", 'image_URL': 'https://s.yimg.com/lq/i/fi/3_0stylelargeeq2.gif', 'sector_holdings': {'realestate': '2.75%', 'consumer_cyclical': '10.13%', 'basic_materials': '2.4%', 'consumer_defensive': '7.38%', 'technology': '23.65%', 'communication_services': '7.43%', 'financial_services': '13.7%', 'utilities': '2.43%', 'industrials': '8.82%', 'energy': '5.11%', 'healthcare': '15.27%'}, 'company_holdings': {'Apple Inc': '5.92%', 'Microsoft Corp': '5.62%', 'Amazon.com Inc': '4.06%', 'Facebook Inc Class A': '2.29%', 'Alphabet Inc Class A': '2.02%', 'Alphabet Inc Class C': '1.97%', 'Berkshire Hathaway Inc Class B': '1.44%', 'Tesla Inc': '1.44%', 'NVIDIA Corp': '1.37%', 'JPMorgan Chase & Co': '1.3%'}, 'annual_returns': {'2022': '-18.15%', '2021': '28.66%', '2020': '18.35%', '2019': '31.46%', '2018': '-4.42%', '2017': '21.78%'}, 'risk_data': {'5y': {'year': '5y', 'alpha': -0.04, 'beta': 1, 'meanAnnualReturn': 0.89, 'rSquared': 100, 'stdDev': 18.69, 'sharpeRatio': -0.19, 'treynorRatio': 8.04}, '3y': {'year': '3y', 'alpha': -0.04, 'beta': 1, 'meanAnnualReturn': 0.8, 'rSquared': 100, 'stdDev': 21.17, 'sharpeRatio': -0.55, 'treynorRatio': 6.76}, '10y': {'year': '10y', 'alpha': -0.04, 'beta': 1, 'meanAnnualReturn': 1.08, 'rSquared': 100, 'stdDev': 14.78, 'sharpeRatio': 0.88, 'treynorRatio': 11.7}}, 'key_characteristics': {'fundInceptionDate': '2010-09-07', 'category': 'Large Blend', 'totalAssets': 744769716224, 'currency': 'USD', 'navPrice': 366.24, 'previousClose': 365.67}}

You also have the option to generate a comparison report as follows:

import thepassiveinvestor as pi

# Collect data from a set of ETFs and compare them
etf_comparison = pi.collect_data(['VOO', 'QQQ', 'ARKG', 'VUG', 'SCHA', 'VWO'], comparison=True)

# Show the comparison
etf_comparison

Which returns the following:

VOOQQQARKGVUGSCHAVWO
('sector_holdings', 'realestate')2.75%0.29%0%2.55%7.16%2.95%
('sector_holdings', 'consumer_cyclical')10.13%14.2%0%18.09%12.75%12.92%
('sector_holdings', 'basic_materials')2.4%0%0%2.01%4.35%9.34%
('sector_holdings', 'consumer_defensive')7.38%6.67%0%2.92%4.12%6.23%
('sector_holdings', 'technology')23.65%47.62%3.41%41.19%14.18%15.49%
('sector_holdings', 'communication_services')7.43%15.99%0%11.96%2.74%8.72%
('sector_holdings', 'financial_services')13.7%0.74%0%6.95%15.68%20.63%
('sector_holdings', 'utilities')2.43%0.88%0%0%1.83%3.78%
('sector_holdings', 'industrials')8.82%4.75%0%4.64%16.16%7.26%
('sector_holdings', 'energy')5.11%0.49%0%1.35%5.85%5.36%
('sector_holdings', 'healthcare')15.27%7.54%96.58%8.13%13.98%4.6%
('annual_returns', '2022')-18.15%-32.49%-53.94%-33.13%-19.8%-17.72%
('annual_returns', '2021')28.66%27.24%-33.89%27.26%16.35%0.96%
('annual_returns', '2020')18.35%48.6%180.51%40.16%19.35%15.32%
('annual_returns', '2019')31.46%39.12%43.75%37.26%26.54%20.4%
('annual_returns', '2018')-4.42%-0.14%0.59%-3.32%-11.75%-14.57%
('annual_returns', '2017')21.78%32.7%45.41%27.8%15.04%31.38%
('key_characteristics', 'fundInceptionDate')2010-09-071999-03-102014-10-312004-01-262009-11-032005-03-04
('key_characteristics', 'category')Large BlendLarge GrowthHealthLarge GrowthSmall BlendDiversified Emerging Mkts
('key_characteristics', 'totalAssets')74476971622414593150156818991083521323039211521332722380893044613120
('key_characteristics', 'currency')USDUSDUSDUSDUSDUSD
('key_characteristics', 'navPrice')366.24281.0332.79225.0843.4241.9
('key_characteristics', 'previousClose')365.67281.5433.43225.6643.4141.92
('risk_data_3y', 'year')3y3y3y3y3y3y
('risk_data_3y', 'alpha')-0.040.76-4.62-1.7-3.72-1.28
('risk_data_3y', 'beta')11.081.321.111.150.9
('risk_data_3y', 'meanAnnualReturn')0.80.920.250.740.60.05
('risk_data_3y', 'rSquared')10087.5741.8290.7982.6676.68
('risk_data_3y', 'stdDev')21.1724.4941.2824.626.820.04
('risk_data_3y', 'sharpeRatio')-0.55-0.70.27-0.721.582
('risk_data_3y', 'treynorRatio')6.767.04-4.514.72.44-2.53
('risk_data_5y', 'year')5y5y5y5y5y5y
('risk_data_5y', 'alpha')-0.042.152.44-0.2-5.06-0.93
('risk_data_5y', 'beta')11.11.51.11.160.94
('risk_data_5y', 'meanAnnualReturn')0.891.160.980.960.60.11
('risk_data_5y', 'rSquared')10088.4945.6691.783.4878.97
('risk_data_5y', 'stdDev')18.6921.8539.3221.423.7318.27
('risk_data_5y', 'sharpeRatio')-0.19-0.44-0.12-0.31.771.58
('risk_data_5y', 'treynorRatio')8.049.811.987.552.69-1.74
('risk_data_10y', 'year')10y10y10y10y10y10y
('risk_data_10y', 'alpha')-0.042.460-0.51-4.08-1.79
('risk_data_10y', 'beta')11.101.081.160.98
('risk_data_10y', 'meanAnnualReturn')1.081.3901.130.90.24
('risk_data_10y', 'rSquared')10085.33091.4880.4475.61
('risk_data_10y', 'stdDev')14.7817.56016.7619.0616.38
('risk_data_10y', 'sharpeRatio')0.880.3900.782.921.44
('risk_data_10y', 'treynorRatio')11.714.01011.057.380.79

Lastly, if you wish to export to Excel this is also a possibility generating an Excel file that contains the most relevant information for each ticker.

import thepassiveinvestor as pi

# Create a report from a list of ETFs
etf_list = ['VOO', 'QQQ', 'ARKG', 'VUG', 'SCHA', 'VWO']
pi.create_ETF_report(etf_list, 'Popular ETFs.xlsx')

Which returns the following:

Screenshot 2023-01-19 at 13 26 48

Functionality

The package outputs an overview of each fund on a separate sheet. In this overview the following data is shown:

TopicContains
GeneralThe title of the fund and a summary about the fund's purpose and goal.
CharacteristicsInception date (the start of the fund), the category, assets under management (AUM), the denominated currency, net asset value (NAV), the latest close price and the Morningstar Style Box (if available).
HoldingsSector holdings (% in each sector) and company holdings (top 10 companies with highest %).
Risk MetricsAll metrics are displayed in an interval of 3, 5 and 10 years. This includes Jensen's Alpha, Beta, Mean Annual Return, R-squared, Standard Deviation, Sharpe Ratio and Treynor Ratio.
PerformanceThe last five annual returns of the fund as well as a graph depicting the adjusted close prices over the last 10 years. The actual data for this graph is available on a hidden sheet.

Contact

If you have any questions about the FinanceToolkit or would like to share with me what you have been working on, feel free to reach out to me via:

If you'd like to support my efforts, either help me out by contributing to the package or Sponsor Me.

Star History Chart

关于 About

Passive Investing for the Average Joe
etfsfinanceinvestingpassivepythonstock-market

语言 Languages

Python100.0%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
0
Total Commits
峰值: 1次/周
Less
More

核心贡献者 Contributors