Skip to content

Commit

Permalink
Adjust and fix according to feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
marcofognog committed May 11, 2024
1 parent 5a683b9 commit 7628bec
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 28 deletions.
22 changes: 0 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,28 +268,6 @@ details on your rights to use the actual data downloaded.

---

### Running Tests

Tests have been written using the built-in Python module `unittest`

An example of running all tests in a file that calls `unittest.main`:

```sh
python -m unittest tests.test_prices
```

An example of running a test of a single method (applicable to a class as well):

```sh
python -m unittest tests.test_prices.TestPriceRepair.test_ticker_missing
```

To run all tests

```sh
python -m unittest discover -s tests
```

### P.S.

Please drop me an note with any feedback you have.
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ frozendict>=2.3.4
beautifulsoup4>=4.11.1
html5lib>=1.1
peewee>=3.16.2
requests_cache>=1.0
requests-ratelimiter>=0.3.1
2 changes: 1 addition & 1 deletion yfinance/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class YFTickerMissingError(YFException):
def __init__(self, ticker, rationale):
super().__init__(f"${ticker}: possibly delisted; {rationale}")
self.rationale = rationale
self.ticker = rationale
self.ticker = ticker


class YFTzMissingError(YFTickerMissingError):
Expand Down
2 changes: 1 addition & 1 deletion yfinance/scrapers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def history(self, period="1mo", interval="1d",
# Check can get TZ. Fail => probably delisted
tz = self.tz
if tz is None:
# Every valid ticker has a timezone. A missing timezone is a problem problem
# Every valid ticker has a timezone. A missing timezone is a problem.
_exception = YFTzMissingError(self.ticker)
err_msg = str(_exception)
shared._DFS[self.ticker] = utils.empty_df()
Expand Down
4 changes: 2 additions & 2 deletions yfinance/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def _download_options(self, date=None):
r = self._data.get(url=url, proxy=self.proxy).json()
if len(r.get('optionChain', {}).get('result', [])) > 0:
for exp in r['optionChain']['result'][0]['expirationDates']:
self._expirations[_datetime.datetime.fromtimestamp(exp).strftime('%Y-%m-%d')] = exp
assert _datetime.datetime.utcfromtimestamp(exp).strftime('%Y-%m-%d') in self._expirations
self._expirations[_datetime.datetime.utcfromtimestamp(
exp).strftime('%Y-%m-%d')] = exp

self._underlying = r['optionChain']['result'][0].get('quote', {})

Expand Down

0 comments on commit 7628bec

Please sign in to comment.