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

Update contributing guide (added a new feature while doing so) #4391

Merged
merged 27 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ed35c94
Update contributing guide
jmaslek Mar 3, 2023
82c3e02
lint md
jmaslek Mar 3, 2023
4a136f4
lint md
jmaslek Mar 3, 2023
7c98c09
lint md
jmaslek Mar 3, 2023
0a69c1e
Tests + fix some markdownlint things
jmaslek Mar 3, 2023
6f39a59
Get rid of irritating newline on reset
jmaslek Mar 3, 2023
bc24799
Trying something small
jmaslek Mar 3, 2023
05dd190
try something else
jmaslek Mar 3, 2023
a31256e
Merge branch 'develop' into feature/contributing-update
jmaslek Mar 4, 2023
29717e7
Merge branch 'develop' into feature/contributing-update
jmaslek Mar 6, 2023
84090a3
linting
jmaslek Mar 6, 2023
5f1877e
Change cfg to the new user object
jmaslek Mar 6, 2023
9e789c5
Merge branch 'develop' into feature/contributing-update
jmaslek Mar 6, 2023
b667cf8
Merge branch 'develop' into feature/contributing-update
hjoaquim Mar 7, 2023
e06e89b
words
jmaslek Mar 7, 2023
69fe17d
Merge branch 'develop' into feature/contributing-update
jmaslek Mar 7, 2023
9cf0353
Merge branch 'develop' into feature/contributing-update
jmaslek Mar 8, 2023
e780f9c
Merge branch 'develop' into feature/contributing-update
jmaslek Mar 8, 2023
b30ba36
Merge branch 'develop' into feature/contributing-update
jmaslek Mar 8, 2023
5c79c89
minor improvements
hjoaquim Mar 9, 2023
77ab0b2
some adjustments to the contributing guidelines
hjoaquim Mar 9, 2023
19b3e06
Merge branch 'develop' into feature/contributing-update
hjoaquim Mar 9, 2023
9c65f8e
Merge branch 'develop' into feature/contributing-update
hjoaquim Mar 9, 2023
bc8aa0c
Another pass at contributing
jmaslek Mar 9, 2023
1b52f52
spelling
jmaslek Mar 9, 2023
1e678d1
we need a local markdown linter
jmaslek Mar 9, 2023
6215e29
why does this pylint disable still fail
jmaslek Mar 9, 2023
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
5 changes: 4 additions & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ jobs:
MPLBACKEND: Agg
run: |
source $VENV
pytest tests/ --optimization --cov --cov-fail-under=50 --autodoc -n auto --durations=10 --timeout=30
pytest tests/ --optimization --cov --cov-fail-under=50 --autodoc -n auto --durations=10 --timeout=30 --cov-report=xml

- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3

- name: Start Terminal and exit
run: |
Expand Down
572 changes: 372 additions & 200 deletions CONTRIBUTING.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Crypto Technical Analysis Controller Module"""
__docformat__ = "numpy"
# pylint: disable=too-many-lines,R0904,C0201
# pylint: disable=C0302,R0904,C0201

import argparse
import logging
Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/miscellaneous/data_sources_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"epsfc": ["SeekingAlpha"],
"revfc": ["SeekingAlpha"],
"est": ["BusinessInsider"],
"pt": ["BusinessInsider"],
"pt": ["BusinessInsider", "FinancialModelingPrep"],
"dcf": ["StockAnalysis"],
"dcfc": ["FinancialModelingPrep"]
},
Expand Down
52 changes: 23 additions & 29 deletions openbb_terminal/stocks/fundamental_analysis/fa_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,7 @@ def call_pt(self, other_args: List[str]):
parser = argparse.ArgumentParser(
add_help=False,
prog="pt",
description="""Prints price target from analysts. [Source: Business Insider]""",
description="""Prints price target from analysts. [Source: Business Insider and Financial Modeling Prep]""",
)
parser.add_argument(
"-t",
Expand All @@ -1792,26 +1792,10 @@ def call_pt(self, other_args: List[str]):
type=str,
default=None,
)
parser.add_argument(
"--raw",
action="store_true",
dest="raw",
help="Only output raw data",
)
parser.add_argument(
"-l",
"--limit",
action="store",
dest="limit",
type=check_positive,
default=10,
help="Limit of latest price targets from analysts to print.",
)

if other_args and "-" not in other_args[0][0]:
other_args.insert(0, "-l")
ns_parser = self.parse_known_args_and_warn(
parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES
parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES, raw=True, limit=10
)
if ns_parser:
if ns_parser.ticker:
Expand All @@ -1821,17 +1805,27 @@ def call_pt(self, other_args: List[str]):
console.print(no_ticker_message)
return

business_insider_view.price_target_from_analysts(
symbol=self.ticker,
data=self.stock,
start_date=self.start,
limit=ns_parser.limit,
raw=ns_parser.raw,
export=ns_parser.export,
sheet_name=" ".join(ns_parser.sheet_name)
if ns_parser.sheet_name
else None,
)
if ns_parser.source == "BusinessInsider":
business_insider_view.price_target_from_analysts(
symbol=self.ticker,
data=self.stock,
start_date=self.start,
limit=ns_parser.limit,
raw=ns_parser.raw,
export=ns_parser.export,
sheet_name=" ".join(ns_parser.sheet_name)
if ns_parser.sheet_name
else None,
)
elif ns_parser.source == "FinancialModelingPrep":
hjoaquim marked this conversation as resolved.
Show resolved Hide resolved
fmp_view.display_price_targets(
symbol=self.ticker,
limit=ns_parser.limit,
export=ns_parser.export,
sheet_name=" ".join(ns_parser.sheet_name)
if ns_parser.sheet_name
else None,
)

@log_start_end(log=logger)
def call_est(self, other_args: List[str]):
Expand Down
39 changes: 38 additions & 1 deletion openbb_terminal/stocks/fundamental_analysis/fmp_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from openbb_terminal.core.session.current_user import get_current_user
from openbb_terminal.decorators import check_api_key, log_start_end
from openbb_terminal.helper_funcs import lambda_long_number_format
from openbb_terminal.helper_funcs import lambda_long_number_format, request
from openbb_terminal.rich_config import console
from openbb_terminal.stocks.fundamental_analysis.fa_helper import clean_df_index

Expand Down Expand Up @@ -779,3 +779,40 @@ def get_rating(symbol: str) -> pd.DataFrame:
else:
df = pd.DataFrame()
return df


@log_start_end(log=logger)
@check_api_key(["API_KEY_FINANCIALMODELINGPREP"])
def get_price_targets(symbol: str) -> pd.DataFrame:
"""Get price targets for a company [Source: Financial Modeling Prep]

Parameters
----------
symbol : str
Symbol to get data for

Returns
-------
pd.DataFrame
DataFrame of price targets
"""
current_user = get_current_user()

url = (
"https://financialmodelingprep.com/api/v4/price-target?"
f"symbol={symbol}&apikey={current_user.credentials.API_KEY_FINANCIALMODELINGPREP}"
)
response = request(url)

# Check if response is valid
if response.status_code != 200 or "Error Message" in response.json():
message = f"Error, Status Code: {response.status_code}."
message = (
message
if "Error Message" not in response.json()
else message + "\n" + response.json()["Error Message"] + ".\n"
)
console.print(message)
return pd.DataFrame()

return pd.DataFrame(response.json())
50 changes: 50 additions & 0 deletions openbb_terminal/stocks/fundamental_analysis/fmp_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import logging
import os
from datetime import datetime
from typing import Optional

import pandas as pd
Expand Down Expand Up @@ -817,3 +818,52 @@ def rating(
df,
sheet_name,
)


@log_start_end(log=logger)
@check_api_key(["API_KEY_FINANCIALMODELINGPREP"])
def display_price_targets(
symbol: str, limit: int = 10, export: str = "", sheet_name: Optional[str] = None
):
"""Display price targets for a given ticker. [Source: Financial Modeling Prep]

Parameters
----------
symbol : str
Symbol
limit: int
Number of last days ratings to display
export: str
Export dataframe data to csv,json,xlsx file
sheet_name: str
Optionally specify the name of the sheet the data is exported to.
"""
columns_to_show = [
"publishedDate",
"analystCompany",
"adjPriceTarget",
"priceWhenPosted",
]
price_targets = fmp_model.get_price_targets(symbol)
if price_targets.empty:
console.print(f"[red]No price targets found for {symbol}[/red]\n")
return
price_targets["publishedDate"] = price_targets["publishedDate"].apply(
lambda x: datetime.strptime(x, "%Y-%m-%dT%H:%M:%S.%fZ").strftime(
"%Y-%m-%d %H:%M"
)
)
export_data(
export,
os.path.dirname(os.path.abspath(__file__)),
"pt",
price_targets,
sheet_name,
)

print_rich_table(
price_targets[columns_to_show].head(limit),
headers=["Date", "Company", "Target", "Posted Price"],
show_index=False,
title=f"{symbol.upper()} Price Targets",
)
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Future Expectations:
epsfc Earning Estimate by Analysts - EPS [SeekingAlpha]
revfc Earning Estimate by Analysts - Revenue [SeekingAlpha]
est quarter and year analysts earnings estimates [BusinessInsider]
pt price targets over time [BusinessInsider]
pt price targets over time [BusinessInsider, FinancialModelingPrep]
dcf advanced Excel customizable discounted cash flow [StockAnalysis]
dcfc determine the (historical) discounted cash flow [FinancialModelingPrep]