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

[Feature] Add Finviz Screener Presets (V3 Compatible) #6601

Merged
merged 10 commits into from
Jul 30, 2024

Conversation

deeleeramone
Copy link
Contributor

  1. Why?:

  2. What?:

Below is copied from the README.md

Screener

The screener is a faithful replication of the public-facing stock screener - https://finviz.com/screener.ashx?

Some options are directly accessible through the function parameters, all others are exposed via presets or filters_dict.
The filters list below are exposed in the function, with choices visible in the docstring:

  • exchange
  • index
  • sector
  • industry
  • mktcap
  • recommendation (analyst's mean score from 1-5)
  • signal (same as the "Signal" on the Finviz page)

When the function is run without any parameters, it will default to the "top_gainers" signal.

res = obb.equity.screener(provider="finviz")

Metric

The metric parameter defines the type of data fields to return. Choices are:

  • overview
  • ownership
  • performance
  • techincal
  • valuation

Default is, "overview".

res = obb.equity.screener(provider="finviz", metric="performance")

Preset Files

Presets can be created and customized in the "OpenBBUserData" folder. Template and default presets are created on the first run of the function.

Files are loaded on run time, changes are effective without restarting the Python interpreter.

The preset parameter will override all others, except metric and limit.

Run the function to create the template and default presets in your OpenBBUserData folder.

Presets from the legacy OpenBB Terminal will continue to work, simply move your presets into the folder below.

res = obb.equity.screener(provider="finviz", index="nasdaq")

Then find the presets here: $HOME/OpenBBUserData/presets/finviz

res = obb.equity.screener(provider="finviz", preset="short_squeeze")

Filters Dict

The filters_dict parameter acts as an alternative to preset, accepting a dictionary or JSON encoded string.

res = obb.equity.screener(provider="finviz", filters_dict={"Index": "NASDAQ 100"})

Or as a JSON:

res = obb.equity.screener(provider="finviz", filters_dict='{"Index": "NASDAQ 100"}')

When using the Fast API, this is sent in the request body.

Error Messages

All parameters are validated, incorrect keys and choices will raise an error with information to help correct. For example:

obb.equity.screener(provider="finviz", filters_dict='{"Index": "NASDAQ"}')
Invalid filter option 'NASDAQ'. Possible filter options: ['Any', 'S&P 500', 'NASDAQ 100', 'DJIA', 'RUSSELL 2000']
  1. Impact:

    • The function will attempt to read/write to the file system in order to populate the user data folder.
    • Makes the function's docstring substantially larger.
  2. Testing Done:

    • Unit/integration tests.
    • CLI
  3. Reviewer Notes:

    • To test the function directly from the Swagger docs, the contents of the "Request Body" must be deleted.

@deeleeramone deeleeramone added enhancement Enhancement platform OpenBB Platform v4 PRs for v4 labels Jul 29, 2024
@IgorWounds IgorWounds added this pull request to the merge queue Jul 30, 2024
Merged via the queue into develop with commit a4ed8ab Jul 30, 2024
14 checks passed
@IgorWounds IgorWounds deleted the feature/finviz-screener-presets branch July 30, 2024 16:19
@mmistroni
Copy link
Contributor

mmistroni commented Aug 7, 2024

Brilliant! works as a charm! when will be available via pip? i guess i'll have to install a new version of openbb-finviz?
tried also the REST API.. works fine but the filter_dict params cannot be used.. seems because the method is a GET it does not allow a body? i guess this is expected..
Kind regards
Marco

@yolotrader
Copy link

@IgorWounds I'm getting the following error when running the preset:
Screenshot 2024-08-29 at 10 19 54 AM

Could you pls take a look?

Thank you for this great work, btw!

@mmistroni
Copy link
Contributor

mmistroni commented Aug 29, 2024 via email

@mmistroni
Copy link
Contributor

mmistroni commented Aug 30, 2024

@yolotrader that's just a warning, which is controlled by your preferences

"preferences" : {
"output_type" : "dataframe",
"show_warnings" : "False"

}

if you print out the result you will see data
Note, you will see this warningr for any presets you use..

hth

2024-08-30

@yolotrader
Copy link

@mmistroni thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking_change enhancement Enhancement platform OpenBB Platform v4 PRs for v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants