litecharts 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,39 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ dist/
8
+ build/
9
+ *.egg-info/
10
+ *.egg
11
+
12
+ # Virtual environments
13
+ .venv/
14
+ venv/
15
+ env/
16
+
17
+ # IDE
18
+ .idea/
19
+ .vscode/
20
+ *.swp
21
+ *.swo
22
+
23
+ # Testing
24
+ .pytest_cache/
25
+ .coverage
26
+ htmlcov/
27
+ tests/html_output/
28
+
29
+ # Bundled JS (downloaded at build time)
30
+ src/litecharts/js/*.js
31
+ !src/litecharts/js/.gitkeep
32
+
33
+ # Lock file (library, not application)
34
+ uv.lock
35
+
36
+ # Dev tools
37
+ CLAUDE.md
38
+ claude-docs/
39
+ .mcp.json
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Chad Thackray
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,120 @@
1
+ Metadata-Version: 2.4
2
+ Name: litecharts
3
+ Version: 0.1.0
4
+ Summary: Python wrapper for TradingView Lightweight Charts
5
+ Project-URL: Homepage, https://github.com/chad/litecharts
6
+ Project-URL: Repository, https://github.com/chad/litecharts
7
+ Author: Chad Thackray
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: candlestick,charts,finance,trading,visualization
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Financial and Insurance Industry
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Scientific/Engineering :: Visualization
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.10
23
+ Provides-Extra: dev
24
+ Requires-Dist: mypy>=1.0; extra == 'dev'
25
+ Requires-Dist: pandas-stubs>=2.0; extra == 'dev'
26
+ Requires-Dist: pytest>=7.0; extra == 'dev'
27
+ Requires-Dist: ruff>=0.8; extra == 'dev'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # litecharts
31
+
32
+ [![PyPI version](https://badge.fury.io/py/litecharts.svg)](https://pypi.org/project/litecharts/)
33
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
34
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
35
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
36
+ [![Typed](https://img.shields.io/badge/typed-strict-blue.svg)](https://mypy-lang.org/)
37
+
38
+ > **Warning:** This library is in alpha. The API may change unexpectedly between versions.
39
+
40
+ Thin Python wrapper for [TradingView Lightweight Charts](https://tradingview.github.io/lightweight-charts/).
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ pip install litecharts
46
+ ```
47
+
48
+ ## Quick Start
49
+
50
+ ```python
51
+ from litecharts import createChart, CandlestickSeries
52
+
53
+ # Create a chart
54
+ chart = createChart({"width": 800, "height": 600})
55
+
56
+ # Add a candlestick series
57
+ candles = chart.addSeries(CandlestickSeries)
58
+ candles.setData([
59
+ {"time": 1609459200, "open": 100, "high": 105, "low": 95, "close": 102},
60
+ {"time": 1609545600, "open": 102, "high": 110, "low": 100, "close": 108},
61
+ {"time": 1609632000, "open": 108, "high": 115, "low": 105, "close": 112},
62
+ ])
63
+
64
+ # Display the chart
65
+ chart.show() # Auto-detects Jupyter or opens browser
66
+ ```
67
+
68
+ ## Features
69
+
70
+ - Candlestick, Line, Area, Bar, Histogram, and Baseline series
71
+ - Multi-pane layouts with synced time scales
72
+ - Pandas DataFrame and NumPy array support
73
+ - Jupyter notebook integration
74
+ - Self-contained HTML output
75
+
76
+ ## Data Input
77
+
78
+ Accepts multiple formats:
79
+
80
+ ```python
81
+ # List of dicts
82
+ candles.setData([{"time": 1609459200, "open": 100, "high": 105, "low": 95, "close": 102}])
83
+
84
+ # Pandas DataFrame
85
+ import pandas as pd
86
+ df = pd.DataFrame({"open": [100], "high": [105], "low": [95], "close": [102]},
87
+ index=pd.to_datetime(["2021-01-01"]))
88
+ candles.setData(df)
89
+
90
+ # NumPy array (columns: time, open, high, low, close)
91
+ import numpy as np
92
+ arr = np.array([[1609459200, 100, 105, 95, 102]])
93
+ candles.setData(arr)
94
+ ```
95
+
96
+ ## Multi-Pane Charts
97
+
98
+ ```python
99
+ from litecharts import createChart, CandlestickSeries, HistogramSeries
100
+
101
+ chart = createChart({"width": 800, "height": 600})
102
+
103
+ # Main pane
104
+ mainPane = chart.addPane({"heightRatio": 3})
105
+ candles = mainPane.addSeries(CandlestickSeries)
106
+ candles.setData(ohlcData)
107
+
108
+ # Volume pane
109
+ volumePane = chart.addPane({"heightRatio": 1})
110
+ volume = volumePane.addSeries(HistogramSeries)
111
+ volume.setData(volumeData)
112
+
113
+ chart.show()
114
+ ```
115
+
116
+ ## License
117
+
118
+ MIT - see [LICENSE](LICENSE)
119
+
120
+ This package bundles [Lightweight Charts](https://github.com/tradingview/lightweight-charts) by TradingView, Inc., licensed under Apache 2.0. See [THIRD_PARTY_LICENSES.md](THIRD_PARTY_LICENSES.md).
@@ -0,0 +1,91 @@
1
+ # litecharts
2
+
3
+ [![PyPI version](https://badge.fury.io/py/litecharts.svg)](https://pypi.org/project/litecharts/)
4
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
7
+ [![Typed](https://img.shields.io/badge/typed-strict-blue.svg)](https://mypy-lang.org/)
8
+
9
+ > **Warning:** This library is in alpha. The API may change unexpectedly between versions.
10
+
11
+ Thin Python wrapper for [TradingView Lightweight Charts](https://tradingview.github.io/lightweight-charts/).
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install litecharts
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```python
22
+ from litecharts import createChart, CandlestickSeries
23
+
24
+ # Create a chart
25
+ chart = createChart({"width": 800, "height": 600})
26
+
27
+ # Add a candlestick series
28
+ candles = chart.addSeries(CandlestickSeries)
29
+ candles.setData([
30
+ {"time": 1609459200, "open": 100, "high": 105, "low": 95, "close": 102},
31
+ {"time": 1609545600, "open": 102, "high": 110, "low": 100, "close": 108},
32
+ {"time": 1609632000, "open": 108, "high": 115, "low": 105, "close": 112},
33
+ ])
34
+
35
+ # Display the chart
36
+ chart.show() # Auto-detects Jupyter or opens browser
37
+ ```
38
+
39
+ ## Features
40
+
41
+ - Candlestick, Line, Area, Bar, Histogram, and Baseline series
42
+ - Multi-pane layouts with synced time scales
43
+ - Pandas DataFrame and NumPy array support
44
+ - Jupyter notebook integration
45
+ - Self-contained HTML output
46
+
47
+ ## Data Input
48
+
49
+ Accepts multiple formats:
50
+
51
+ ```python
52
+ # List of dicts
53
+ candles.setData([{"time": 1609459200, "open": 100, "high": 105, "low": 95, "close": 102}])
54
+
55
+ # Pandas DataFrame
56
+ import pandas as pd
57
+ df = pd.DataFrame({"open": [100], "high": [105], "low": [95], "close": [102]},
58
+ index=pd.to_datetime(["2021-01-01"]))
59
+ candles.setData(df)
60
+
61
+ # NumPy array (columns: time, open, high, low, close)
62
+ import numpy as np
63
+ arr = np.array([[1609459200, 100, 105, 95, 102]])
64
+ candles.setData(arr)
65
+ ```
66
+
67
+ ## Multi-Pane Charts
68
+
69
+ ```python
70
+ from litecharts import createChart, CandlestickSeries, HistogramSeries
71
+
72
+ chart = createChart({"width": 800, "height": 600})
73
+
74
+ # Main pane
75
+ mainPane = chart.addPane({"heightRatio": 3})
76
+ candles = mainPane.addSeries(CandlestickSeries)
77
+ candles.setData(ohlcData)
78
+
79
+ # Volume pane
80
+ volumePane = chart.addPane({"heightRatio": 1})
81
+ volume = volumePane.addSeries(HistogramSeries)
82
+ volume.setData(volumeData)
83
+
84
+ chart.show()
85
+ ```
86
+
87
+ ## License
88
+
89
+ MIT - see [LICENSE](LICENSE)
90
+
91
+ This package bundles [Lightweight Charts](https://github.com/tradingview/lightweight-charts) by TradingView, Inc., licensed under Apache 2.0. See [THIRD_PARTY_LICENSES.md](THIRD_PARTY_LICENSES.md).
@@ -0,0 +1,26 @@
1
+ """Build hook to download Lightweight Charts JS at package build time."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import urllib.request
6
+ from pathlib import Path
7
+
8
+ from hatchling.builders.hooks.plugin.interface import BuildHookInterface
9
+
10
+ LWC_VERSION = "5.1.0"
11
+ LWC_URL = f"https://cdn.jsdelivr.net/npm/lightweight-charts@{LWC_VERSION}/dist/lightweight-charts.standalone.production.js"
12
+ JS_DIR = Path(__file__).parent / "src" / "litecharts" / "js"
13
+ JS_FILE = JS_DIR / "lightweight-charts.js"
14
+
15
+
16
+ class CustomBuildHook(BuildHookInterface):
17
+ """Download Lightweight Charts JS during build."""
18
+
19
+ def initialize(self, version: str, build_data: dict) -> None:
20
+ """Download LWC JS if not already present."""
21
+ JS_DIR.mkdir(parents=True, exist_ok=True)
22
+
23
+ if not JS_FILE.exists():
24
+ print(f"Downloading Lightweight Charts v{LWC_VERSION}...")
25
+ urllib.request.urlretrieve(LWC_URL, JS_FILE)
26
+ print(f"Downloaded to {JS_FILE}")
@@ -0,0 +1,75 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "litecharts"
7
+ version = "0.1.0"
8
+ description = "Python wrapper for TradingView Lightweight Charts"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.10"
12
+ authors = [
13
+ { name = "Chad Thackray" }
14
+ ]
15
+ keywords = ["trading", "charts", "visualization", "finance", "candlestick"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "Intended Audience :: Financial and Insurance Industry",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Topic :: Scientific/Engineering :: Visualization",
27
+ "Typing :: Typed",
28
+ ]
29
+
30
+ [project.optional-dependencies]
31
+ dev = [
32
+ "pytest>=7.0",
33
+ "mypy>=1.0",
34
+ "ruff>=0.8",
35
+ "pandas-stubs>=2.0",
36
+ ]
37
+
38
+ [project.urls]
39
+ Homepage = "https://github.com/chad/litecharts"
40
+ Repository = "https://github.com/chad/litecharts"
41
+
42
+ [tool.hatch.build.targets.sdist]
43
+ include = [
44
+ "/src",
45
+ "/build_hooks.py",
46
+ ]
47
+
48
+ [tool.hatch.build.targets.wheel]
49
+ packages = ["src/litecharts"]
50
+
51
+ [tool.hatch.build.hooks.custom]
52
+ path = "build_hooks.py"
53
+
54
+ [tool.pytest.ini_options]
55
+ testpaths = ["tests"]
56
+
57
+ [tool.mypy]
58
+ python_version = "3.10"
59
+ strict = true
60
+ warn_return_any = true
61
+ warn_unused_ignores = true
62
+
63
+ [tool.ruff]
64
+ target-version = "py310"
65
+ line-length = 88
66
+
67
+ [tool.ruff.lint]
68
+ select = ["E", "F", "W", "I", "UP", "B", "SIM", "RUF", "N"]
69
+ ignore = [
70
+ "N802", # Function name should be lowercase (we use camelCase to match LWC)
71
+ "N803", # Argument name should be lowercase (we use camelCase to match LWC)
72
+ "N806", # Variable in function should be lowercase (we use camelCase to match LWC)
73
+ "N815", # Variable in class scope should not be mixedCase (we use camelCase)
74
+ "N816", # Variable in global scope should not be mixedCase (we use camelCase)
75
+ ]
@@ -0,0 +1,100 @@
1
+ """Litecharts - Python wrapper for TradingView Lightweight Charts."""
2
+
3
+ from .chart import Chart, createChart
4
+ from .pane import Pane
5
+ from .series import (
6
+ AreaSeries,
7
+ BarSeries,
8
+ BaselineSeries,
9
+ BaseSeries,
10
+ CandlestickSeries,
11
+ HistogramSeries,
12
+ LineSeries,
13
+ createSeriesMarkers,
14
+ )
15
+ from .types import (
16
+ AreaSeriesOptions,
17
+ AutoScaleMargins,
18
+ AxisDoubleClickOptions,
19
+ AxisPressedMouseMoveOptions,
20
+ BarSeriesOptions,
21
+ BaselineSeriesOptions,
22
+ BaseSeriesOptions,
23
+ BaseValuePrice,
24
+ CandlestickSeriesOptions,
25
+ ChartOptions,
26
+ CrosshairLineOptions,
27
+ CrosshairOptions,
28
+ GridLineOptions,
29
+ GridOptions,
30
+ HandleScaleOptions,
31
+ HandleScrollOptions,
32
+ HistogramSeriesOptions,
33
+ KineticScrollOptions,
34
+ LastPriceAnimationOptions,
35
+ LayoutOptions,
36
+ LineSeriesOptions,
37
+ LocalizationOptions,
38
+ Marker,
39
+ MarkerTooltip,
40
+ OhlcData,
41
+ PaneOptions,
42
+ PriceFormat,
43
+ PriceLineOptions,
44
+ PriceScaleMargins,
45
+ PriceScaleOptions,
46
+ RectangleOptions,
47
+ SingleValueData,
48
+ TimeScaleOptions,
49
+ WatermarkOptions,
50
+ )
51
+
52
+ __version__ = "0.1.0"
53
+
54
+ __all__ = [
55
+ "AreaSeries",
56
+ "AreaSeriesOptions",
57
+ "AutoScaleMargins",
58
+ "AxisDoubleClickOptions",
59
+ "AxisPressedMouseMoveOptions",
60
+ "BarSeries",
61
+ "BarSeriesOptions",
62
+ "BaseSeries",
63
+ "BaseSeriesOptions",
64
+ "BaseValuePrice",
65
+ "BaselineSeries",
66
+ "BaselineSeriesOptions",
67
+ "CandlestickSeries",
68
+ "CandlestickSeriesOptions",
69
+ "Chart",
70
+ "ChartOptions",
71
+ "CrosshairLineOptions",
72
+ "CrosshairOptions",
73
+ "GridLineOptions",
74
+ "GridOptions",
75
+ "HandleScaleOptions",
76
+ "HandleScrollOptions",
77
+ "HistogramSeries",
78
+ "HistogramSeriesOptions",
79
+ "KineticScrollOptions",
80
+ "LastPriceAnimationOptions",
81
+ "LayoutOptions",
82
+ "LineSeries",
83
+ "LineSeriesOptions",
84
+ "LocalizationOptions",
85
+ "Marker",
86
+ "MarkerTooltip",
87
+ "OhlcData",
88
+ "Pane",
89
+ "PaneOptions",
90
+ "PriceFormat",
91
+ "PriceLineOptions",
92
+ "PriceScaleMargins",
93
+ "PriceScaleOptions",
94
+ "RectangleOptions",
95
+ "SingleValueData",
96
+ "TimeScaleOptions",
97
+ "WatermarkOptions",
98
+ "createChart",
99
+ "createSeriesMarkers",
100
+ ]
@@ -0,0 +1,29 @@
1
+ """Lightweight Charts JavaScript asset loading."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from functools import lru_cache
6
+ from importlib.resources import files
7
+
8
+
9
+ @lru_cache(maxsize=1)
10
+ def getLwcJs() -> str:
11
+ """Load the bundled Lightweight Charts JavaScript.
12
+
13
+ Returns:
14
+ The LWC JavaScript source code.
15
+
16
+ Raises:
17
+ FileNotFoundError: If the JS file is not found (package not built correctly).
18
+ """
19
+ jsPath = files("litecharts.js").joinpath("lightweight-charts.js")
20
+
21
+ try:
22
+ return jsPath.read_text(encoding="utf-8")
23
+ except FileNotFoundError:
24
+ msg = (
25
+ "Lightweight Charts JS not found. "
26
+ "This usually means the package was not built correctly. "
27
+ "Try reinstalling: pip install --force-reinstall litecharts"
28
+ )
29
+ raise FileNotFoundError(msg) from None