GithubHelp home page GithubHelp logo

shner-elmo / tradingview-screener Goto Github PK

View Code? Open in Web Editor NEW
139.0 10.0 22.0 186 KB

A package that lets you create TradingView screeners in Python

Home Page: https://shner-elmo.github.io/TradingView-Screener/tradingview_screener.html

License: MIT License

Python 100.00%
live-data stock stock-market stock-screener trading tradingview crypto forex quant quantitative-finance

tradingview-screener's People

Contributors

shner-elmo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tradingview-screener's Issues

Query to filter with "above of below %"

Hi, the new v2 screener of Trading view allows to have filters like this: "Price above New Low 52 Weeks by 100% or more"

I try to implement this filter with the Query() I add a multiplier (*2) at the end of Column('price_52_week_low'):

(Query()
.select('name', 'close', 'price_52_week_low')
.where(
Column('close') >= (Column('price_52_week_low')*2 ) ,
)
.get_scanner_data())

but get this error:

Traceback (most recent call last):
File "", line 4, in
TypeError: unsupported operand type(s) for +: 'int' and 'Column'

Is there any other way to implement this kind of filters using the "above of below %"?

Thank you

Retrieve the next earnings date for a ticker but did receive a float not a date

My idea was to retrieve the next earnings date for a ticker so I checked your code and I think I found the corresponding column to use.
So I tried the customer screener with this query:

Python code used:
tmp = (Query()
.select('name', 'earnings_release_date','Recent Earnings Date','earnings_release_next_date')
.get_scanner_data())
df = tmp[1]
df[df.name == 'PFE']['earnings_release_next_date']

but getting floats instead of dates:

  ticker name  earnings_release_date  earnings_release_date earnings_release_next_date

48 NYSE:PFE PFE 1.706615e+09 1.706615e+09 1.714478e+09

Can you please help/fix?

Column('Change (1,5, etc)m, %') always returns an error when using .get_scanner_data()

I was testing with the scanner and can't seem to get get passed this error. It seems to be occurring for all the 'Change xm, %'s.

Error:
Exception has occurred: HTTPError 400 Client Error: Bad Request Body: {"totalCount":0,"error":"Unknown field \"change.5\"","data":null} for url: https://scanner.tradingview.com/america/scan File "N:\StockTrading\Live\StockScreener\StockScreener.py", line 20, in <module> .get_scanner_data()) requests.exceptions.HTTPError: 400 Client Error: Bad Request Body: {"totalCount":0,"error":"Unknown field \"change.5\"","data":null} for url: https://scanner.tradingview.com/america/scan

Full code:

from tradingview_screener import Scanner, Query, Column

_, scalpers = (Query()
 .select('name')
 .where(
     Column('Relative Volume') > 1.5,
     Column('relative_volume_10d_calc') > 1.5,
     Column('Change %') >= 8,
 )
 .get_scanner_data())

breakouts = (Query()
 .select('name')
 .where(
     Column('Relative Volume') > 3,
     Column('relative_volume_10d_calc') > 3,
     Column('Relative Volume at Time') > 3,
     Column('Change 5m, %') >= 5
 )
 .get_scanner_data())
#
#_, breakouts = breakouts  # Unpack the tuple to ignore the count and get the DataFrame
## Extract the 'name' column
#tickers = tickers.extend(breakouts['name'].tolist())

print(scalpers['name'].tolist())

Scanner does not return data but Website does

I observed that not always data gets returned.
_, df = Query().select('name', 'close', 'earnings_release_date',, 'earnings_release_next_date').get_scanner_data()

On 07. Feb 2024 for eaxmple for CRUS:
df[df.name == 'CRUS'][['name', 'close', 'earnings_release_date', 'earnings_release_next_date']]
Empty DataFrame
Columns: [name, close, earnings_release_date, earnings_release_next_date]
Index: []

but on TradingView Earnings View/Screener page they are listed for today after Market
image

Why is this? Anything else required to retrieve the data?

Time lag in the result

thanks for the work for this great tool and it works like a charm.

Just realized that the result from the API has a few minutes lag compare to the result directly form the tradingview.

I am a premium user of tradingview. From the website you can't do much as a guest, which is the API's role fetching the data.

No sure what cause the lag. If we need to login to get realtime result, can the tool add this feature in the future? Thanks.

Comparing current close price with previous days

It would be helpful to allow the query to compare current price to previous price. For example, if we want to create a scanner that can identify stocks that had 3 down days, and today's low is lower than yesterday's low and current price is higher than yesterday's low.

Selected column is not appearing in the DataFrame

Hello Shneor,

Thank you very much for your reply. Much appreciated.

i am running a query which allows me to extract one of the fields I am interested in, 'Revenue (Quarterly QoQ Growth'. I believe it is held in a JSON but could be wrong on this. I am trying to understand how I can place the output from this query into a dataframe? From there I can then manipulate the data, plot it and so on.

image

Thank you very much,

Stephen

cannot import name 'Screener' from 'tradingview_screener'

I'm trying to run my python script, even on Replit i get everytime
"Traceback (most recent call last):
File "C:\xxx\tradinview\index.py", line 1, in
from tradingview_screener import Screener
ImportError: cannot import name 'Screener' from 'tradingview_screener'"

Relative volume query change

Hello It seems like the 'Relative Volume': 'relative_volume_10d_calc' no longer works. It seems like the general 10 day relative volume has been changed to custom values.

image

Getting data directly from the Tradingview website/URL

Coming from the Time lag issue here, is it possible (to get around a paid account "requirement") for non-delayed data to get it from the Tradingview website directly (screener or markets URL)? I know there are some scrappers exist, but for non-delayed data on the website we have to be signed in with a free account (and I haven't seen this function in them). So my questions are:

  1. How can we get the website data through requests (without having a browser window always open like with scrappers)?
  2. How can we sign in with a free account through requests to make sure the data would be non-delayed?
  3. (optional) Is it possible that free account cookies sent through API don't let us be/stay signed in to get non-delayed data from API? How to check this?

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.