Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Market Status #2176

Closed
wants to merge 6 commits into from
Closed

Market Status #2176

wants to merge 6 commits into from

Conversation

R5dan
Copy link
Contributor

@R5dan R5dan commented Dec 10, 2024

Adds a class for Market Status. Different from Market Summary although that does include part of the data.

@R5dan
Copy link
Contributor Author

R5dan commented Dec 10, 2024

Ruff is wrong by the way. The imports are used

@ValueRaider
Copy link
Collaborator

Ruff is wrong by the way. The imports are used

Ruff is right. You're looking at the wrong file.

@R5dan
Copy link
Contributor Author

R5dan commented Dec 10, 2024

Ruff is wrong by the way. The imports are used

Ruff is right. You're looking at the wrong file.

Yeah, hadn't read it properly. Don't know why I was even in search.py

@ValueRaider
Copy link
Collaborator

Bug:

Traceback (most recent call last):
  File "./test.py", line 1, in <module>
    import yfinance as yf
  File "yfinance/__init__.py", line 23, in <module>
    from .status import Status
  File "yfinance/status.py", line 7, in <module>
    from datetime import (
ImportError: cannot import name 'deltatime' from 'datetime' (/usr/lib64/python3.12/datetime.py). Did you mean: 'datetime'?

@R5dan
Copy link
Contributor Author

R5dan commented Dec 12, 2024

Bug:

Traceback (most recent call last):
  File "./test.py", line 1, in <module>
    import yfinance as yf
  File "yfinance/__init__.py", line 23, in <module>
    from .status import Status
  File "yfinance/status.py", line 7, in <module>
    from datetime import (
ImportError: cannot import name 'deltatime' from 'datetime' (/usr/lib64/python3.12/datetime.py). Did you mean: 'datetime'?

Fixed that, sorry its timedelta not deltatime

@R5dan
Copy link
Contributor Author

R5dan commented Dec 12, 2024

I currently am getting:

requests.exceptions.SSLError: HTTPSConnectionPool(host='query1.finance.yahoo.com', port=443): Max retries exceeded with url: /v1/test/getcrumb (Caused by SSLError(SSLCertVerificationError(1, "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Hostname mismatch, certificate is not valid for 'query1.finance.yahoo.com'. (_ssl.c:1020)")))

when requesting data from yfinance. How do I stop this?

@ValueRaider
Copy link
Collaborator

when requesting data from yfinance. How do I stop this?

wrong thread

@R5dan
Copy link
Contributor Author

R5dan commented Dec 12, 2024

when requesting data from yfinance. How do I stop this?

wrong thread

? I am only getting this with this patch. That is why it is here not on a separate issue.

@ValueRaider
Copy link
Collaborator

Max retries exceeded with url: /v1/test/getcrumb

Nothing to do with this branch, and doesn't happen to me.

Also your branch is riddled with bugs.

@ValueRaider ValueRaider marked this pull request as draft December 12, 2024 23:02
@R5dan
Copy link
Contributor Author

R5dan commented Dec 13, 2024

@ValueRaider fixed bugs.

@ValueRaider
Copy link
Collaborator

ValueRaider commented Dec 14, 2024

yf.Status("US")

  File "./test.py", line 7, in <module>
    yf.Status("US")
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "yfinance/status.py", line 26, in __init__
    self._parse_data(True)
  File "yfinance/status.py", line 55, in _parse_data
    self._fetch_data()
  File "yfinance/status.py", line 45, in _fetch_data
    type_change = self._raw_data["duration"][0]
                  ~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'duration'

@R5dan
Copy link
Contributor Author

R5dan commented Dec 14, 2024

  File "./test.py", line 7, in <module>
    x = yf.Status("US", session=session)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "yfinance/status.py", line 26, in __init__
    self._parse_data(True)
  File "yfinance/status.py", line 55, in _parse_data
    self._fetch_data()
  File "yfinance/status.py", line 45, in _fetch_data
    type_change = self._raw_data["duration"][0]

What code did you use for this? And what is the actual error @ValueRaider

@ValueRaider
Copy link
Collaborator

commit fd309bd

@R5dan
Copy link
Contributor Author

R5dan commented Dec 14, 2024

I can't tell if you are telling me to commit it or that that is the error? @ValueRaider

@ValueRaider
Copy link
Collaborator

I thought you were asking code version, because the code I ran is in the stack trace. I've added error message.

@R5dan
Copy link
Contributor Author

R5dan commented Dec 16, 2024

I think they must have edited that API. That used to be how long that section would last (when yfit_market_status changed). Also just noticed spelling mistake in the commit message

@R5dan
Copy link
Contributor Author

R5dan commented Dec 16, 2024

Is there anything else you want me to add or change? @ValueRaider

@ValueRaider
Copy link
Collaborator

ValueRaider commented Dec 17, 2024

Like with your other branch, don't unpack the dict into class attributes, just return a dict. You can parse its values but still return a dict.

@R5dan
Copy link
Contributor Author

R5dan commented Dec 17, 2024

Done @ValueRaider anything else?

@R5dan R5dan marked this pull request as ready for review December 18, 2024 21:12
@R5dan
Copy link
Contributor Author

R5dan commented Dec 19, 2024

@ValueRaider Can this be merged?

@ValueRaider
Copy link
Collaborator

ValueRaider commented Dec 19, 2024

Almost, but where you parse into attributes e.g. fromisoformat just overwrite the dict. Seems less work for everyone. Basically reduce to a simple function with optional argument raw=True.

@R5dan
Copy link
Contributor Author

R5dan commented Dec 19, 2024

What about storing it? It seems silly to reparse data every time when I feel more people will use the parsed on (especially as is_open is a custom property I defined as that is it's most likely use. The other 4 are also all going to be common uses. I'm happy to change it but can you tell me what to change as I don't get what your asking for. @ValueRaider

@R5dan R5dan closed this Jan 3, 2025
@R5dan
Copy link
Contributor Author

R5dan commented Jan 3, 2025

Closing as added to market summary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants