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

improved market cap value extraction #5169

Merged
merged 5 commits into from
Nov 8, 2023
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,19 @@ def get_market_cap(symbol) -> float:
latest_year = market_cap.index[-1]

value = market_cap.loc[latest_year]["Market capitalization"]

if "M" in value:
updated_value = float(value.split(" M")[0]) * 1000000
elif "B" in value:
updated_value = float(value.split(" B")[0]) * 1000000000
elif "T" in value:
updated_value = float(value.split(" T")[0]) * 1000000000000
values_str = str(value)

# use values_str in string operations
if values_str.endswith("M"):
updated_value = float(values_str.split(" M", maxsplit=1)[0]) * 1000000
elif values_str.endswith("B"):
updated_value = float(values_str.split(" B", maxsplit=1)[0]) * 1000000000
elif values_str.endswith("T"):
updated_value = float(values_str.split(" T", maxsplit=1)[0]) * 1000000000000
else:
updated_value = float(value)
updated_value = float(values_str)
else:
updated_value = 0

return updated_value


Expand Down
Loading