Litecharts
Python adaptor for TradingView Lightweight Charts
Install / Use
/learn @ChadThackray/LitechartsREADME
litecharts
Warning: This library is in alpha. The API may change unexpectedly between versions.
Thin Python wrapper for TradingView Lightweight Charts. Documentation
Installation
pip install litecharts
Quick Start
from litecharts import createChart, CandlestickSeries
# Create a chart
chart = createChart({"width": 800, "height": 600})
# Add a candlestick series
candles = chart.addSeries(CandlestickSeries)
candles.setData([
{"time": 1609459200, "open": 100, "high": 105, "low": 95, "close": 102},
{"time": 1609545600, "open": 102, "high": 110, "low": 100, "close": 108},
{"time": 1609632000, "open": 108, "high": 115, "low": 105, "close": 112},
])
# Display the chart
chart.show() # Auto-detects Jupyter or opens browser
Features
- Candlestick, Line, Area, Bar, Histogram, and Baseline series
- Multi-pane layouts with synced time scales
- Series markers for buy/sell signals and annotations
- Customizable HTML output styling
- Pandas DataFrame and NumPy array support
- Jupyter notebook integration
- Self-contained HTML output
Data Input
Accepts multiple formats:
# List of dicts
candles.setData([{"time": 1609459200, "open": 100, "high": 105, "low": 95, "close": 102}])
# Pandas DataFrame
import pandas as pd
df = pd.DataFrame({"open": [100], "high": [105], "low": [95], "close": [102]},
index=pd.to_datetime(["2021-01-01"]))
candles.setData(df)
# NumPy array (columns: time, open, high, low, close)
import numpy as np
arr = np.array([[1609459200, 100, 105, 95, 102]])
candles.setData(arr)
Multi-Pane Charts
from litecharts import createChart, CandlestickSeries, HistogramSeries
chart = createChart({"width": 800, "height": 600})
# Main pane
mainPane = chart.addPane({"stretchFactor": 3})
candles = mainPane.addSeries(CandlestickSeries)
candles.setData(ohlcData)
# Volume pane
volumePane = chart.addPane({"stretchFactor": 1})
volume = volumePane.addSeries(HistogramSeries)
volume.setData(volumeData)
chart.show()
Markers
from litecharts import createChart, CandlestickSeries, createSeriesMarkers
chart = createChart({"width": 800, "height": 400})
candles = chart.addSeries(CandlestickSeries)
candles.setData(ohlcData)
# Add buy/sell markers
createSeriesMarkers(candles, [
{"time": 1609459200, "position": "belowBar", "shape": "arrowUp", "color": "#26a69a", "text": "Buy"},
{"time": 1609718400, "position": "aboveBar", "shape": "arrowDown", "color": "#ef5350", "text": "Sell"},
])
chart.show()
License
MIT - see LICENSE
This package bundles Lightweight Charts by TradingView, Inc., licensed under Apache 2.0. See THIRD_PARTY_LICENSES.md.
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
