A python module to scrape tradingview's technical analysis.
Author: deathlyface
Scrape analysis from TradingView, ex: from XLMBTC, to a list. Works by using selenium webdriver to scrape elements from tradingview's technical analysis widget.
Using pip:
pip install tradingview_ta
from tradingview_ta import TA_Handler
xlmbtc = TA_Handler()
xlmbtc.symbol = "xlmbtc"
xlmbtc.interval = "1m"
#xlmbtc.driver = "chrome"
#xlmbtc.headless = True
xlmbtc.start_driver()
analysis = xlmbtc.get_analysis()
print(analysis)
#Example output: ["Buy", 3, 10, 17]
from tradingview_ta import TA_Handler
ta_instance = TA_Handler()
It does not have to be ta_instance
. Name it whatever you want!
ta_instance.symbol = "SYMBOL NAME"
Pair/Ticker/Symbol example: "btcusdt", "googl", "aapl", etc.
You may use the exchanger's name too, for example: "binance:btcusdt" or "nasdaq:aapl"
ta_instance.interval = "INTERVAL"
Available interval (case-sensitive):
- "1m" for 1 minute.
- "5m" for 5 minutes.
- "15m" for 15 minutes.
- "1h" for 1 hour.
- "4h" for 4 hours.
- "1D" for 1 day.
- "1W" for 1 week.
- "1M" for 1 month.
ta_instance.driver = "WEBDRIVER NAME"
Available webdriver (case-insensitive):
- Chrome
- Firefox
- Safari
- Edge
- Heroku (Unofficial, please follow EXACTLY this youtube video for set-up tutorial)
See selenium's documentation for webdriver installation.
ta_instance.headless = True/False
Headless means no GUI, so no browser tab will be opened.
ta_instance.start_driver()
Start the previously setted up webdriver.
analysis = ta_instance.get_analysis()
The get_analysis()
function will return a list, containing the following value.
- The first index (string) shows the recommendation from TradingView, the value can contain "Buy", "Strong Buy", "Neutral", "Sell", or "Strong Sell".
- The second index (int) shows the number/count of Sell analysis
- The third index (int) shows the number/count of Neutral analysis
- The fourth index (int) shows the number/count of Buy analysis
See the picture in the upper part of this page for visualisation.
Please see my blog post here for a more detailed installation and usage.
Trading is a dangerous activity. Do not use tradingview's analysis to trade automatically without your supervision. I am not responsible for any financial loss.
You can fork this repository or submit a pull request. Any pull request (documentation, bug fix, features, etc) are welcomed.
This package or software is available for free to all. You may share, edit, or do whatever you want. For more information please see the LICENSE file.