lightweight-charts-python icon indicating copy to clipboard operation
lightweight-charts-python copied to clipboard

working with list of list instead of dataframes

Open Fougl opened this issue 1 year ago • 1 comments

Description

Hi, I am wondering how difficult it is to change the chart.set and chart.update and chart.update_from_tick to actually accept list of lists? Concatenating to a dataframe gets extremely costly, if dataframe is a bit larger, also for live trading, its concatenating the ticks and calculating continously, which is not optimal.

Code example

No response

Method of implementation

No response

Fougl avatar Dec 11 '24 19:12 Fougl

You could adapt / mimic js_data() in utils.py to work with nested lists instead of dataframes. Take each candle/datapoint's values, create a dictionary like this, put them all into a list (or don't if it's to update the chart) then dump it into json.

LineData = {
	time: Time;
	value: number;
}

CandleData = {
	time: Time;
	high: number;
	low: number;
	close: number;
	open: number;
}

Then just modify the set/update methods in abstract.py to accept your data. Now for the live data, analyze the logic behind the update()/update_from_tick() methods carefully so you can implement your version correctly.

AbstractChart needs it's own implementation of the set/update methods, separate from the ones in SeriesCommon btw.

EsIstJosh avatar Dec 12 '24 08:12 EsIstJosh