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

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' 

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.2.0.tar.gz (14.3 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.2.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pytradingview-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b0f9b4990ba950e24999a21ee113f309e4cbc1c06c2339af70929d0d42725e32
MD5 7c65e1a58802e2187dda8dd29f4de252
BLAKE2b-256 ad06d76687d1a5a2eeb662b15376d71376069d330d07aca00709f04447b991aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytradingview-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.7 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 67acbff0ba990762e25dcd73df3fcb250466b2ab8a9a0d9bfa3b3a43f6278c86
MD5 60f381fc41b4e4e2b10a2c9243024bc1
BLAKE2b-256 c848c698b047c521b03fb75afb41561f38344a6258bef712fb0d2b5745b5b354

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