Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Portfolio Functionalities & Caching Methods #174

Merged
merged 64 commits into from
Mar 1, 2025
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
0586c49
Bump streamlit from 1.36.0 to 1.37.0
dependabot[bot] Sep 7, 2024
0e96424
Merge branch 'main' into dependabot/pip/streamlit-1.37.0
JerBouma Oct 30, 2024
a8ceb1a
Merge pull request #152 from JerBouma/dependabot/pip/streamlit-1.37.0
JerBouma Oct 30, 2024
dd1b122
Fix issue within economics returning a 403 error, fixing #162
JerBouma Dec 12, 2024
2ad2977
Update the historical model overriding yfinance messages and ensuring…
JerBouma Dec 12, 2024
6fee30a
Update tests
JerBouma Dec 12, 2024
3a14784
Release of v1.9.9 fixing Economics and Yahoo Finance Historical data
JerBouma Dec 12, 2024
7619661
Bump tornado from 6.4.1 to 6.4.2
dependabot[bot] Dec 12, 2024
71e516e
Merge pull request #161 from JerBouma/dependabot/pip/tornado-6.4.2
JerBouma Dec 20, 2024
855806d
Update tests with portfolio tests
JerBouma Feb 2, 2025
47fb3b2
Add Portfolio modules allowing for portfolio evaluations
JerBouma Feb 2, 2025
a7365ea
Update the financetoolkit to be able to work with a portfolio column
JerBouma Feb 2, 2025
58293dc
Add a Portfolio example and update all examples accordingly
JerBouma Feb 2, 2025
0315c59
Add portfolio example to the file
JerBouma Feb 2, 2025
cd43a66
Update README with Portfolio information
JerBouma Feb 2, 2025
6e6b299
Prepare for upcoming release
JerBouma Feb 2, 2025
57d701d
Add portfolio image
JerBouma Feb 2, 2025
f869dc8
Misc
JerBouma Feb 2, 2025
ca3b112
Minor detail
JerBouma Feb 25, 2025
587f69d
Add portfolio weights hidden variable
JerBouma Feb 25, 2025
ba08674
Add robustness for error handling and a yahoo finance correction
JerBouma Feb 25, 2025
8e7964b
Add clearer error messages add caching functions
JerBouma Feb 25, 2025
26600ae
Add portfolio weights hidden variable
JerBouma Feb 25, 2025
d7ca0bb
Add robustness for error handling
JerBouma Feb 25, 2025
ae925bd
Introduce the Global Macro Database from https://github.com/KMueller-…
JerBouma Feb 25, 2025
c0e8fce
Minor details
JerBouma Feb 25, 2025
b9260dc
Add portfolio weights hidden variable
JerBouma Feb 25, 2025
274a226
Add caching support to all functions
JerBouma Feb 25, 2025
5c7dfe5
Add new portfolio menu
JerBouma Feb 25, 2025
5f082e4
Add new portfolio menu
JerBouma Feb 25, 2025
84cc720
Minor details
JerBouma Feb 25, 2025
1d5fad0
Update examples
JerBouma Feb 25, 2025
c6a7b4b
Bugfix for FRED data
JerBouma Feb 25, 2025
6f0b60d
Minor details
JerBouma Feb 25, 2025
24684af
Exclude the cached folder
JerBouma Feb 25, 2025
047978d
Remove Twitter
JerBouma Feb 25, 2025
17754b5
Update README.md
JerBouma Feb 25, 2025
b7c5e65
Remove Twitter
JerBouma Feb 25, 2025
ff2cb4f
Remove Twitter and Discord
JerBouma Feb 25, 2025
21585fa
Update module to find the correct paths
JerBouma Feb 28, 2025
a51c464
Important details
JerBouma Feb 28, 2025
eb4450f
Remove trailing option for balance sheet statements due to #172
JerBouma Feb 28, 2025
0fd0802
Add some additional tests
JerBouma Feb 28, 2025
5800075
Reorder functions
JerBouma Feb 28, 2025
65dd602
Update the README with the new additions
JerBouma Feb 28, 2025
99967f9
Introduce fix for wrongly calculated income statement ratios as menti…
JerBouma Feb 28, 2025
76c49f5
Update portfolio section
JerBouma Feb 28, 2025
4a7d2d3
Update portfolio section
JerBouma Feb 28, 2025
6852257
Update portfolio section
JerBouma Feb 28, 2025
a2dfe73
Update portfolio section
JerBouma Feb 28, 2025
978552e
Update portfolio section
JerBouma Feb 28, 2025
0ef40ef
Update portfolio section
JerBouma Feb 28, 2025
fb160b7
Minor documentation
JerBouma Feb 28, 2025
05c039c
Minor documentation
JerBouma Feb 28, 2025
894d254
Preparing the v2.0.0 release
JerBouma Feb 28, 2025
63ab4c8
Add TQDM in dev dependencies
JerBouma Feb 28, 2025
8e567c1
Update lock file
JerBouma Feb 28, 2025
ea7a917
Add in the portfolio test file
JerBouma Feb 28, 2025
c51d555
Add in a check based on the plan you are using
JerBouma Mar 1, 2025
3531ae3
Robustness on ticker and plan
JerBouma Mar 1, 2025
5741765
Add better error handling
JerBouma Mar 1, 2025
c1eb8ab
Expand portfolio overview with volatilities and betas
JerBouma Mar 1, 2025
e61d889
Minor bugfixes
JerBouma Mar 1, 2025
18f7271
Update table
JerBouma Mar 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add robustness for error handling and a yahoo finance correction
  • Loading branch information
JerBouma committed Feb 25, 2025
commit ba08674b32a899f305b3260b12beb151dafd9e4b
16 changes: 14 additions & 2 deletions financetoolkit/historical_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def get_historical_data(
show_ticker_seperation: bool = True,
show_errors: bool = False,
tqdm_message: str = "Obtaining historical data",
user_subscription: str = "Free",
):
"""
Retrieves historical stock data for the given ticker(s) from Financial Modeling Prep or/and Yahoo Finance
Expand Down Expand Up @@ -222,7 +223,9 @@ def worker(ticker, historical_data_dict):
thread.join()

historical_data_dict = (
helpers.check_for_error_messages(historical_data_dict)
helpers.check_for_error_messages(
dataset_dictionary=historical_data_dict, user_subscription=user_subscription
)
if show_errors
else historical_data_dict
)
Expand Down Expand Up @@ -508,7 +511,12 @@ def get_historical_data_from_yahoo_finance(
start=start_timestamp,
end=end_timestamp,
interval=interval,
auto_adjust=True,
).droplevel(level=1, axis=1)

if "Adj Close" not in historical_data and historical_data.columns.nlevels == 1:
historical_data["Adj Close"] = historical_data["Close"]

except (HTTPError, URLError, RemoteDisconnected, IndexError):
return pd.DataFrame()

Expand Down Expand Up @@ -879,6 +887,7 @@ def get_historical_statistics(
progress_bar: bool = True,
show_errors: bool = False,
tqdm_message: str = "Obtaining historical statistics",
user_subscription: str = "Free",
):
"""
Retrieves statistics about each ticker's historical data. This is useful to understand why certain
Expand Down Expand Up @@ -965,7 +974,10 @@ def worker(ticker, historical_statistics_dict):
thread.join()

historical_statistics_dict = (
helpers.check_for_error_messages(historical_statistics_dict)
helpers.check_for_error_messages(
dataset_dictionary=historical_statistics_dict,
user_subscription=user_subscription,
)
if show_errors
else historical_statistics_dict
)
Expand Down