summaryrefslogtreecommitdiffstats
path: root/openbb_platform/providers/cboe/openbb_cboe/models/options_chains.py
diff options
context:
space:
mode:
Diffstat (limited to 'openbb_platform/providers/cboe/openbb_cboe/models/options_chains.py')
-rw-r--r--openbb_platform/providers/cboe/openbb_cboe/models/options_chains.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/openbb_platform/providers/cboe/openbb_cboe/models/options_chains.py b/openbb_platform/providers/cboe/openbb_cboe/models/options_chains.py
index c1c0602d3cc..ca049ee80a7 100644
--- a/openbb_platform/providers/cboe/openbb_cboe/models/options_chains.py
+++ b/openbb_platform/providers/cboe/openbb_cboe/models/options_chains.py
@@ -39,11 +39,6 @@ class CboeOptionsChainsQueryParams(OptionsChainsQueryParams):
class CboeOptionsChainsData(OptionsChainsData):
"""CBOE Options Chains Data."""
- last_trade_timestamp: Optional[datetime] = Field(
- description="Last trade timestamp of the option.", default=None
- )
- dte: int = Field(description="Days to expiration for the option.")
-
class CboeOptionsChainsFetcher(
Fetcher[
@@ -51,7 +46,7 @@ class CboeOptionsChainsFetcher(
List[CboeOptionsChainsData],
]
):
- """Transform the query, extract and transform the data from the CBOE endpoints."""
+ """Cboe Options Chains Fetcher."""
@staticmethod
def transform_query(params: Dict[str, Any]) -> CboeOptionsChainsQueryParams:
@@ -137,7 +132,6 @@ class CboeOptionsChainsFetcher(
"theo": "theoretical_price",
"percent_change": "change_percent",
"prev_day_close": "prev_close",
- "last_trade_time": "last_trade_timestamp",
}
)
@@ -162,7 +156,9 @@ class CboeOptionsChainsFetcher(
option_df_index.expiration = DatetimeIndex(
option_df_index.expiration, yearfirst=True
).astype(str)
- option_df_index = option_df_index.drop(columns=["Ticker"])
+ option_df_index = option_df_index.rename(
+ columns={"Ticker": "underlying_symbol"}
+ )
# Joins the parsed symbol into the dataframe.
@@ -173,20 +169,22 @@ class CboeOptionsChainsFetcher(
temp_ = (temp - now).days + 1
quotes["dte"] = temp_
- quotes["last_trade_timestamp"] = (
- to_datetime(quotes["last_trade_timestamp"], format="%Y-%m-%dT%H:%M:%S")
+ quotes["last_trade_time"] = (
+ to_datetime(quotes["last_trade_time"], format="%Y-%m-%dT%H:%M:%S")
.fillna(value="-")
.replace("-", None)
)
quotes = quotes.set_index(
keys=["expiration", "strike", "option_type"]
).sort_index()
+ if results_metadata.get("current_price"):
+ quotes["underlying_price"] = results_metadata["current_price"]
quotes["open_interest"] = quotes["open_interest"].astype("int64")
quotes["volume"] = quotes["volume"].astype("int64")
quotes["bid_size"] = quotes["bid_size"].astype("int64")
quotes["ask_size"] = quotes["ask_size"].astype("int64")
- quotes["prev_close"] = round(quotes["prev_close"], 2)
- quotes["change_percent"] = round(quotes["change_percent"] / 100, 4)
+ quotes["prev_close"] = quotes["prev_close"]
+ quotes["change_percent"] = quotes["change_percent"] / 100
return AnnotatedResult(
result=[