lwcharts
TradingView-quality interactive charts from pandas data, in one fluent chain.
chart = (
Chart("BTC/USDT — 1D", theme="dark", height=700)
.candles(df)
.line(ema_20, name="EMA 20", color="#f0b429")
.line(ema_50, name="EMA 50", color="#a5b4fc", style="dashed")
.volume(df)
.add_subplot(
Subplot(height_ratio=0.2, label="RSI(14)", y_min=0, y_max=100)
.line(rsi, color="#58a6ff")
.hline(70, style="dashed")
.hline(30, style="dashed")
)
.markers(entries, shape="arrowUp", position="belowBar", color="#26a641", label="E")
)
chart.serve()
Description
lwcharts is a simple python wrapper of the famous TradingView's Lightweight Charts
Why lwcharts
- Zero JS knowledge required. You write pandas, you get interactive TradingView charts. Crosshair sync, scroll, zoom — all included.
- Single
createChartarchitecture. All subpanes share one time axis. No manual sync hacks, no drift between panes. - No calculation, no opinion. The lib renders what you give it. Your EMA, your RSI, your signals — computed with whatever tools you prefer.
- Truly offline. The lightweight-charts JS bundle is embedded in the generated HTML by default. Works on air-gapped machines, in Jupyter.
- Zero dependencies beyond pandas. No plotly, no bokeh, no nodejs, no webpack.
Installation
uv add lwcharts
# or
pip install lwcharts
Quickstart
import numpy as np
import pandas as pd
from lwcharts import Chart, Subplot
rng = np.random.default_rng(42)
n = 300
idx = pd.date_range("2023-01-01", periods=n, freq="B")
close = 42000 + np.cumsum(rng.normal(0, 500, n))
df = pd.DataFrame({
"open": close - rng.uniform(0, 300, n),
"high": close + rng.uniform(0, 600, n),
"low": close - rng.uniform(0, 600, n),
"close": close,
"volume": rng.integers(500_000_000, 2_000_000_000, n).astype(float),
}, index=idx)
ema_20 = df["close"].ewm(span=20).mean()
ema_50 = df["close"].ewm(span=50).mean()
delta = df["close"].diff()
rsi = 100 - 100 / (1 + delta.clip(lower=0).ewm(com=13).mean()
/ (-delta.clip(upper=0)).ewm(com=13).mean())
entries = pd.Series(False, index=idx)
entries.iloc[[40, 120, 210]] = True
chart = (
Chart("BTC/USDT — 1D", theme="dark", height=700)
.candles(df)
.line(ema_20, name="EMA 20", color="#f0b429")
.line(ema_50, name="EMA 50", color="#a5b4fc", style="dashed")
.volume(df)
.add_subplot(
Subplot(height_ratio=0.2, label="RSI(14)", y_min=0, y_max=100)
.line(rsi, color="#58a6ff")
.hline(70, style="dashed")
.hline(30, style="dashed")
)
.markers(entries, shape="arrowUp", position="belowBar", color="#26a641", label="E")
)
chart.serve() # opens browser at localhost:1337
chart.to_html("btc.html") # or write a self-contained HTML file
What the lib does not do
lwcharts is a rendering layer, not an analytics engine. It does not:
- Calculate indicators (EMA, RSI, MACD, Bollinger…)
- Fetch market data (no Bloomberg, CCXT, Yahoo Finance connectors)
- Resample OHLCV (1D → 1W resampling belongs in pandas)
You keep full control of your data pipeline. Use pandas-ta, ta-lib, numpy, or
your own in-house library to compute whatever you need, then pass the resulting
Series directly to lwcharts.
Documentation
Full API reference, all methods, edge cases, and complete code examples: docs/DOCUMENTATION.md
License
MIT
Metadata
Release files for lwcharts 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lwcharts-0.3.0.tar.gz | 78.2 kB | Without provenance | Details for lwcharts-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lwcharts-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for lwcharts-0.3.0-py3-none-any.whl |
Total release size: 162.8 kB
Release files / lwcharts-0.3.0.tar.gz
| Download URL | lwcharts-0.3.0.tar.gz |
|---|---|
| Size | 78.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12e679de6b18490dc5f5128c497f4c979ac09005cc02f5edb1ade3a2b51cc6d3
|
|
BLAKE2b-256 checksum How to use checksums |
66879d5c500f39ebeb0488c5b1991ca76f2f73145cb9c2d740d6d3de52903b4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / lwcharts-0.3.0-py3-none-any.whl
| Download URL | lwcharts-0.3.0-py3-none-any.whl |
|---|---|
| Size | 84.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0cde1dc847487e9fae62dc5a432250c9d41838c85b702108c23ee44697f067c4
|
|
BLAKE2b-256 checksum How to use checksums |
91ae9b47a994c8a701c57d08629956a905c02ca9c78563a849a5318e81ad1773
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for lwcharts 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.