Skip to main content

TradingView Screener API

Project description

TradingView Screener API

Python library to retrieve data from TradingView Screener.

tradingview-screener.png

Features

  • Query Stock, Forex and Crypto Screener
  • All the fields available (~250 fields)
  • Any time interval (no need to be a registered user)
  • Filters by any fields, symbols, markets, countries, etc.
  • Get the results as a Pandas Dataframe

dataframe.png

Installation

$ pip install git+https://github.com/houseofai/tradingview-screener@main

Usage

For Stocks screener:

import tvscreener as tvs

ss = tvs.StockScreener()
df = ss.get()

# ... returns a dataframe with 150 rows by default

For Forex screener:

import tvscreener as tvs

fs = tvs.ForexScreener()
df = fs.get()

For Crypto screener:

import tvscreener as tvs

cs = tvs.CryptoScreener()
df = cs.get()

Options

Range

By default, it gets the 150 first results. You can change this by setting the range option:

import tvscreener as tvs

ss = tvs.StockScreener()
ss.set_range(0, 10000)
df = ss.get()

# or to get the last 500 rows:
ss.set_range(9500, 10000)
df = ss.get()

Sorting

While it is easier to sort on the Pandas Dataframe, you can also sort directly on the screener:

import tvscreener as tvs

ss = tvs.StockScreener()
ss.sort_by('market_cap_basic', 'desc')
df = ss.get()

Note that market_cap_basic is the default sorting option for stocks

Filters

Markets

Filter by markets:

Default: america

import tvscreener as tvs

ss = tvs.StockScreener()
ss.set_markets('america', 'france', 'japan')
df = ss.get()

You can list the markets with:

from generate import tvdata

print(tvdata.stock['markets'])
# ['america', 'uk', 'india', 'spain', 'russia', 'australia', ...]

By Columns

Filter by columns:

import tvscreener as tvs

ss = tvs.StockScreener()
ss.add_filter('Recommend.All', tvs.filter.FilterOperator.IN_RANGE, values=[0.5, 1]) # Strong BUY
df = ss.get()

Recommend.All corresponds to the TECHNICAL RATING column. You can get a list of all columns available with:

from ignore import tvdata

print(tvdata.stock['columns'].keys())  # ['ChaikinMoneyFlow', 'MoneyFlow', 'Value.Traded', 'after_tax_margin', ...]
print(tvdata.forex['columns'].keys())  # ['ask', 'bid', 'country', 'sector', ...]
print(tvdata.crypto['columns'].keys())  # ['24h_vol_change|5', '24h_vol|5', 'ask', 'average_volume_10d_calc', ...]

Time intervals

Change the time interval of the technical data:

Default: Daily (TimeInterval.DAILY)

import tvscreener as tvs

ss = tvs.StockScreener()
df = ss.get(tvs.TimeInterval.THIRTY_MINUTES)

Debugging

Print the request URL and the payload:

import tvscreener as tvs

ss = tvs.StockScreener()
df = ss.get(print_request=True)

TODO

  • Crypto Coins screener
  • ETF screener
  • More Built-in filters
  • Query historical data

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tvscreener-0.0.1.tar.gz (20.7 kB view hashes)

Uploaded Source

Built Distribution

tvscreener-0.0.1-py3-none-any.whl (26.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page