Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
lightweight-charts-server
Advanced tools
lightweight-charts-python based chart hosting library
pip install --upgrade lightweight-charts-server
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
python -m examples.1_setting_data.setting_data
python -m examples.2_live_data.live_data
python -m examples.3_tick_data.tick_data
python -m examples.4_line_indicators.line_indicators
python -m examples.5_styling.styling
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.
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()
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()
FAQs
lightweight-chart custom python server
We found that lightweight-charts-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.