Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #1.Importing the Library and Setting the Stock of Interest
- import yfinance as yahooFinance
- import pandas as pd
- pd.set_option('display.max_rows', None)
- total_energies = yahooFinance.Ticker("TTE.PA")
- #2.Retrieving Stock Information
- total_energies.info
- #3.Holders
- total_energies.major_holders
- total_energies.institutional_holders
- #4.Actions
- total_energies.actions
- total_energies.dividends
- df = pd.DataFrame(total_energies.dividends)
- df_new = df.groupby(['Date']).agg({'Dividends': 'sum'}).reset_index()
- df_new['Date_in_Datetime'] = pd.to_datetime(df_new['Date'])
- df_new['Year'] = df_new['Date_in_Datetime'].dt.year
- df_converted= df_new.groupby(['Year']).agg({'Dividends': 'sum'}).reset_index()
- import matplotlib.pyplot as plt #plot the dividends by years
- plt.figure(figsize=(10, 6))
- plt.bar(df_converted['Year'], df_converted['Dividends'])
- plt.xlabel('Year')
- plt.ylabel('Total Dividends')
- plt.title('Dividends by Year')
- plt.show()
- total_energies.splits
- #5.Financial Statements
- total_energies.income_stmt
- total_energies.quarterly_income_stmt
- total_energies.balance_sheet
- total_energies.quarterly_balance_sheet
- total_energies.cash_flow
- total_energies.quarterly_cashflow
- _____________________________________________________________________________________________________
- #QuantStats: Portfolio analytics for quants
- %matplotlib inline
- import quantstats as qs
- # extend pandas functionality with metrics, etc.
- qs.extend_pandas()
- # fetch the daily returns for a stock
- stock = qs.utils.download_returns('TTE.PA')
- stock
- # show sharpe ratio
- qs.stats.sharpe(stock)
- # or using extend_pandas() :)
- stock.sharpe()
- #Visualize stock performance
- qs.plots.snapshot(stock, title='TotalEnergies Performance', show=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement