Skip to content

Commit

Permalink
Feature/some cleaning (#4170)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoaquim authored Feb 9, 2023
1 parent 4f915e6 commit 424d073
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 339 deletions.
98 changes: 0 additions & 98 deletions openbb_terminal/economy/econ_data_helper.py

This file was deleted.

46 changes: 0 additions & 46 deletions openbb_terminal/stocks/stocks_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,52 +803,6 @@ def display_candle(
return data


def load_ticker(
ticker: str,
start_date: Union[str, datetime],
end_date: Optional[Union[str, datetime]] = None,
) -> pd.DataFrame:
"""Load a ticker data from Yahoo Finance.
Adds a data index column data_id and Open-Close High/Low columns after loading.
Parameters
----------
ticker : str
The stock ticker.
start_date : Union[str,datetime]
Start date to load stock ticker data formatted YYYY-MM-DD.
end_date : Union[str,datetime]
End date to load stock ticker data formatted YYYY-MM-DD.
Returns
-------
DataFrame
A Panda's data frame with columns Open, High, Low, Close, Adj Close, Volume,
date_id, OC-High, OC-Low.
Examples
--------
>>> from openbb_terminal.sdk import openbb
>>> msft_df = openbb.stocks.load("MSFT")
"""
df_data = yf.download(
ticker, start=start_date, end=end_date, progress=False, ignore_tz=True
)

df_data.index = pd.to_datetime(df_data.index)

df_data["date_id"] = (df_data.index.date - df_data.index.date.min()).astype(
"timedelta64[D]"
)
df_data["date_id"] = df_data["date_id"].dt.days + 1

df_data["OC_High"] = df_data[["Open", "Close"]].max(axis=1)
df_data["OC_Low"] = df_data[["Open", "Close"]].min(axis=1)

return df_data


def process_candle(data: pd.DataFrame) -> pd.DataFrame:
"""Process DataFrame into candle style plot.
Expand Down
180 changes: 0 additions & 180 deletions tests/openbb_terminal/economy/test_econ_data_helper.py

This file was deleted.

6 changes: 3 additions & 3 deletions tests/openbb_terminal/stocks/backtesting/test_bt_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def mock_yf_download(*args, **kwargs):
ticker = "PM"
start = datetime.strptime("2020-12-01", "%Y-%m-%d")
end = datetime.strptime("2020-12-02", "%Y-%m-%d")
df_stock = stocks_helper.load_ticker(ticker=ticker, start_date=start, end_date=end)
df_stock = stocks_helper.load(symbol=ticker, start_date=start, end_date=end)
back_test_instance = bt_model.ema_strategy(
symbol=ticker,
data=df_stock,
Expand All @@ -83,7 +83,7 @@ def mock_yf_download(*args, **kwargs):
ticker = "PM"
start = datetime.strptime("2020-12-01", "%Y-%m-%d")
end = datetime.strptime("2020-12-02", "%Y-%m-%d")
df_stock = stocks_helper.load_ticker(ticker=ticker, start_date=start, end_date=end)
df_stock = stocks_helper.load(symbol=ticker, start_date=start, end_date=end)
back_test_instance = bt_model.emacross_strategy(
symbol=ticker,
data=df_stock,
Expand All @@ -109,7 +109,7 @@ def mock_yf_download(*args, **kwargs):
ticker = "PM"
start = datetime.strptime("2020-12-01", "%Y-%m-%d")
end = datetime.strptime("2020-12-02", "%Y-%m-%d")
df_stock = stocks_helper.load_ticker(ticker=ticker, start_date=start, end_date=end)
df_stock = stocks_helper.load(symbol=ticker, start_date=start, end_date=end)
back_test_instance = bt_model.rsi_strategy(
symbol=ticker,
data=df_stock,
Expand Down
6 changes: 3 additions & 3 deletions tests/openbb_terminal/stocks/backtesting/test_bt_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def mock_yf_download(*args, **kwargs):
ticker = "PM"
start = datetime.strptime("2020-12-01", "%Y-%m-%d")
end = datetime.strptime("2020-12-02", "%Y-%m-%d")
df_stock = stocks_helper.load_ticker(ticker=ticker, start_date=start, end_date=end)
df_stock = stocks_helper.load(symbol=ticker, start_date=start, end_date=end)
bt_view.display_simple_ema(
symbol=ticker,
data=df_stock,
Expand All @@ -63,7 +63,7 @@ def mock_yf_download(*args, **kwargs):
ticker = "PM"
start = datetime.strptime("2020-12-01", "%Y-%m-%d")
end = datetime.strptime("2020-12-02", "%Y-%m-%d")
df_stock = stocks_helper.load_ticker(ticker=ticker, start_date=start, end_date=end)
df_stock = stocks_helper.load(symbol=ticker, start_date=start, end_date=end)
bt_view.display_emacross(
symbol=ticker,
data=df_stock,
Expand Down Expand Up @@ -92,7 +92,7 @@ def mock_yf_download(*args, **kwargs):
ticker = "PM"
start = datetime.strptime("2020-12-01", "%Y-%m-%d")
end = datetime.strptime("2020-12-02", "%Y-%m-%d")
df_stock = stocks_helper.load_ticker(ticker=ticker, start_date=start, end_date=end)
df_stock = stocks_helper.load(symbol=ticker, start_date=start, end_date=end)
bt_view.display_rsi_strategy(
symbol=ticker,
data=df_stock,
Expand Down
9 changes: 0 additions & 9 deletions tests/openbb_terminal/stocks/test_stocks_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,3 @@ def test_display_candle(mocker, use_matplotlib):
use_matplotlib=use_matplotlib,
intraday=intraday,
)


@pytest.mark.vcr
def test_load_ticker(recorder):
ticker = "PM"
start = datetime.strptime("2020-12-01", "%Y-%m-%d")
end = datetime.strptime("2020-12-02", "%Y-%m-%d")
result_df = stocks_helper.load_ticker(ticker=ticker, start_date=start, end_date=end)
recorder.capture(result_df)

0 comments on commit 424d073

Please sign in to comment.