Skip to main content

Stocks Screener

The Stocks Screener module imports the same screener found in the OpenBB Terminal. The screener utilizes presets (.ini files) to scan for stocks meeting the defined criteria. User-generated files are kept in the stocks/screener folder within the OpenBBUserData folder.

This screener can find stocks on three exchanges:

  • AMEX
  • NASDAQ
  • NYSE

The data returned is grouped into six categories:

  • Overview
  • Financial
  • Ownership
  • Performance
  • Technical
  • Valuation

The default preset is, top_gainers, and the default data type is, overview. Without the use of arguments, the screener will return results using those default values.

openbb.stocks.screener.screener_data()

This preset, like some of the others, contain no parameters other than a signal - the name of the preset - and has no corresponding file which can be edited. All signals are listed in the table below.

Preset and Signal NameDescription
top_gainersstocks with the highest % price gain today
top_losersstocks with the highest % price loss today
new_highstocks making 52-week high today
new_lowstocks making 52-week low today
most_volatilestocks with the highest widest high/low trading range today
most_activestocks with the highest trading volume today
unusual_volumestocks with unusually high volume today - the highest relative volume ratio
overboughtstock is becoming overvalued and may experience a pullback.
oversoldoversold stocks may represent a buying opportunity for investors
downgradesstocks downgraded by analysts today
upgradesstocks upgraded by analysts today
earnings_beforecompanies reporting earnings today, before market open
earnings_aftercompanies reporting earnings today, after market close
recent_insider_buyingstocks with recent insider buying activity
recent_insider_sellingstocks with recent insider selling activity
major_newsstocks with the highest news coverage today
horizontal_srhorizontal channel of price range between support and resistance trendlines
tl_resistanceonce a rising trendline is broken
tl_supportonce a falling trendline is broken
wedge_upupward trendline support and upward trendline resistance (reversal)
wedge_downdownward trendline support and downward trendline resistance (reversal)
wedgeupward trendline support, downward trendline resistance (contiunation)
triangle_ascendingupward trendline support and horizontal trendline resistance
triangle_descendinghorizontal trendline support and downward trendline resistance
channel_upboth support and resistance trendlines slope upward
channel_downboth support and resistance trendlines slope downward
channelboth support and resistance trendlines are horizontal
double_topstock with 'M' shape that indicates a bearish reversal in trend
double_bottomstock with 'W' shape that indicates a bullish reversal in trend
multiple_topsame as double_top hitting more highs
multiple_bottomsame as double_bottom hitting more lows
head_shoulderschart formation that predicts a bullish-to-bearish trend reversal
head_shoulders_inversechart formation that predicts a bearish-to-bullish trend reversal

These signals offer a good starting point, and results can be narrowed by creating a custom preset with defined parameters.

How to Use

note

Refer to the template file here for all of the available parameters and accepted values.

All of the included presets can be viewed online here

Without any parameters, a screener preset file must contain the following at a minimum:

# Author of preset:
# Description:

[General]

[Descriptive]

[Fundamental]

[Technical]

Parameters should be added as required, and they all have pre-defined values; for example, Price/Free Cash Flow:

# Any, Low (<15), High (>50), Under 5, Under 10, Under 15, Under 20, Under 25, Under 30, Under 35,
# Under 40, Under 45, Under 50, Under 60, Under 70, Under 80, Under 90, Under 100, Over 5, Over 10,
# Over 15, Over 20, Over 25, Over 30, Over 35, Over 40, Over 45, Over 50, Over 60, Over 70, Over 80,
# Over 90, Over 100

Price/Free Cash Flow = Any

Examples

List All Presets

The name of each available preset and the local path to the file can be imported as a dictionary.

from openbb_terminal.stocks.screener.finviz_model import preset_choices

preset choices

Print only the name of each preset as a list:

list(preset_choices)

Creating a Preset

To make a screener with only a few filters, it should look something like this:

# Author of preset: OpenBB
# Description: SDK Demo Screener

[General]
Order = Relative Volume
Signal = Major News

[Descriptive]
Average Volume = Over 500K
Price = Over $5

[Fundamental]
Price/Free Cash Flow = Low (<15)

[Technical]
Beta = Under 1

Copy the block above to a new text file in any editor, and save the file to the OpenBBUserData folder, naming it something like, sdk_guide_preset.ini. This preset has also been included with the installation. Declaring the path to the preset file, when located in the OpenBBUserData folder, is not required. The kernel must be restarted when a file is renamed or created; however, changes to the preset itself will be reflected immediately and without restarting.

It is a good idea to test choices made before making it too complicated. Start with a handful of filters and modify, or add, them one-at-a-time. Let's pass what we have so far through the screener with performance selected as the data_type.

Performance

openbb.stocks.screener.screener_data(preset_loaded='sdk_guide_preset', data_type = 'performance')
TickerPerf WeekPerf MonthPerf QuartPerf HalfPerf YearPerf YTDVolatility WVolatility MRecomAvg VolumeRel VolumePriceChangeVolume
0GEO0.13890.40050.45890.67230.39550.53420.05740.05582.52.09e+064.2311.890.16238.86013e+06
1EBS-0.0059-0.4513-0.5136-0.6429-0.7204-0.72920.04520.08272.77536102.9111.770.01382.19107e+06
2TME0.18710.79840.37210.5789-0.0531-0.03650.06810.07562.39.95e+062.26.60.06112.18486e+07
3QFIN0.08740.4331-0.0738-0.0744-0.389-0.3650.04720.07871.49970701.6214.560.08491.61386e+06
4ATHM0.02290.0391-0.1772-0.2256-0.1971-0.04550.04920.05792.25770501.628.140.0484922812
93TGNA0.0093-0.0514-0.0882-0.1073-0.05280.05330.01330.02862.31.38e+060.4519.550.0046620767
94AMN0.0096-0.03650.16850.25910.0558-0.00260.02430.04641.76074200.43122.01-0.0078264138
95MCY-0.00280.24160.1165-0.2619-0.3014-0.31910.02060.038625651300.4336.130.0036241950
96FIBK-0.0138-0.03550.0790.14110.06160.06810.01680.02062.25962800.4143.44-0.0044243947
97BPOP0.02170.0126-0.0777-0.1245-0.1108-0.1280.01580.023625964600.471.540.0007238605

It found just under 100 tickers meeting the criteria. Let's dial down the beta value to see how many remain at less than 0.5.

Change the one argument:

[Technical]
Beta = Under 0.5

Running the exact same command as before trims down the list to only eleven.

openbb.stocks.screener.screener_data(preset_loaded='sdk_guide_preset', data_type = 'performance')
TickerPerf WeekPerf MonthPerf QuartPerf HalfPerf YearPerf YTDVolatility WVolatility MRecomAvg VolumeRel VolumePriceChangeVolume
0QFIN0.08740.4331-0.0738-0.0744-0.389-0.3650.04720.07871.49970701.6214.560.08491.61386e+06
1ATHM0.02290.0391-0.1772-0.2256-0.1971-0.04550.04920.05792.25770501.628.140.0484922812
2JD0.01430.4065-0.1343-0.0511-0.379-0.22090.0290.04541.89.14e+061.4753.250.06691.34395e+07
3NI0.02560.0518-0.0844-0.13420.0784-0.01380.01510.02571.94.61e+061.3627.230.00046.2667e+06
4ZTO0.11760.3862-0.0572-0.1073-0.216-0.13930.04470.04371.73.21e+060.9624.050.02173.06905e+06
5QDEL-0.058-0.06140.077-0.1232-0.4438-0.38280.03350.04082.36426800.7983.32-0.018508575
6ED0.02280.0888-0.0203-0.02980.19850.12870.01490.02023.51.73e+060.7796.3-0.00251.3419e+06
7SFM0.0270.12790.16560.2370.2370.1290.02490.0343.21.54e+060.7433.51-0.00951.14442e+06
8PINC0.0244-0.0549-0.0635-0.1125-0.1377-0.19360.01580.02172.65192900.7233.20.0097373171
9AEP0.01610.0587-0.066-0.07230.13610.06380.0180.0222.23.19e+060.6494.65-0.0062.04444e+06
10LRN-0.00250.0796-0.0594-0.08460.03980.07410.02070.02881.45877700.4635.8-0.0047270842
11AMN0.0096-0.03650.16850.25910.0558-0.00260.02430.04641.76074200.43122.01-0.0078264138

Overview

We know know that these eleven companies have a beta relative to the S&P of under 0.5, and that they all have a price-to-free-cashflow ratio under 15. The signal argument has also been set as Major News, so we know at least this much about the companies and their relative performance over the last year. Setting the data_type to 'overview', will fetch the data which helps us understand who these companies are.

openbb.stocks.screener.screener_data(preset_loaded='sdk_guide_preset', data_type = 'overview')
TickerCompanySectorIndustryCountryMarket CapP/EPriceChangeVolume
0QFIN360 DigiTech, Inc.FinancialCredit ServicesChina2.19e+093.7314.560.08491.61386e+06
1ATHMAutohome Inc.Communication ServicesInternet Content & InformationChina3.49e+0916.9628.140.0484922812
2JDJD.com, Inc.Consumer CyclicalInternet RetailChina8.152e+10300.8553.250.06691.34395e+07
3NINiSource Inc.UtilitiesUtilities - Regulated GasUSA1.09e+1017.6927.230.00046.2667e+06
4ZTOZTO Express (Cayman) Inc.IndustrialsIntegrated Freight & LogisticsChina1.947e+1024.6724.050.02173.06905e+06
5QDELQuidelOrtho CorporationHealthcareDiagnostics & ResearchUSA5.53e+094.9683.32-0.018508575
6EDConsolidated Edison, Inc.UtilitiesUtilities - Regulated ElectricUSA3.366e+1020.2196.3-0.00251.3419e+06
7SFMSprouts Farmers Market, Inc.Consumer DefensiveGrocery StoresUSA3.57e+0914.6733.51-0.00951.14442e+06
8PINCPremier, Inc.HealthcareHealth Information ServicesUSA3.92e+0921.5233.20.0097373171
9AEPAmerican Electric Power Company, Inc.UtilitiesUtilities - Regulated ElectricUSA4.791e+1019.6394.65-0.0062.04444e+06
10LRNStride, Inc.Consumer DefensiveEducation & Training ServicesUSA1.54e+0916.7435.8-0.0047270842
11AMNAMN Healthcare Services, Inc.HealthcareMedical Care FacilitiesUSA5.4e+0911.76122.01-0.0078264138

Ownership

When data_type = 'ownership', data presented are statistics for the general float, insider, institutional, and the short ratio.

openbb.stocks.screener.screener_data(preset_loaded='sdk_guide_preset', data_type = 'ownership')
TickerMarket CapOutstandingFloatInsider OwnInsider TransInst OwnInst TransFloat ShortShort RatioAvg VolumePriceChangeVolume
0QFIN2.19e+091.5624e+081.2743e+080.065400.6910.00340.02262.8999707014.560.08491.61386e+06
1ATHM3.49e+091.246e+086.846e+07nannan0.513-0.03970.02132.5357705028.140.0484922812
2JD8.152e+101.56e+091.26e+090.04900.161-0.11490.01361.889.14e+0653.250.06691.34395e+07
3NI1.09e+104.065e+084.0459e+080.00100.948-0.02540.03453.044.61e+0627.230.00046.2667e+06
4ZTO1.947e+108.0973e+086.4491e+080.007100.3150.03450.02414.833.21e+0624.050.02173.06905e+06
5QDEL5.53e+096.69e+076.092e+070.01100.9730.00580.05154.8864268083.32-0.018508575
6ED3.366e+103.546e+083.5443e+080.0010.00560.6840.00820.02064.221.73e+0696.3-0.00251.3419e+06
7SFM3.57e+091.0723e+081.0362e+080.008-0.1276nan-0.02870.13869.311.54e+0633.51-0.00951.14442e+06
8PINC3.92e+091.1835e+081.1817e+080.00800.707-0.00440.01363.151929033.20.0097373171
9AEP4.791e+105.1373e+085.137e+080.0003-0.03360.7580.00330.01292.073.19e+0694.65-0.0062.04444e+06
10LRN1.54e+094.208e+074.082e+070.040nan0.01580.08085.6158777035.8-0.0047270842
11AMN5.4e+094.378e+074.299e+070.003-0.0868nan0.01480.09836.96607420122.01-0.0078264138

Technical

With data_type set to technical, aspects of technical analysis is returned.

openbb.stocks.screener.screener_data(preset_loaded='sdk_guide_preset', data_type = 'technical')
TickerBetaATRSMA20SMA50SMA20052W High52W LowRSIPriceChangefrom OpenGapVolume
0QFIN0.371.110.10610.1107-0.0206-0.39530.537556.614.560.08490.03410.04921.61386e+06
1ATHM0.191.89-0.0324-0.0405-0.1047-0.31180.373447.1328.140.04840.00570.0425922812
2JD0.393.30.11410.1183-0.0584-0.3860.605458.0753.250.0669-0.00390.07111.34395e+07
3NI0.440.620.0490.0498-0.0598-0.16430.145161.6227.230.00040.0052-0.00486.2667e+06
4ZTO-0.091.140.17240.0968-0.0412-0.25650.478265.4424.050.02170.00210.01953.06905e+06
5QDEL0.293.46-0.06660.0262-0.1185-0.53730.245842.1883.32-0.018-0.0180508575
6ED0.321.830.05740.08430.0365-0.05780.242666.8896.3-0.00250.002-0.00451.3419e+06
7SFM0.411.120.05840.14460.1605-0.05180.485463.9933.51-0.0095-0.0053-0.00411.14442e+06
8PINC0.360.70.0322-0.0004-0.0711-0.20420.077355.1933.20.00970.0125-0.0027373171
9AEP0.412.070.04560.0559-0.0117-0.10370.179961.6294.65-0.0060.0005-0.00652.04444e+06
10LRN0.251.360.0302-0.0923-0.0562-0.24390.395744.8535.8-0.0047-0.0014-0.0033270842
11AMN0.34.850.0110.05990.1431-0.05510.474454.13122.01-0.0078-0.0059-0.0019264138

Valuation

Lastly, valuation gets the basic fundamental ratios.

TickerPriceChangeVolumeMarket CapP/EFwd P/EPEGP/SP/BP/CP/FCFEPS this YEPS next YEPS past 5YEPS next 5YSales past 5Y
0AAPL141.17-0.0211835788522.23252e+1223.1420.742.65.6644.6746.2223.110.0890.08980.2160.08890.115
1MSFT240.33-0.0059179297051.77308e+1225.921.491.998.7310.3216.5339.590.1980.17090.2430.13010.155
2GOOG95.44-0.0084201450811.23434e+1218.6818.042.094.384.88N/AN/A-0.1590.1210.28480.0895N/A
3GOOGL95.19-0.009200478481.21605e+1219.5118.122.184.314.8910.4619.440.9140.11390.3210.08950.233
4AMZN92.42-0.0163652457239.3352e+1185.2655.083.281.866.8515.91N/A0.5490.82390.6760.260.281
...continued

Combined, the five DataFrames provide an outline of who they are, which segment of the market they belong to, and how they are currently trading.

Unconventional Applications

One way to use the screener is to feed it the least amount of variables possible. In this next example, the preset file contains only one filter; requesting data for all constituents of the S&P 500 Index.

# Author of preset: OpenBB
# Description: S&P Index

[General]
Order = Market Cap.

[Descriptive]
Index = S&P 500

[Fundamental]

[Technical]

Copy and past the block above into any text editor; then save the file, as sp500_filter.ini, to the ~/OpenBBUserData/presets/stocks/screener folder. The sample code below combines all five DataFrames for the entire S&P 500 into one, fifty-column, DataFrame. It will likely take over two-minutes to collect the data.

from openbb_terminal.sdk import openbb
import pandas as pd

sp500_overview = openbb.stocks.screener.screener_data(preset_loaded='sp500_filter', data_type = 'overview')
sp500_ownership = openbb.stocks.screener.screener_data(preset_loaded='sp500_filter', data_type = 'ownership')
sp500_performance = openbb.stocks.screener.screener_data(preset_loaded='sp500_filter', data_type = 'performance')
sp500_technical = openbb.stocks.screener.screener_data(preset_loaded='sp500_filter', data_type = 'technical')
sp500_valuation = openbb.stocks.screener.screener_data(preset_loaded='sp500_filter', data_type = 'valuation')

sp500_overview = sp500_overview.convert_dtypes()
sp500_ownership = sp500_ownership.convert_dtypes()
sp500_performance = sp500_performance.convert_dtypes()
sp500_technical = sp500_technical.convert_dtypes()
sp500_valuation = sp500_valuation.convert_dtypes()

sp500_overview.drop(columns = ['P/E'], inplace = True)
sp500_overview.set_index(keys = ['Ticker', 'Price', 'Change', 'Volume'], inplace = True)
sp500_performance.drop(columns = ['Avg Volume', 'Price', 'Change', 'Volume'], inplace = True)
sp500_performance.set_index(keys = ['Ticker'], inplace = True)
sp500_ownership.drop(columns = ['Price', 'Change', 'Volume', 'Market Cap'], inplace = True)
sp500_ownership.set_index(keys = ['Ticker'], inplace = True)
sp500_technical.drop(columns = ['Price', 'Change', 'Volume'], inplace = True)
sp500_technical.set_index(keys = ['Ticker'], inplace = True)
sp500_valuation.drop(columns = ['Price', 'Change', 'Volume', 'Market Cap'], inplace = True)
sp500_valuation.set_index(keys = ['Ticker'], inplace = True)

sp500_df = sp500_overview.join(sp500_valuation)
sp500_df = sp500_df.join(sp500_ownership)
sp500_df = sp500_df.join(sp500_performance)
sp500_df = sp500_df.join(sp500_technical)

sp500_df.reset_index(inplace = True)

sp500_df

A summary of the output:

    Ticker   Price  Change    Volume  ... 52W Low    RSI from Open     Gap
0 AAPL 141.17 -0.0211 83578852 ... 0.094 42.47 -0.0211 0.0
1 MSFT 240.33 -0.0059 17929705 ... 0.126 50.94 -0.0044 -0.0015
2 GOOG 95.44 -0.0084 20145081 ... 0.1437 48.17 -0.0052 -0.0032
3 GOOGL 95.19 -0.009 20047848 ... 0.1422 48.24 -0.0063 -0.0027
4 AMZN 92.42 -0.0163 65245723 ... 0.0763 38.54 -0.0167 0.0004
.. ... ... ... ... ... ... ... ... ...
498 LUMN 5.47 -0.0091 31885469 ... 0.0018 30.19 -0.0036 -0.0054
499 PENN 34.07 0.0119 1689121 ... 0.3366 50.3 0.0068 0.005
500 NWL 12.87 -0.0191 5725896 ... 0.051 40.29 -0.01 -0.0091
501 VNO 25.31 0.0218 2560781 ... 0.2636 59.59 0.0181 0.0036
502 PVH 64.88 0.0399 1100532 ... 0.4918 66.83 0.0328 0.0069

[503 rows x 50 columns]