π
As clichΓ© as it sounds, Love building things and solving problems.
Python package for mining stock and financial data, using data from open data sources like Yahoo Finance
new package version should be released to PyPI by Github workflow on new tag release
Error:
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/tmp/pip-build-env-r4268o3h/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 10, in <module>
import distutils.core
ModuleNotFoundError: No module named 'distutils'
It would be helpful to add date headers to the financial statements returned in the Ticker
class.
A crude and inelegant fix:
class Ticker(TickerAPI, JustETF):
"""
Class for the Ticker
"""
...
@property
def income_stmt(self) -> pd.DataFrame:
"""
Get income statement for the ticker
Returns:
pd.DataFrame: A pandas DataFrame including the income statement
visible in the Yahoo Finance statistics page for the ticker
"""
# URL of the website to scrape
url = f"https://finance.yahoo.com/quote/{self.ticker}/financials"
response = self.get_response(url)
# Parse the HTML content of the website
soup = BeautifulSoup(response.content, "html.parser")
# <div class="" data-test="fin-row">
raw_data = soup.find_all("div", {"data-test": "fin-row"})
data_df = pd.DataFrame()
dates = []
for item in raw_data:
if not dates:
# collect date headers for data_df
# e.g., ['12/31/2023', '12/31/2022', '12/31/2021', '12/31/2020']
dates = re.findall(
pattern=r"\d+/\d+/\d{4}", string=item.parent.parent.text
)
assert (
len(dates) == 4
), f"len(dates)={len(dates)}, should be 4 (dates={', '.join(dates)})"
# column for the most recent period gets collected twice below
# i.e., ['12/31/2023', '12/31/2023', '12/31/2022', '12/31/2021', '12/31/2020']
dates = [dates[0]] + dates
# get criteria. e.g. "Total Revenue"
major_div = item.find_all("div", {"class": True})[0]
criteria = major_div.find_all("div", {"class": True})[0].find("span").text
# get data. e.g. "274515000000"
minor_div = major_div.find_all("div", {"class": "Ta(c)"})
data_list = []
for div in minor_div:
data_list.append(div.text)
data_df[criteria] = data_list
data_df = data_df.T
# update columns to reflect the date headers
data_df.columns = dates
return data_df
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.