mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-13 04:41:24 +00:00
Merge branch 'develop' into release/3.2.1
This commit is contained in:
@@ -35,7 +35,8 @@ def get_option_history(
|
||||
price : Union[str, Union[int, float]]
|
||||
Strike price for a specific option
|
||||
chain_id: str
|
||||
OCC option symbol. Overwrites other inputs
|
||||
Option symbol. Overwrites other inputs. ChartExchange uses the format:
|
||||
`{TICKER}{YYYYMMDD}{C/P}{PRICE}`, where the price has no leading and trailing zeros.
|
||||
|
||||
Returns
|
||||
-------
|
||||
|
||||
@@ -72,6 +72,7 @@ def display_raw(
|
||||
price: float = 90,
|
||||
limit: int = 10,
|
||||
chain_id: Optional[str] = None,
|
||||
raw: bool = False,
|
||||
export: str = "",
|
||||
sheet_name: Optional[str] = None,
|
||||
external_axes: bool = False,
|
||||
@@ -109,22 +110,27 @@ def display_raw(
|
||||
option_type = "call" if call else "put"
|
||||
fig = plot_chart(df, option_type, symbol, price)
|
||||
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"hist",
|
||||
df,
|
||||
sheet_name,
|
||||
fig,
|
||||
)
|
||||
print_rich_table(
|
||||
df,
|
||||
headers=list(df.columns),
|
||||
show_index=True,
|
||||
index_name="Date",
|
||||
title=f"{symbol.upper()} raw data",
|
||||
export=bool(export),
|
||||
limit=limit,
|
||||
)
|
||||
if export:
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"hist",
|
||||
df,
|
||||
sheet_name,
|
||||
fig,
|
||||
)
|
||||
return None
|
||||
|
||||
if raw:
|
||||
print_rich_table(
|
||||
df,
|
||||
headers=list(df.columns),
|
||||
show_index=True,
|
||||
index_name="Date",
|
||||
title="Historical Option Prices",
|
||||
export=bool(export),
|
||||
limit=limit,
|
||||
)
|
||||
return None
|
||||
|
||||
return fig.show(external=external_axes)
|
||||
|
||||
@@ -71,6 +71,8 @@ def display_historical(
|
||||
headers=[x.title() for x in df_hist.columns],
|
||||
title="Historical Option Prices",
|
||||
export=bool(export),
|
||||
show_index=True,
|
||||
index_name="Date",
|
||||
)
|
||||
|
||||
df_hist.columns = [x.title() for x in df_hist.columns]
|
||||
|
||||
@@ -800,6 +800,7 @@ class OptionsController(BaseController):
|
||||
call=not ns_parser.put,
|
||||
price=ns_parser.strike,
|
||||
limit=ns_parser.limit,
|
||||
raw=ns_parser.raw,
|
||||
export=ns_parser.export,
|
||||
chain_id=ns_parser.chain_id,
|
||||
sheet_name=" ".join(ns_parser.sheet_name)
|
||||
|
||||
@@ -72,6 +72,8 @@ def display_historical(
|
||||
headers=[x.title() for x in df_hist.columns],
|
||||
title="Historical Option Prices",
|
||||
export=bool(export),
|
||||
show_index=True,
|
||||
index_name="Date",
|
||||
)
|
||||
|
||||
op_type = ["call", "put"][put]
|
||||
|
||||
@@ -23,12 +23,12 @@ def vcr_config():
|
||||
@pytest.mark.vcr
|
||||
@pytest.mark.record_stdout
|
||||
@pytest.mark.parametrize(
|
||||
"tab",
|
||||
"raw",
|
||||
[True, False],
|
||||
)
|
||||
def test_display_raw(mocker, tab):
|
||||
def test_display_raw(mocker, raw):
|
||||
# MOCK CHARTS
|
||||
preferences = PreferencesModel(USE_TABULATE_DF=tab)
|
||||
preferences = PreferencesModel(USE_TABULATE_DF=raw)
|
||||
mock_current_user = copy_user(preferences=preferences)
|
||||
mocker.patch(
|
||||
target="openbb_terminal.core.session.current_user.__current_user",
|
||||
@@ -39,9 +39,5 @@ def test_display_raw(mocker, tab):
|
||||
mocker.patch(target="openbb_terminal.stocks.options.chartexchange_view.plot_chart")
|
||||
|
||||
chartexchange_view.display_raw(
|
||||
export="",
|
||||
symbol="GME",
|
||||
expiry="2021-02-05",
|
||||
call=True,
|
||||
price=90,
|
||||
export="", symbol="GME", expiry="2021-02-05", call=True, price=90, raw=raw
|
||||
)
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
Open High Low Close Change Volume Open Interest Change Since
|
||||
Date
|
||||
2021-01-25 20.70 85.70 13.90 20.00 0.00000 1834.0 552.0 -0.99850
|
||||
2021-01-26 27.50 75.79 21.00 70.17 2.50850 1763.0 572.0 -0.99957
|
||||
2021-01-27 210.20 285.50 70.80 255.90 2.64686 309.0 461.0 -0.99988
|
||||
2021-01-28 225.40 385.55 62.75 130.65 -0.48945 49.0 450.0 -0.99977
|
||||
2021-01-29 232.15 296.20 183.10 183.10 0.40145 37.0 445.0 -0.99984
|
||||
2021-02-01 232.60 232.60 133.09 133.09 -0.27313 107.0 441.0 -0.99977
|
||||
2021-02-02 64.61 76.20 18.50 23.70 -0.82193 1991.0 555.0 -0.99873
|
||||
2021-02-03 40.45 40.45 13.50 14.26 -0.39831 2124.0 1074.0 -0.99790
|
||||
2021-02-04 13.70 14.00 0.75 0.75 -0.94741 5945.0 2386.0 -0.96000
|
||||
2021-02-05 0.57 14.79 0.01 0.03 -0.96000 6580.0 2017.0 0.00000
|
||||
|
||||
Reference in New Issue
Block a user