Can I Buy My Own Income?

It feels good carrying a bunch of money
See. Over a 100,000 rows

How did I query my database?

In my SQLite database I wrote this nifty query to return a table of all the dividend paying companies in the S&P 500.

The query I wrote to return the table of company dividends organized by month

So why am I sharing this?

Well, in a world where employers increasingly have more leverage over their employees and job security is evermore fleeting I want to help people create their own financial security net. Having something like this will make the hard times not so hard if one gets laid off or furloughed. While employed a person can just reinvest the dividends paid out each month, which I elaborated on in a previous post. If they get fired or decide to leave their job, they then can use the monthly dividend payments to float them while they search for a new job or go back to school or whatever they decide to do. Also, having this type of portfolio could be the difference in staying at a job that someone hates or walking away from it and finding more fulfilling work.

Do you want to make your own dataset?

Below is the script of code you can use to make your own dataset of stock info from AlphaVantage. You’ll just need your own API key and a list of companies for which you want data.

allCompany_df = pd.DataFrame([[0, 0, 0, 0,0,0, 0, "0", "0", 0, 0]], columns=['1. open', '2. high', '3. low', '4. close', '5. adjusted close', '6. volume', '7. dividend amount', 'Company_Ticker', 'Company_name', 'month', 'year'])i = 0#for symbol in chunker(lstOFa, 1):for symbol in listOfCompanies:div_monthly_summary = f"https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY_ADJUSTED&symbol={symbol}&apikey={APIkey}"parsed_divs = json.loads(requests.get(div_monthly_summary).text)### make a row for each date in the 'Monthly Adjusted Time Series' with the### dividend amount as the entry"""div_dates = list(parsed_divs.items())date_cols = list(div_dates[1][1].keys())"""monthly_time_series_df = pd.DataFrame.from_dict(parsed_divs['Monthly Adjusted Time Series'], orient ='index')monthly_time_series_df['Company_ticker'] = symbolmonthly_time_series_df['Company_name'] = trimmedSP500['Security'][i]monthly_time_series_df['month'] = pd.DatetimeIndex(monthly_time_series_df.index).monthmonthly_time_series_df['year'] = pd.DatetimeIndex(monthly_time_series_df.index).yearmonthly_time_series_df.reset_index(drop=True, inplace=True)print(monthly_time_series_df.head(3))allCompany_df = pd.concat([allCompany_df, monthly_time_series_df])x = i % 5if x == 0:sleep(65)i += 1#parsed_overview, parsed_intra, wiwtk#print(week_avgPEratio)allCompany_df

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store