Repository: ranaroussi/yfinance

Issue:
Method `history_metadata` generating error of invalid period
### Describe bug

When using the method `history_metadata`, the result is returned correctly but an error log is also generated (which gets reported to our bug tracking system) saying the period `1wk` is invalid.

### Simple code that reproduces your problem

```python
import yfinance
yfinance.Ticker(ticker='fskax').history_metadata["regularMarketPrice"]
```

### Debug log

```
DEBUG    Entering _fetch_ticker_tz()
DEBUG     Entering get()
DEBUG      url=https://query2.finance.yahoo.com/v8/finance/chart/FSKAX
DEBUG      params=frozendict.frozendict({'range': '1d', 'interval': '1d'})
DEBUG      Entering _get_cookie_and_crumb()
DEBUG       cookie_mode = 'basic'
DEBUG       Entering _get_cookie_and_crumb_basic()
DEBUG        fetched basic cookie = <Cookie A3=d=AQABBP1KZGYCEGT5aoIId-40kAB4KfYEtNoFEgEBAQGcZWZuZtxH0iMA_eMAAA&S=AQAAAuUVoyau8cJbVNIEa7wKsko for .yahoo.com/>
DEBUG        reusing cookie
DEBUG        crumb = '6nn8IaNfskZ'
DEBUG       Exiting _get_cookie_and_crumb_basic()
DEBUG      Exiting _get_cookie_and_crumb()
DEBUG      response code=200
DEBUG     Exiting get()
DEBUG    Exiting _fetch_ticker_tz()
DEBUG    Entering history()
DEBUG     FSKAX: Yahoo GET parameters: {'range': '1wk', 'interval': '1h', 'includePrePost': True, 'events': 'div,splits,capitalGains'}
DEBUG     Entering get()
DEBUG      url=https://query2.finance.yahoo.com/v8/finance/chart/FSKAX
DEBUG      params={'range': '1wk', 'interval': '1h', 'includePrePost': True, 'events': 'div,splits,capitalGains'}
DEBUG      Entering _get_cookie_and_crumb()
DEBUG       cookie_mode = 'basic'
DEBUG       Entering _get_cookie_and_crumb_basic()
DEBUG        reusing cookie
DEBUG        reusing crumb
DEBUG       Exiting _get_cookie_and_crumb_basic()
DEBUG      Exiting _get_cookie_and_crumb()
DEBUG      response code=200
DEBUG     Exiting get()
ERROR     FSKAX: Period '1wk' is invalid, must be one of ['1mo', '3mo', '6mo', 'ytd', '1y', '2y', '5y', '10y', 'max']
DEBUG    Exiting history()
146.34
```

### Bad data proof

_No response_

### `yfinance` version

0.2.40

### Python version

3.12.3

### Operating system

_No response_


Discussion:
I'm getting errors pulling 1d as well for mutual funds. MERFX, ARCIX pulling 1d throws an invalid period error. These worked fine in last release:

MERFX: Period '1d' is invalid, must be one of ['1mo', '3mo', '6mo', 'ytd', '1y', '2y', '5y', '10y', 'max']

Resolving patch:
diff --git a/yfinance/scrapers/history.py b/yfinance/scrapers/history.py
--- a/yfinance/scrapers/history.py
+++ b/yfinance/scrapers/history.py
@@ -265,6 +265,7 @@ def history(self, period="1mo", interval="1d",
             tps = self._history_metadata["tradingPeriods"]
             if not isinstance(tps, pd.DataFrame):
                 self._history_metadata = utils.format_history_metadata(self._history_metadata, tradingPeriodsOnly=True)
+                self._history_metadata_formatted = True
                 tps = self._history_metadata["tradingPeriods"]
             quotes = utils.fix_Yahoo_returning_prepost_unrequested(quotes, params["interval"], tps)
         logger.debug(f'{self.ticker}: OHLC after cleaning: {quotes.index[0]} -> {quotes.index[-1]}')
@@ -391,7 +392,7 @@ def history(self, period="1mo", interval="1d",
     def get_history_metadata(self, proxy=None) -> dict:
         if self._history_metadata is None:
             # Request intraday data, because then Yahoo returns exchange schedule.
-            self.history(period="1wk", interval="1h", prepost=True, proxy=proxy)
+            self.history(period="5d", interval="1h", prepost=True, proxy=proxy)
 
         if self._history_metadata_formatted is False:
             self._history_metadata = utils.format_history_metadata(self._history_metadata)


Test patch: