mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-13 04:41:24 +00:00
Add realtime earnings from geekofwallstr (#731)
This commit is contained in:
1
README.md
vendored
1
README.md
vendored
@@ -400,6 +400,7 @@ Feel free to share loss porn, memes or any questions at:
|
||||
* **Chavithra** and **Deel18** : for Degiro's integration.
|
||||
* **Traceabl3** : By adding several preset screeners
|
||||
* **jpp** : Responsible by developing `Crypto` menu
|
||||
* **rkornmeyer** : Provides realtime earnings data on https://thegeekofwallstreet.com/
|
||||
|
||||
<a href="https://github.com/GamestonkTerminal/GamestonkTerminal/graphs/contributors">
|
||||
<img src="https://contributors-img.web.app/image?repo=GamestonkTerminal/GamestonkTerminal" height="276"/>
|
||||
|
||||
@@ -5,8 +5,10 @@ import argparse
|
||||
import os
|
||||
from typing import List
|
||||
from datetime import datetime
|
||||
|
||||
from matplotlib import pyplot as plt
|
||||
from prompt_toolkit.completion import NestedCompleter
|
||||
|
||||
from gamestonk_terminal import feature_flags as gtff
|
||||
from gamestonk_terminal.helper_funcs import get_flair
|
||||
from gamestonk_terminal.menu import session
|
||||
@@ -24,6 +26,7 @@ from gamestonk_terminal.stocks.discovery import (
|
||||
shortinterest_view,
|
||||
yahoofinance_view,
|
||||
finnhub_view,
|
||||
geekofwallstreet_view,
|
||||
)
|
||||
|
||||
|
||||
@@ -56,6 +59,7 @@ class DiscoveryController:
|
||||
"trending",
|
||||
"lowfloat",
|
||||
"hotpenny",
|
||||
"rtearn",
|
||||
]
|
||||
|
||||
CHOICES += CHOICES_COMMANDS
|
||||
@@ -74,10 +78,12 @@ class DiscoveryController:
|
||||
help_text = """https://github.com/GamestonkTerminal/GamestonkTerminal/tree/main/gamestonk_terminal/stocks/discovery
|
||||
|
||||
Discovery:
|
||||
cls clear screen")
|
||||
?/help show this menu again")
|
||||
q quit this menu, and shows back to main menu")
|
||||
quit quit to abandon program")
|
||||
cls clear screen
|
||||
?/help show this menu again
|
||||
q quit this menu, and shows back to main menu
|
||||
quit quit to abandon program
|
||||
Geek of Wall St:
|
||||
rtearn realtime earnings from and expected moves
|
||||
Finnhub:
|
||||
pipo past IPOs dates
|
||||
fipo future IPOs dates
|
||||
@@ -146,6 +152,35 @@ pennystockflow.com
|
||||
"""Process Quit command - quit the program"""
|
||||
return True
|
||||
|
||||
def call_rtearn(self, other_args: List[str]):
|
||||
"""Process rtearn command"""
|
||||
parser = argparse.ArgumentParser(
|
||||
add_help=False,
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
||||
prog="rtearn",
|
||||
description="""
|
||||
Realtime earnings data and expected moves. [Source: https://thegeekofwallstreet.com]
|
||||
""",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--export",
|
||||
choices=["csv", "json", "xlsx"],
|
||||
default="",
|
||||
type=str,
|
||||
dest="export",
|
||||
help="Export dataframe data to csv,json,xlsx file",
|
||||
)
|
||||
|
||||
try:
|
||||
ns_parser = parse_known_args_and_warn(parser, other_args)
|
||||
if not ns_parser:
|
||||
return
|
||||
|
||||
geekofwallstreet_view.display_realtime_earnings(ns_parser.export)
|
||||
|
||||
except Exception as e:
|
||||
print(e, "\n")
|
||||
|
||||
def call_pipo(self, other_args: List[str]):
|
||||
"""Process pipo command"""
|
||||
parser = argparse.ArgumentParser(
|
||||
@@ -218,9 +253,8 @@ pennystockflow.com
|
||||
help="Export dataframe data to csv,json,xlsx file",
|
||||
)
|
||||
try:
|
||||
if other_args:
|
||||
if "-" not in other_args[0]:
|
||||
other_args.insert(0, "-n")
|
||||
if other_args and "-" not in other_args[0]:
|
||||
other_args.insert(0, "-n")
|
||||
|
||||
ns_parser = parse_known_args_and_warn(parser, other_args)
|
||||
if not ns_parser:
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
"""Geek of wall street model"""
|
||||
__docformat__ = "numpy"
|
||||
|
||||
import io
|
||||
import requests
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def download_file_from_google_drive(file_id: str) -> bytes:
|
||||
"""Custom function from rkornmeyer for pulling csv from google drive
|
||||
|
||||
Parameters
|
||||
----------
|
||||
file_id : str
|
||||
File id to pull from google drive
|
||||
|
||||
Returns
|
||||
-------
|
||||
bytes
|
||||
Content from request response
|
||||
"""
|
||||
|
||||
def get_confirm_token(response):
|
||||
for key, value in response.cookies.items():
|
||||
if key.startswith("download_warning"):
|
||||
return value
|
||||
|
||||
return None
|
||||
|
||||
URL = "https://docs.google.com/uc?export=download"
|
||||
|
||||
session = requests.Session()
|
||||
|
||||
response = session.get(URL, params={"id": file_id}, stream=True)
|
||||
token = get_confirm_token(response)
|
||||
|
||||
if token:
|
||||
params = {"id": file_id, "confirm": token}
|
||||
response = session.get(URL, params=params, stream=True)
|
||||
|
||||
return response.content
|
||||
|
||||
|
||||
def get_realtime_earnings() -> pd.DataFrame:
|
||||
"""Pulls realtime earnings from geek of wallstreet
|
||||
|
||||
Returns
|
||||
-------
|
||||
pd.DataFrame
|
||||
Dataframe containing realtime earnings
|
||||
"""
|
||||
data = download_file_from_google_drive("1-TsAuzKs_vvg40r5RuRaG_wyb2Hzxbd5").decode(
|
||||
"utf-8"
|
||||
)
|
||||
return pd.read_csv(io.StringIO(data))
|
||||
56
gamestonk_terminal/stocks/discovery/geekofwallstreet_view.py
Normal file
56
gamestonk_terminal/stocks/discovery/geekofwallstreet_view.py
Normal file
@@ -0,0 +1,56 @@
|
||||
"""Geek of wall street view"""
|
||||
__docformat__ = "numpy"
|
||||
import os
|
||||
|
||||
import pandas as pd
|
||||
from tabulate import tabulate
|
||||
|
||||
import gamestonk_terminal.feature_flags as gtff
|
||||
from gamestonk_terminal.helper_funcs import export_data
|
||||
from gamestonk_terminal.stocks.discovery import geekofwallstreet_model as gwt_model
|
||||
|
||||
# pylint:disable=no-member
|
||||
|
||||
|
||||
def display_realtime_earnings(export: str = ""):
|
||||
"""Displays real time earnings data from geekofwallstreet.com
|
||||
|
||||
Parameters
|
||||
----------
|
||||
export : str, optional
|
||||
Format to export data
|
||||
"""
|
||||
earnings: pd.DataFrame = gwt_model.get_realtime_earnings()
|
||||
earnings_export = earnings.copy()
|
||||
# Make the table look pretty
|
||||
earnings = earnings.drop(
|
||||
columns=[
|
||||
"Name",
|
||||
"Previous Earnings Date",
|
||||
"Stock Type",
|
||||
"Confirmation",
|
||||
"Special Case",
|
||||
"Conference Call",
|
||||
"Press Release",
|
||||
"Has Options",
|
||||
]
|
||||
).fillna("")
|
||||
earnings["Market Cap"] = earnings["Market Cap"] / 1_000_000_000
|
||||
earnings = earnings.rename(columns={"Market Cap": "Market Cap ($1B)"})
|
||||
if gtff.USE_TABULATE_DF:
|
||||
print(
|
||||
tabulate(
|
||||
earnings,
|
||||
headers=earnings.columns,
|
||||
tablefmt="fancy_grid",
|
||||
showindex=False,
|
||||
floatfmt=".3f",
|
||||
),
|
||||
"\n",
|
||||
)
|
||||
else:
|
||||
print(earnings.to_string())
|
||||
|
||||
export_data(
|
||||
export, os.path.dirname(os.path.abspath(__file__)), "rtearn", earnings_export
|
||||
)
|
||||
@@ -355,6 +355,7 @@ def about_us():
|
||||
f"{Fore.CYAN}Quiver Quantitative: {Style.RESET_ALL}https://www.quiverquant.com\n"
|
||||
f"{Fore.CYAN}Ops.Syncretism: {Style.RESET_ALL}https://ops.syncretism.io/api.html\n"
|
||||
f"{Fore.CYAN}SentimentInvestor: {Style.RESET_ALL}https://sentimentinvestor.com\n"
|
||||
f"{Fore.CYAN}The Geek of Wall Street: {Style.RESET_ALL}https://thegeekofwallstreet.com/\n"
|
||||
f"\n{Fore.RED}"
|
||||
"DISCLAIMER: Trading in financial instruments involves high risks including the risk of losing some, "
|
||||
"or all, of your investment amount, and may not be suitable for all investors. Before deciding to trade in "
|
||||
|
||||
Reference in New Issue
Block a user