Skip to main content

lightweight-charts-server

lightweight-charts-python based chart hosting library

Installation

pip install --upgrade lightweight-charts-server

Examples

Examples of usage are in examples/

Get examples through git clone

git clone https://github.com/vegaxholdings/lightweight-charts-server.git

cd lightweight-charts-server

pip install -r requirements.txt

Run Examples

  1. python -m examples.1_setting_data.setting_data
  2. python -m examples.2_live_data.live_data
  3. python -m examples.3_tick_data.tick_data
  4. python -m examples.4_line_indicators.line_indicators
  5. python -m examples.5_styling.styling

Advanced

There are two types of Display: View and Stream.

View can receive values ​​through HTML Form and reflect them on the chart.

Stream can receive values ​​from outside and update the chart in real time.

View

graph LR
	wb("Web Form")
	subgraph Server
		dy("HTML")
		ftype
		subgraph display
			view
		end
		subgraph lightweight-charts code
			create("create(a,b,c) -> Chart")
		end
	end
	wb --> ftype --> create
	create --> view
	view --> dy
	
	dy --> Web

This code demonstrates how to interact with a Form through ftype.

from datetime import timedelta

from lightweight_charts import Chart
from lightweight_charts_server import ftype, View, Server

intervals = ftype.options("1m", "15m")

def create(
    option: intervals = intervals("15m"),
    color: ftype.Color = ftype.Color("#1B2E00"),
    boolean: ftype.Bool = ftype.Bool(False),
    num_int: ftype.Int = ftype.Int(14),  
    num_float: ftype.Int = ftype.Float(3.14),  
    string: ftype.Str = ftype.Str("apple"),  
    time: ftype.DateTime = ftype.DateTime.now() - timedelta(days=10),  
    df: ftype.DataFrame = ftype.DataFrame({"a": [], "b": [], "c": []}),
    config: ftype.JSON = ftype.JSON([1, 2, 3]),
) -> Chart:

    option.selected # -> str
    color.hex # -> str
    boolean.value # -> bool

    num_int # -> int
    num_float # -> float
    string # -> str
    time # -> datetime

    df # -> DataFrame
    config.obj # -> list or dict

    ...

    return chart

display = View(callback=create)
server = Server(display)

if __name__ == "__main__":
    server.serve()

Stream

graph LR
	subgraph Server
		subgraph display
			stream
		end
		subgraph lightweight-charts code
			update("update(chart)")
			Chart
		end
	end
	subgraph External
		Upbit
	end
		Chart --> stream
	update --> stream
	stream <--->|websocket| Web
	External --> update

This code streams prices in real time through the upbit exchange.

import time
from datetime import date, datetime, timedelta

import pyupbit
import pandas as pd
from lightweight_charts import Chart
from lightweight_charts_server import Stream, Server

TICKER = "KRW-XRP"

init_df = pyupbit.get_ohlcv(ticker=TICKER, interval="minute")


def update(chart: Chart):
    while True:
        update_df = pyupbit.get_ohlcv(ticker=TICKER, count=1, interval="minute")
        tick = pd.Series(
            {
                "time": date.today().isoformat(), 
                "price": update_df.iloc[0]["close"],
            }
        )
        chart.update_from_tick(tick)
        time.sleep(0.1)


chart = Chart(toolbox=True)
chart.set(init_df)

display = Stream(chart, callback=update)
server = Server(display)

if __name__ == "__main__":
    server.serve()

Metadata

Release files for lightweight-charts-server 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lightweight-charts-server 0.2.4
File Size Uploaded Provenance Actions
lightweight_charts_server-0.2.4.tar.gz 91.7 kB Without provenance Details for lightweight_charts_server-0.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lightweight-charts-server 0.2.4
File Interpreter ABI Platform Actions
lightweight_charts_server-0.2.4-py3-none-any.whl Python 3 none any Details for lightweight_charts_server-0.2.4-py3-none-any.whl

Total release size: 185.4 kB

Release files / lightweight_charts_server-0.2.4.tar.gz

Download URL lightweight_charts_server-0.2.4.tar.gz
Size 91.7 kB
Tags Source
SHA-256 checksum
How to use checksums
034e0a9dd7a2b8aa1165595b91fd5f1b61bdfdf7edf5e702100c3efaf7c54e86
BLAKE2b-256 checksum
How to use checksums
48701d341f2cac823b6e7c2cb130bc300ddef93761ced0a99b8a11725cbd1a34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / lightweight_charts_server-0.2.4-py3-none-any.whl

Download URL lightweight_charts_server-0.2.4-py3-none-any.whl
Size 93.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e33c4abfb91b0f913e801929ab9d962782496e7ee0ccd8f1778168fa359df012
BLAKE2b-256 checksum
How to use checksums
320c4ead899a321d9be5974676c6fa4ecae78473d546c366a70c8a5192704505
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Security for lightweight-charts-server 0.2.4

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.

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page