shner-elmo / TradingView-Screener

A package that lets you create TradingView screeners in Python
https://shner-elmo.github.io/TradingView-Screener/2.5.0/tradingview_screener.html
MIT License
270 stars 43 forks source link

Is there a top_gainers field in Scanner.names() #45

Closed akash02ita closed 2 months ago

akash02ita commented 2 months ago

I was wondering if it is also possible to see top_gainers.

shner-elmo commented 2 months ago

I haven't added it there, but you can use this query:

top_gainers = (
 Query()
 .select('change')
 .where(
     Column('exchange').isin(['AMEX', 'NASDAQ', 'NYSE']),
     Column('is_primary') == True,
     Column('typespecs').has('common'),
     Column('typespecs').has_none_of('preferred'),
     Column('type') == 'stock',
     Column('close').between(2, 10000),
     Column('change') > 0,
     Column('active_symbol') == True,
 )
 .order_by('change', ascending=False)
 .set_markets('america')
 )
top_gainers.query['preset'] = 'gainers'

top_gainers.get_scanner_data()
(2733,          ticker      change
  0    NASDAQ:GDC  127.906977
  1   NASDAQ:REVB  101.271186
  2   NASDAQ:SDIG   82.252560
  3   NASDAQ:VRAX   79.775281
  4   NASDAQ:NEON   51.488095
  ... 
  45   NASDAQ:CYN   12.219451
  46  NASDAQ:CAPR   11.980440
  47  NASDAQ:GRRR   11.864407
  48  NASDAQ:GLUE   11.815068
  49  NASDAQ:CCLD   11.808118)
shner-elmo commented 2 months ago

I think you can also just set the preset and order_by('change', ascending=False) to achieve the same result