Skip to content

Commit

Permalink
Resolved merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
colin99d committed Feb 27, 2023
2 parents f7cdce0 + 0d5fa09 commit 4640126
Show file tree
Hide file tree
Showing 111 changed files with 37,118 additions and 1,074 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

| OpenBB is committed to build the future of investment research by focusing on an open source infrastructure accessible to everyone, everywhere. |
|:--:|
| ![openbb.jpg](/images/openbb_gradient.png) |
| [![openbb.jpg](/images/openbb_gradient.png)](https://openbb.co) |
| Check our website at [openbb.co](https://openbb.co) |

<br />
Expand Down
2 changes: 0 additions & 2 deletions build/pyinstaller/terminal.spec
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ added_files = [
(os.path.join(pathex, "user_agent"), "user_agent"),
(os.path.join(pathex, "vaderSentiment"), "vaderSentiment"),
(os.path.join(pathex, "prophet"), "prophet"),
(os.path.join(pathex, "frozendict", "VERSION"), "frozendict"),
(
os.path.join(pathex, "linearmodels", "datasets"),
os.path.join("linearmodels", "datasets"),
Expand Down Expand Up @@ -99,7 +98,6 @@ hidden_imports = [
"statsmodels",
"user_agent",
"vaderSentiment",
"frozendict",
"pyEX",
"feedparser",
"_sysconfigdata__darwin_darwin",
Expand Down
5 changes: 3 additions & 2 deletions openbb_terminal/config_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@
API_POLYGON_KEY = os.getenv("OPENBB_API_POLYGON_KEY") or "REPLACE_ME"

# https://developer.twitter.com
API_TWITTER_KEY = os.getenv("OPENBB_API_TWITTER_KEY") or "REPLACE_ME"
API_TWITTER_SECRET_KEY = os.getenv("OPENBB_API_TWITTER_SECRET_KEY") or "REPLACE_ME"
API_TWITTER_BEARER_TOKEN = os.getenv("OPENBB_API_TWITTER_BEARER_TOKEN") or "REPLACE_ME"

# https://fred.stlouisfed.org/docs/api/api_key.html
Expand Down Expand Up @@ -202,3 +200,6 @@

# https://intrinio.com/starter-plan
API_INTRINIO_KEY = os.getenv("OPENBB_API_INTRINIO_KEY") or "REPLACE_ME"

# https://databento.com/
API_DATABENTO_KEY = os.getenv("OPENBB_API_DATABENTO_KEY") or "REPLACE_ME"
23 changes: 20 additions & 3 deletions openbb_terminal/core/integration_tests/integration_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from multiprocessing.pool import Pool
from pathlib import Path
from traceback import FrameSummary, extract_tb, format_list
from typing import Any, Dict, List, Optional, Tuple
from typing import Any, Callable, Dict, List, Optional, Tuple

from openbb_terminal.core.config.paths import (
MISCELLANEOUS_DIRECTORY,
Expand Down Expand Up @@ -353,6 +353,7 @@ def run_test_files(
verbose: bool = False,
special_arguments: Optional[Dict[str, str]] = None,
subprocesses: Optional[int] = None,
ordered: bool = False,
) -> Tuple[int, int, Dict[str, Dict[str, Any]], float]:
"""Runs the test scripts and returns the fails dictionary
Expand All @@ -366,6 +367,8 @@ def run_test_files(
The special arguments to use in the scripts
subprocesses: Optional[int]
The number of subprocesses to use to run the tests
ordered: bool
Multiprocessing is not ordered by default. Use this flag to run the tests in order
Returns
-------
Expand Down Expand Up @@ -410,8 +413,10 @@ def run_test_files(
if extra:
chunksize += 1

runner: Callable = pool.imap if ordered else pool.imap_unordered

for i, result in enumerate(
pool.imap(
runner(
partial(
run_test,
verbose=verbose,
Expand Down Expand Up @@ -531,6 +536,7 @@ def run_test_session(
special_arguments: Optional[Dict[str, str]] = None,
verbose: bool = False,
subprocesses: Optional[int] = None,
ordered: bool = False,
):
"""Run the integration test session
Expand All @@ -552,11 +558,13 @@ def run_test_session(
Whether or not to print the output of the scripts
subprocesses
The number of subprocesses to use to run the tests
ordered: bool
Multiprocessing is not ordered by default. Use this flag to run the tests in order.
"""
console.print(to_section_title("integration test session starts"), style="bold")
test_files = collect_test_files(path_list, skip_list)
n_successes, n_failures, fails, seconds = run_test_files(
test_files, verbose, special_arguments, subprocesses
test_files, verbose, special_arguments, subprocesses, ordered
)
display_failures(fails)
display_summary(fails, n_successes, n_failures, seconds)
Expand Down Expand Up @@ -645,6 +653,14 @@ def parse_args_and_run():
action="store_true",
default=False,
)
parser.add_argument(
"-o",
"--ordered",
help="Multiprocessing is not ordered by default. Use this flag to run the tests in order.",
dest="ordered",
action="store_true",
default=False,
)
for arg in special_arguments_values:
parser.add_argument(
f"--{arg}",
Expand Down Expand Up @@ -680,6 +696,7 @@ def parse_args_and_run():
special_arguments=special_args_dict,
verbose=ns_parser.verbose,
subprocesses=ns_parser.subprocesses,
ordered=ns_parser.ordered,
)


Expand Down
23 changes: 10 additions & 13 deletions openbb_terminal/core/log/generation/directories.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# IMPORTATION STANDARD
import os
import uuid
from pathlib import Path

Expand All @@ -14,25 +13,23 @@
def get_log_dir() -> Path:
"""Retrieve application's log directory."""

log_dir = USER_DATA_DIRECTORY.joinpath("logs")
log_dir = USER_DATA_DIRECTORY.joinpath("logs").absolute()

if not os.path.isdir(log_dir.absolute()):
os.mkdir(log_dir.absolute())
if not log_dir.is_dir():
log_dir.mkdir(parents=True, exist_ok=True)

log_id = log_dir.absolute().joinpath(".logid")
log_id = (log_dir / ".logid").absolute()

if not os.path.isfile(log_id.absolute()):
if not log_id.is_file():
logging_id = f"{uuid.uuid4()}"
with open(log_id.absolute(), "a") as a_file:
a_file.write(f"{logging_id}\n")
log_id.write_text(logging_id, encoding="utf-8")
else:
with open(log_id.absolute()) as a_file:
logging_id = a_file.readline().rstrip()
logging_id = log_id.read_text(encoding="utf-8").rstrip()

uuid_log_dir = log_dir.absolute().joinpath(logging_id)
uuid_log_dir = (log_dir / logging_id).absolute()

if not os.path.isdir(uuid_log_dir.absolute()):
os.mkdir(uuid_log_dir.absolute())
if not uuid_log_dir.is_dir():
uuid_log_dir.mkdir(parents=True, exist_ok=True)

return uuid_log_dir

Expand Down
16 changes: 12 additions & 4 deletions openbb_terminal/cryptocurrency/cryptocurrency_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,19 @@ def load(
start_date: Optional[Union[datetime, Union[str, None]]] = None,
interval: Union[str, int] = "1440",
exchange: str = "binance",
to_symbol: str = "usdt",
to_symbol: str = "usd",
end_date: Optional[Union[datetime, Union[str, None]]] = None,
source: str = "CCXT",
source: str = "CoinGecko",
) -> pd.DataFrame:
"""Load crypto currency to get data for
"""
Load crypto currency to get data for
Note:
take into consideration that the data might not be found if the data provider
(example) uses `usd` instead of `usdt` as the quote currency, so you might need to adjust
the `to_symbol` parameter.
For `CCXT` a valid pair would be: "BTC/USDT"
For `CoinGecko` a valid pair would be: "BTC-USD"
For `YahooFinance` a valid pair would be: "BTC-USD"
Parameters
----------
Expand Down Expand Up @@ -549,7 +557,7 @@ def load(
if isinstance(interval, int):
interval = str(interval)
if start_date is None:
start_date = (datetime.now() - timedelta(days=1100)).strftime("%Y-%m-%d")
start_date = (datetime.now() - timedelta(days=365)).strftime("%Y-%m-%d")

if end_date is None:
end_date = datetime.now().strftime("%Y-%m-%d")
Expand Down
42 changes: 2 additions & 40 deletions openbb_terminal/economy/economy_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ class EconomyController(BaseController):
"map",
"rtps",
"bigmac",
"ycrv",
# "spread",
"events",
"edebt",
]
Expand Down Expand Up @@ -254,7 +252,6 @@ def print_help(self):
mt.add_cmd("futures")
mt.add_cmd("map")
mt.add_cmd("bigmac")
mt.add_cmd("ycrv")
mt.add_cmd("events")
mt.add_cmd("edebt")
mt.add_raw("\n")
Expand Down Expand Up @@ -623,7 +620,8 @@ def call_macro(self, other_args: List[str]):
self.DATASETS["macro"].drop(column, axis=1, inplace=True)

self.DATASETS["macro"] = pd.concat(
[self.DATASETS["macro"], df], axis=1
[self.DATASETS["macro"], df],
axis=1,
)

# update units dict
Expand Down Expand Up @@ -1042,42 +1040,6 @@ def call_treasury(self, other_args: List[str]):
if obbff.ENABLE_EXIT_AUTO_HELP:
self.print_help()

@log_start_end(log=logger)
def call_ycrv(self, other_args: List[str]):
"""Process ycrv command"""
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prog="ycrv",
description="Generate country yield curve. The yield curve shows the bond rates"
" at different maturities.",
)
parser.add_argument(
"-d",
"--date",
type=valid_date,
help="Date to get data from FRED. If not supplied, the most recent entry will be used.",
dest="date",
default=None,
)
ns_parser = self.parse_known_args_and_warn(
parser,
other_args,
export_allowed=EXPORT_ONLY_RAW_DATA_ALLOWED,
raw=True,
)
if ns_parser:
fred_view.display_yield_curve(
date=ns_parser.date.strftime("%Y-%m-%d") if ns_parser.date else "",
raw=ns_parser.raw,
export=ns_parser.export,
sheet_name=" ".join(ns_parser.sheet_name)
if ns_parser.sheet_name
else None,
)

# TODO: Add `Investing` to sources again when `investpy` is fixed

@log_start_end(log=logger)
def call_events(self, other_args: List[str]):
"""Process events command"""
Expand Down
103 changes: 0 additions & 103 deletions openbb_terminal/economy/fred_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import logging
import os
import textwrap
from datetime import datetime, timedelta
from typing import List, Optional, Tuple

import certifi
Expand Down Expand Up @@ -247,105 +246,3 @@ def get_aggregated_series_data(
data[s_id] = series[s_id]

return data, detail


@log_start_end(log=logger)
@check_api_key(["API_FRED_KEY"])
def get_yield_curve(
date: str = "", return_date: bool = False
) -> Tuple[pd.DataFrame, str]:
"""Gets yield curve data from FRED
Parameters
----------
date: str
Date to get curve for. If empty, gets most recent date (format yyyy-mm-dd)
return_date: bool
If True, returns date of yield curve
Returns
-------
Tuple[pd.DataFrame, str]
Dataframe of yields and maturities,
Date for which the yield curve is obtained
Examples
--------
>>> from openbb_terminal.sdk import openbb
>>> ycrv_df = openbb.economy.ycrv()
Since there is a delay with the data, the most recent date is returned and can be accessed with return_date=True
>>> ycrv_df, ycrv_date = openbb.economy.ycrv(return_date=True)
"""

# Necessary for installer so that it can locate the correct certificates for
# API calls and https
# https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error/73270162#73270162
# os.environ["REQUESTS_CA_BUNDLE"] = certifi.where()
# os.environ["SSL_CERT_FILE"] = certifi.where()

fredapi_client = Fred(cfg.API_FRED_KEY)
fred_series = {
"1Month": "DGS1MO",
"3Month": "DGS3MO",
"6Month": "DGS6MO",
"1Year": "DGS1",
"2Year": "DGS2",
"3Year": "DGS3",
"5Year": "DGS5",
"7Year": "DGS7",
"10Year": "DGS10",
"20Year": "DGS20",
"30Year": "DGS30",
}
df = pd.DataFrame()
# Check that the date is in the past
today = datetime.now().strftime("%Y-%m-%d")
if date and date >= today:
console.print("[red]Date cannot be today or in the future[/red]")
if return_date:
return pd.DataFrame(), date
return pd.DataFrame()

# Add in logic that will get the most recent date.
get_last = False

if not date:
date = (datetime.now() - timedelta(days=7)).strftime("%Y-%m-%d")
get_last = True

for key, s_id in fred_series.items():
df = pd.concat(
[
df,
pd.DataFrame(fredapi_client.get_series(s_id, date), columns=[key]),
],
axis=1,
)
if df.empty:
if return_date:
return pd.DataFrame(), date
return pd.DataFrame()
# Drop rows with NaN -- corresponding to weekends typically
df = df.dropna()

if date not in df.index or get_last:
# If the get_last flag is true, we want the first date, otherwise we want the last date.
idx = -1 if get_last else 0
date_of_yield = df.index[idx].strftime("%Y-%m-%d")
rates = pd.DataFrame(df.iloc[idx, :].values, columns=["Rate"])
else:
date_of_yield = date
series = df[df.index == date]
if series.empty:
return pd.DataFrame(), date_of_yield
rates = pd.DataFrame(series.values.T, columns=["Rate"])

rates.insert(
0,
"Maturity",
[1 / 12, 0.25, 0.5, 1, 2, 3, 5, 7, 10, 20, 30],
)
if return_date:
return rates, date_of_yield
return rates
Loading

0 comments on commit 4640126

Please sign in to comment.