Skip to main content

A Python client for TradingView WebSocket API. It's a lightweight library capable of providing real-time data on stocks, cryptocurrencies, indices etc.

Project description

pytradingview

A lightweight, open-source Python client for connecting to TradingView's WebSocket API.

Features

  • WebSocket connection management
  • Easy to extend for custom signals and data
  • Download data
  • Search for symbols

Dependencies

websocket-client

Installation

pip install pytradingview

Usage

# example.py
from pytradingview import TVclient

# Create the client and chart
client = TVclient()
chart = client.Chart

# Set up the chart
chart.set_up_chart()

# Set the market
chart.set_market("BINANCE:BTCUSD", {
    "timeframe": "1",  # 1-minute chart
    "currency": "USD",
})

# Event: When the symbol data is loaded
chart.on_symbol_loaded(lambda _: print("✅ Market loaded:", chart.get_infos['description']))

# Event: When price data is updated
def handle_update(_):
    if chart.get_periods:
        print(f"🟢 New Price: {chart.get_periods['close']}")

chart.on_update(handle_update)

# Start the WebSocket connection
client.create_connection()

Command line (CLI)

python -m pytradingview -d -s '2025-04-24 00:00' -e '2025-04-25 00:00' -p 'FX:EURUSD' 
python -m pytradingview --search EURUSD --max 50

Contributing

Contributions are welcome! Please open issues or PRs to collaborate.

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

pytradingview-0.3.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytradingview-0.3.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file pytradingview-0.3.0.tar.gz.

File metadata

  • Download URL: pytradingview-0.3.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pytradingview-0.3.0.tar.gz
Algorithm Hash digest
SHA256 35a735b946a8306a1c0e9beed69c70ec905715a53bdc9f595ba4192ac5a867db
MD5 8dc250a9c23a0b252c263eebdc348bae
BLAKE2b-256 ab926cbf438dd7b384bf897786dca27954ec9c30154b5b0e627abee1b3661afe

See more details on using hashes here.

File details

Details for the file pytradingview-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pytradingview-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pytradingview-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 74379d4ac4cf793e47868044d2124f516c5d83d5f673be370e74b413b1f418c4
MD5 c3a1fe8ba46beede57bf618e6075a14d
BLAKE2b-256 7c91d34db0f1928334eaa48703713af40ca5d43aa562b539349ba21894537a02

See more details on using hashes here.

Supported by

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