TradingView Screener in Python

tradingview
Author

im@johnho.ca

Published

Tuesday, February 4, 2025

Abstract
Pythonic TradingView Screener as pandas dataframe using tradingview-screener

TradingView Screener Demo

while PineScreener is a premium feature in TradingView, the vanilla Stock Screener is free and now there’s even a python package for it: tradingview-screener

So maybe this could be your first step in creating your own PineScreener with python!

All the filters available on TradingView are accessible. The package come with a very convenient search tool for it here.

As demo, below is my screener for:

  • US ETFs
  • non-OTC
  • non-leveraged
  • has NAV total return of over 5% (“risk-free” rate) for the last year
  • has over $1mm dollar traded per day
from tradingview_screener import Query, col

screen = (Query()
    .select('name', 'exchange', 'close', 'volume', 'Perf.Y', 'nav_total_return.1Y', 'description')
    .where(
        col('typespecs').has(['etf']),
        col('leveraged_flag') == "Non-leveraged",
        col('exchange')!= 'OTC', 
        col("Value.Traded|1")>1000000,
        col('nav_total_return.1Y')> 0.05
        )
    .order_by('Perf.Y', ascending=False)
    .limit(10))
screen.set_markets('america')

r = screen.get_scanner_data()
df_screen = r[1]
df_screen
ticker name exchange close volume Perf.Y nav_total_return.1Y description
0 NASDAQ:IBIT IBIT NASDAQ 56.8900 26369182 129.858586 139.121541 iShares Bitcoin Trust
1 AMEX:FXI FXI AMEX 32.5565 32561098 50.654789 47.915148 iShares China Large-Cap ETF
2 AMEX:GLD GLD AMEX 262.3500 7281528 40.387960 39.503670 SPDR Gold Trust
3 NASDAQ:QQQ QQQ NASDAQ 524.1500 17021515 22.143240 21.611925 Invesco QQQ Trust, Series 1
4 AMEX:VTI VTI AMEX 298.4250 1910055 21.890700 23.032064 Vanguard Total Stock Market ETF
5 AMEX:SPY SPY AMEX 601.6300 17737501 21.862689 22.799563 SPDR S&P 500 ETF TRUST
6 AMEX:IWM IWM AMEX 226.4900 11364919 17.675482 17.967812 iShares Russell 2000 ETF
7 CBOE:XJH XJH CBOE 42.9900 75643 15.876011 16.666597 iShares ESG Screened S&P Mid-Cap ETF
8 AMEX:DIA DIA AMEX 445.6500 1114115 15.456359 17.696816 SPDR Dow Jones Industrial Average ETF
9 AMEX:RSP RSP AMEX 180.6799 4873530 14.819459 16.699148 Invesco S&P 500 Equal Weight ETF

Conclusion

with programmatic access to TradingView’s screener, this open up the possibility of building many cool applications for investment research. Here’s a few ideas I have:

  • funds discovery in other markets: the screener works in many markets (for the full list see here) so could we use this screener to narrow down stocks with specific features we are looking for? (e.g. finding a MicroStrategy type stock but in Hong Kong?)
  • ETFs leaderboard: like LMArena but for ETFs and we evaluate base on a few curated metrics like Max-Drawdown, Sortino Ratio, Gain-to-Pain ratio, etc.
  • Identify Outperformers: for ETFs trading on the same underlying, could we identify ones that consistently outperform maybe for long-short opportunities? Or just simply a lower risk way to invest into an asset?

what other ideas would this mean for you?