-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Redo Screener #2190
base: dev
Are you sure you want to change the base?
Redo Screener #2190
Conversation
|
The return types on the Screener are wrong (for example
I go into the source code to work out what types different properties are as when I run code (which would be correct with the types) it fails (due to incorrect type) I also have to go looking for what string literals are allowed in
Mostly fixed it with this PR. Take a look if you want. I also made the the types run faster and be more runtime safe: by putting the type in a string it only has to construct a string and not the full class and it also means it's easier to fix circular import errors or the class not actually existing for some reason as some of them could be moved under |
@ValueRaider What do you think? |
Improve how user sets up a screener query with a simpler intermediate form:
Should shorten the screener html page by a lot. |
Should I also add #154 into this one? |
ok |
@ValueRaider any other predefined keys you know off? Still don't know where you found that 52 week gain |
Also why is |
I just navigated the gainers webpage with Firefox network inspector open. |
@ValueRaider Still need to add proper logging (not just print statements) and docs etc, but what do you think of this. {
"finance":
{
"result":null,
"error":
{
"code":"internal-error",
"description":"sort field is not a field: fundnetassets"
}
}
} returned by yahoo. I don't understand why as this part is the same as the original and that works fine. Any ideas? |
self._body_updated = True | ||
self._body = body | ||
return self | ||
|
||
def patch_body(self, values: Dict) -> 'Screener': | ||
|
||
def patch_body(self, offset: 'int' = 0, size: 'int' = 100, sortField: 'str' = "ticker", sortType: 'str' = "desc", quoteType: 'str' = "equity", userId: 'str' = "", userIdType: 'str' = "guid"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this result in unintentional updates of certain fields?
i.e. user with body offset = 50, goes to patch the sortField but offset will reset to 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it would, except it is not implemented yet. Will change it when I do implement it
fetch and parse the screener results, and access predefined screener bodies. | ||
""" | ||
def __init__(self, session=None, proxy=None): | ||
class PredefinedScreener: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need a separate class for this? Isn't this just a Screener with pre-defined fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it sends a different request to a different endpoint with a different response
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you access the yahoo's screener via: https://finance.yahoo.com/research-hub/screener, the request is made to the same endpoint for the pre-defined queries.
imho, it's better to not create a separate class for this to allow user to construct a Screener
that reflects the pre-defined body, and edit it as they need for flexibility. i.e. offset, or exchange requirements.
Weird, I don't get that error: from yfinance.screener import Screener
predefined = Screener.predefined("day_gainers", count=25) |
Below are just my two cents: I think this affects more than just I'm actually not sure what problem this PR is trying to solve anymore.
This was done so future developers can extend to different types of queries but leverage the same screener class. i.e.
I personally have a preference for using the typing module instead for readability and maintainability. |
It was initially just to edit the Types but then I was asked to fix the Query and EntityQuery and make screener better and easier. I understand what you are saying about having no direction, it is now to redo the screener to make it easier to use and make custom queries etc.
Personally I generally prefer as little from typing as possible (except certain things)
Yes, I am going to add more, just wanted to see whether people like this, or want specific and overall changes before implementing more specific, adding docs and tests, I just wanted to get something working. This is a draft pr so far. |
Ok, I have your code running now. I've deleted those comments to tidy this thread and get back on track.
Might be my fault. I only just now understand that @ericpien implemented a |
Do you want me to stop this then? |
Pause for now. I'll look more over weekend. |
@ValueRaider Made a decision? Are you just going to go with #2207 |
I was just checking. Wanted to see if you wanted me to continue or not, so Ill pause for now. |
It is annoying that the types are wrong on
Screener
, I find myself looking at the source code to determine the types of theScreener
class so this is a fix