From f66bd1d95409f6af3e7491d613d08f0c4a6d4927 Mon Sep 17 00:00:00 2001 From: jeroen Date: Sun, 30 Jun 2024 12:50:14 +0200 Subject: [PATCH] Update dashboard design, adding in video and updating texts --- app/helpers.py | 32 +++++++++++++++++++ app/socials_model.py | 13 +++++++- dashboard.py | 74 +++++++++++++++++++++++++------------------- pyproject.toml | 2 +- 4 files changed, 88 insertions(+), 33 deletions(-) diff --git a/app/helpers.py b/app/helpers.py index 6abe745..a182e6c 100644 --- a/app/helpers.py +++ b/app/helpers.py @@ -1,7 +1,25 @@ +"""Helpers Module""" + +import streamlit as st + from financetoolkit import helpers def check_api_key_status(api_key: str): + """ + Check the status of an API key. + + Args: + api_key (str): The API key to check. + + Returns: + Tuple[bool, bool, str]: A tuple containing the following values: + - invalid_api_key (bool): True if the API key is invalid, False otherwise. + - premium_plan (bool): True if the API key is associated with a premium plan, False otherwise. + - reason (str): The reason for the status of the API key. None if the API key is valid and associated + with a premium plan. + + """ determine_plan = helpers.get_financial_data( url=f"https://financialmodelingprep.com/api/v3/income-statement/AAPL?period=quarter&apikey={api_key}", sleep_timer=False, @@ -25,3 +43,17 @@ def check_api_key_status(api_key: str): reason = "API Key Limit Reached." return invalid_api_key, premium_plan, reason + + +def load_css(file_name): + """ + Loads and applies custom CSS styles from a file. + + Args: + file_name (str): The name of the CSS file to load. + + Returns: + Markdown object from Streamlit. + """ + with open(file_name) as f: + st.markdown(f"", unsafe_allow_html=True) diff --git a/app/socials_model.py b/app/socials_model.py index 2f1dcb1..2f903b3 100644 --- a/app/socials_model.py +++ b/app/socials_model.py @@ -4,6 +4,16 @@ def create_socials_sidebar(): + """ + Creates a sidebar with social media links and additional information. + + This function adds a divider and displays social media badges with links to GitHub, Twitter, LinkedIn, + GitHub Sponsors, and Buy Me a Coffee. It also includes additional information about the Finance Toolkit + and provides a link to open a ticket for sharing thoughts or issues. + + Returns: + Divided and Markdown objects from Streamlit. + """ st.divider() st.markdown( unsafe_allow_html=True, @@ -14,6 +24,7 @@ def create_socials_sidebar(): [![GitHub Sponsors](https://img.shields.io/badge/Sponsor_this_Project-grey?logo=github)](https://github.com/sponsors/JerBouma) [![Buy Me a Coffee](https://img.shields.io/badge/Buy_Me_a_Coffee-grey?logo=buymeacoffee)](https://www.buymeacoffee.com/jerbouma) - \n\n The Finance Toolkit is written and maintained by [Jeroen Bouma](https://www.jeroenbouma.com) + \n\n The Finance Toolkit is written and maintained by [Jeroen Bouma](https://www.jeroenbouma.com). + Like to share your thoughts? Please open a ticket [here](https://github.com/JerBouma/FinanceToolkit/issues/new/choose). """, ) diff --git a/dashboard.py b/dashboard.py index ed343bf..0535484 100644 --- a/dashboard.py +++ b/dashboard.py @@ -1,9 +1,11 @@ +"""Dashboard Module""" + import streamlit as st -from app import initalization_model, metrics_view, socials_model +from app import helpers, initalization_model, metrics_view, socials_model st.set_page_config( - page_title="Finance Toolkit in Streamlit", page_icon="📈", layout="wide" + page_title="Finance Toolkit Dashboard", page_icon="🛠️", layout="wide" ) @@ -13,43 +15,53 @@ st.session_state["is_expanded"] = True if st.session_state["invalid_api_key"]: - st.session_state["welcome_msg"].markdown( + helpers.load_css("app/assets/style.css") + + st.markdown( """ + """, + unsafe_allow_html=True, + ) + + st.session_state["welcome_msg"].markdown( + body=""" ## Welcome to the Finance Toolkit dashboard! 👋 - While browsing a variety of websites, I repeatedly observed significant fluctuations in the same financial metric - among different sources. - Similarly, the reported financial statements often didn't line up, and there was limited information on the - methodology used to calculate each metric. - - For example, Microsoft's Price-to-Earnings (PE) ratio on the 6th of May, 2023 is reported to - be 28.93 (Stockopedia), 32.05 (Morningstar), - 32.66 (Macrotrends), 33.09 (Finance Charts), 33.66 (Y Charts), 33.67 (Wall Street Journal), 33.80 - (Yahoo Finance) and 34.4 (Companies Market Cap). All of these calculations are correct, however the - method of calculation varies leading to different results. Therefore, collecting data from multiple - sources can lead to wrong interpretation of the results given that one source could apply a different - definition than another. And that is, if that definition is even available as often the underlying - methods are hidden behind a paid subscription. - - **This is why I designed the Finance Toolkit**, this is an open-source toolkit in which all relevant financial - ratios 200+ indicators - and performance measurements are written down in the most simplistic way allowing for complete transparency - of the method of calculation. - - This dashboard is powered entirely by the Finance Toolkit and gves access to all relevant financial ratios, - indicators and performance measurements. Key features of the dashboard are: - - - Compare a small or large selection of tickers for any period (10+ years for Premium users, max 5 years for + This dashboard is powered by the Finance Toolkit, an open-source toolkit in which 200+ relevant financial ratios, + indicators and performance measurements are written down in the most simplistic way allowing for complete + transparency of the method of calculation. Once you've entered you're API key you are ready to go! + + The key features of this dashboard are as follows: + + - 🏢 Compare a small or large selection of tickers for any period (10+ years for Premium users, max 5 years for Free users). - - Plot any item from the Financial Statements (Balance Sheet, Income Statement, Cash Flow Statement). - - Compare a large selection of financial ratios, technical indicators, performance metrics and risk metrics. - - Show quarterly results, growth rates, trailing twelve months (TTM) as well as tables (with download - to CSV option) + - 📃 Plot any item from the Financial Statements, e.g. Shareholder's Equity from the Balance Sheet, Revenue from + the Income Statement and Operating Cash Flow from the Cash Flow Statement. + - 💸 Compare 150+ financial ratios, technical indicators, performance metrics and risk metrics. + - 📈 Show quarterly results, growth rates, trailing twelve months (TTM) as well as tables (with the option + to download the data) - Once you've entered you're API key you are ready to go! + Find below a demonstration of what is possible once you have entered your API key. """ ) + st.video( + "app/assets/financetoolkit-dashboard.mov", + autoplay=True, + muted=True, + start_time=3, + end_time=66, + ) + + st.markdown( + """ +

📱 Mobile Users

Given that you are viewing this page on mobile, + please open the sidebar (arrow in the top left) to get started! Once you've entered your API key it + should automatically proceed.
+ """, + unsafe_allow_html=True, + ) + st.session_state = initalization_model.create_api_key_sidebar(st.session_state) diff --git a/pyproject.toml b/pyproject.toml index 3e243fa..cd39b42 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,7 +94,7 @@ ignore-words-list = 'te,hsi,amplitud,nam,tha,plaform' skip = '*.json,./.git,pyproject.toml,poetry.lock,examples' [tool.mypy] -disable_error_code = "misc" +disable_error_code = "misc, valid-type, attr-defined, index" [tool.pytest.ini_options] filterwarnings = [