Skip to content

Commit

Permalink
Remove unpacking of results
Browse files Browse the repository at this point in the history
  • Loading branch information
R5dan committed Dec 17, 2024
1 parent 2d1ed95 commit c237faf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 37 deletions.
22 changes: 12 additions & 10 deletions doc/source/reference/examples/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
# Get the market status of america
US = yf.Status("US")

# Get the status

US.status

# Get when the market opens

# Get the open time
US.open

# Get when the market closes

# Get the close time
US.close

# Get the whether the market is open
# Get the timezone
US.timezone

# Get the request time
US.request_time

# Get the market status
US.is_open

US.is_open
# Get the rest of the data
US.data
30 changes: 3 additions & 27 deletions yfinance/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,42 +76,18 @@ def _parse_data(self, force:'bool'=False):
self._is_open = True if self._raw_data["status"] == "open" else False

@property
def raw_data(self):
def data(self):
self._parse_data()
return self._raw_data

@property
def id(self) -> 't.Optional[str]':
return self.raw_data.get("id", None)

@property
def name(self) -> 'str':
return self.raw_data.get("name", None)

@property
def status(self) -> 't.Literal["open", "closed", None]':
return self.raw_data.get("status", None)

@property
def yf_market_id(self) -> 't.Optional[str]':
return self.raw_data.get("yfit_market_id", None)


@property
def close(self) -> 't.Optional[dt]':
return self._close

@property
def message(self) -> 't.Optional[str]':
return self.raw_data.get("message", None)

@property
def open(self) -> 't.Optional[dt]':
return self._open

@property
def yf_status(self) -> 't.Optional[str]': # Move research needed for specific string literals
return self.raw_data.get("yfit_market_status", None)


@property
def request_time(self) -> 't.Optional[dt]':
return self._time
Expand Down

0 comments on commit c237faf

Please sign in to comment.