Version 2.0
Hello everyone!
I have created a new 2.0 branch which i’m planning on releasing in the coming days/weeks. It includes:
- A complete rework of the backend, which now uses TypeScript
- A rewrite of the drawing objects (written as plugins) including rectangles
- Test cases
Now that we are using plugins (and the js/ts source code is readable!) I hope that it will be easier for others to contribute their own ideas, especially on the typescript/javascript side of things.
Some ideas that others could contribute:
- Fib lines
- Markers that can be placed at locations on the Y axis
- Other control panel widgets
Any feedback/testing would be much appreciated!
To Install this branch:
- download/clone the 2.0 branch.
- in your own venv:
-
pip uninstall lightweight_charts -
pip install -e path/to/lightweight-charts-python/lightweight_charts/
-
Louis
I could notice that the horizontal line uses 2 clicks and not 1 as before. changing colors in the lines and box work well. I could see that the center of the rectangle always remains gray and only the edges change color. deleting the drawings do not work or styles do not work either. Suggestion for styles to be able to adjust the tickness of the lines please. Otherwise it works very well, I will be testing it more thoroughly to see if I find more problems. A request for future fibbonacci retracement. Good job, the light weight charts python project looks better every day.
After second click on horizontal line cant move again. if change time frame drawings desappear and When you return to the tf where the drawings were created, they appear.
Thanks for your feedback @cilindro5432, ill get those ironed out soon.
@louisnw01 How to use this new 2.0 version please guide through installation??
I would love if you can simply make the drawing tools color/behaviour default to same as in tradingview app. They are pretty good already
Great to hear, thanks for all your work on this @louisnw01 !
Will there be support for PyQt6 in this version?
I have waited for long for BOX / RECTANGLE to be implemented thanks for your great work. I am using something like FIBs in my project maybe after 2.0 I will help but only in python.
One suggestion if possible add some examples for BANDs like macd. Also make separate SECTION for questions and answers, Maybe discord also
Hello, can someone help me set up lightweight-charts on Ubuntu 20.4 WLS Installation? I managed to get a static chart but no live one, I get an error about python gtk which I cannot resolve. I use Python 3.11 on Anaconda. Sorry for posting this, maybe a Q&A like armeya25 said would be usefull
I could notice that the horizontal line uses 2 clicks and not 1 as before. changing colors in the lines and box work well. I could see that the center of the rectangle always remains gray and only the edges change color. deleting the drawings do not work or styles do not work either. Suggestion for styles to be able to adjust the tickness of the lines please. Otherwise it works very well, I will be testing it more thoroughly to see if I find more problems. A request for future fibbonacci retracement. Good job, the light weight charts python project looks better every day.
horizontal lines are back to a single click, delete should work now.
Louis
@louisnw01 How to use this new 2.0 version please guide through installation??
I have added an installation section to this issue.
Louis
Hi Mr. Lois In the latest version notice that a horizontal line is created with one click and not 2 and the new vertical line uses 2 clicks instead of one. The way clicks are implemented shouldn't matter after they work. I use the Oanda API to get the data. In the first version of the Light weight chart 2.0 I could draw with the problems I had but the drawings were still visible. In this latest version it keeps the drawings in static data but with tick data the drawings disappear from the chart when updating. I tried saving and loading the drawings in drawings.json and it doesn't save or load the drawings. I don't know if it's my mistake but try to verify it as soon as you can. In the previous version it had a handler error at the beginning that many times it did not open the app and other times it did, that was resolved in the latest version and it works very well. Anyway, this latest version works better than the previous one, it's just that the drawings with tick data don't work well for me and the previous version does. Could you tell me which specific files I need to manipulate to control the thinness of the lines, if possible? In the previous version as in this last one I found the same error in the price scale. When you press click and slide up and down the image of the candles look as if the candles were reduced or enlarged. The image does not stay in that position where I left it, in seconds it returns to its original state.
@armeya25 If you dont have any or just a little knolodge in python try chat gpt to setup your chat.
@armeya25 If you dont have any or just a little knolodge in python try chat gpt to setup your chat.
I am noob in python but I used lightweight charts before it was working fine for 2.0 it's shows error for same code that was working fine for older version of lightweight charts
@armeya25 If you dont have any or just a little knolodge in python try chat gpt to setup your chat.
I am noob in python but I used lightweight charts before it was working fine for 2.0 it's shows error for same code that was working fine for older version of lightweight charts
I had some issues with my code too in first version of this branch. The first version of this branch had several problems when starting the app. I had to modify my code. The second version does not have these problems, try with the latest update of light weight charts. As I told you, if you don't have much experience in python, chat gpt can help you a lot, it can identify errors more clearly.
export WEBKIT_DISABLE_COMPOSITING_MODE="1"
After this command works on arch linux i3wm
@louisnw01 box implementation working or not Test works fine but It didn't draw box This is code, What I am doing wrong here
https://github.com/louisnw01/lightweight-charts-python/issues/344
the drawings disappear https://github.com/louisnw01/lightweight-charts-python/assets/150294229/31d06830-ee18-4c2a-b34f-c9431d19eecc
the drawings disappear https://github.com/louisnw01/lightweight-charts-python/assets/150294229/31d06830-ee18-4c2a-b34f-c9431d19eecc
My drawing doesn't disappeared though, But it's only working on manual drawing, Chart.box() doesn't draw it automatically
Should that also be raised as big ?
@armeya25
"A complete rework of the backend, which now uses TypeScript A rewrite of the drawing objects (written as plugins) including rectangles Test cases Now that we are using plugins (and the js/ts source code is readable!) I hope that it will be easier for others to contribute their own ideas, especially on the typescript/javascript side of things.
Some ideas that others could contribute:
Fib lines ### Markers that can be placed at locations on the Y axis Other control panel widgets Any feedback/testing would be much appreciated!"
You want a marker as rectangle. Now is time to be creative
It gives error :
DEBUG:PyQt5.uic.uiparser:pop widget QStatusBar statusbar
DEBUG:PyQt5.uic.uiparser:new topwidget MainWindow
DEBUG:PyQt5.uic.uiparser:pop widget QMainWindow MainWindow
DEBUG:PyQt5.uic.uiparser:new topwidget None
Traceback (most recent call last):
File "D:\Installed_Python\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\Installed_Python\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "E:\Works\Project VI\charting\chart_project_1_prblm.py", line 711, in
My app has a lot of early development rust on it at this point. Very excited for the next 2.0 release so I can finally rebuild it.
Thanks for your hard work, Louis. Without this library a lot of the ideas would just stay in our heads forever.
Encountered a bug in 2.0 presented here: https://github.com/louisnw01/lightweight-charts-python/issues/362
in python-lightweight-charts v 2.0 adding marker throwing the following error:
chart.marker(time=date.at[i], position = 'above', shape= 'arrow_down', color= 'red', text ='SEXIT')
Exception in thread Thread-2 (loop): Traceback (most recent call last): File "/home/anil/pyprojects/trado5/lightweight-charts-python/lightweight_charts/chart.py", line 89, in loop window.evaluate_js(arg) File "/home/anil/pyprojects/trado5/venv5/lib/python3.11/site-packages/webview/window.py", line 50, in wrapper return function(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/anil/pyprojects/trado5/venv5/lib/python3.11/site-packages/webview/window.py", line 444, in evaluate_js raise JavascriptException(result) webview.errors.JavascriptException: {'name': 'SyntaxError', 'message': "Unexpected number '09'. Expected '}' to end an object literal.", 'line': 4, 'column': 33, 'sourceURL': 'http://127.0.0.1:52941/test.html', 'stack': 'eval@[native code]\nglobal code@http://127.0.0.1:52941/test.html:4:33'}
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner self.run() File "/usr/lib/python3.11/threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "/home/anil/pyprojects/trado5/lightweight-charts-python/lightweight_charts/chart.py", line 94, in loop raise JavascriptException(f"\n\nscript -> '{arg}',\nerror -> {msg['name']}[{msg['line']}:{msg['column']}]\n{msg['message']}") webview.errors.JavascriptException:
script -> ' window.dppwcgvk.markers.push({ time: 2024-04-24 09:15:00, position: 'aboveBar', color: 'red', shape: 'arrowDown', text: 'SEXIT 349.8', id: 'window.zcmtakbs' }); window.dppwcgvk.series.setMarkers(window.dppwcgvk.markers)', error -> SyntaxError[4:33] Unexpected number '09'. Expected '}' to end an object literal.
Is this v2.0 based on https://github.com/rwitzlib/lightweight-charts fork ?
Is this v2.0 based on https://github.com/rwitzlib/lightweight-charts fork ?
Nope; all drawing plugins have only been written by me (so far)
in python-lightweight-charts v 2.0 adding marker throwing the following error:
chart.marker(time=date.at[i], position = 'above', shape= 'arrow_down', color= 'red', text ='SEXIT')Exception in thread Thread-2 (loop): Traceback (most recent call last): File "/home/anil/pyprojects/trado5/lightweight-charts-python/lightweight_charts/chart.py", line 89, in loop window.evaluate_js(arg) File "/home/anil/pyprojects/trado5/venv5/lib/python3.11/site-packages/webview/window.py", line 50, in wrapper return function(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/anil/pyprojects/trado5/venv5/lib/python3.11/site-packages/webview/window.py", line 444, in evaluate_js raise JavascriptException(result) webview.errors.JavascriptException: {'name': 'SyntaxError', 'message': "Unexpected number '09'. Expected '}' to end an object literal.", 'line': 4, 'column': 33, 'sourceURL': 'http://127.0.0.1:52941/test.html', 'stack': 'eval@[native code]\nglobal code@http://127.0.0.1:52941/test.html:4:33'}
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner self.run() File "/usr/lib/python3.11/threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "/home/anil/pyprojects/trado5/lightweight-charts-python/lightweight_charts/chart.py", line 94, in loop raise JavascriptException(f"\n\nscript -> '{arg}',\nerror -> {msg['name']}[{msg['line']}:{msg['column']}]\n{msg['message']}") webview.errors.JavascriptException:
script -> ' window.dppwcgvk.markers.push({ time: 2024-04-24 09:15:00, position: 'aboveBar', color: 'red', shape: 'arrowDown', text: 'SEXIT 349.8', id: 'window.zcmtakbs' }); window.dppwcgvk.series.setMarkers(window.dppwcgvk.markers)', error -> SyntaxError[4:33] Unexpected number '09'. Expected '}' to end an object literal.
Fixed
I am receiving following error when I am doing following:
- I have created lines
- I have set the lines
- I delete all the lines
- I am creating the lines again
- I am setting them again
When I get a bar data for a perticulat stock I create indicators and set them. I search the stock and set the candle data for another stock and now I have to delete the old indicator lines and recreate and reset them.
Exception in thread Thread-2 (loop): Traceback (most recent call last): File "/home/anil/pyprojects/trado5/lightweight-charts-python/lightweight_charts/chart.py", line 89, in loop window.evaluate_js(arg) File "/home/anil/pyprojects/trado5/venv5/lib/python3.11/site-packages/webview/window.py", line 50, in wrapper return function(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/anil/pyprojects/trado5/venv5/lib/python3.11/site-packages/webview/window.py", line 444, in evaluate_js raise JavascriptException(result) webview.errors.JavascriptException: {'name': 'TypeError', 'message': "undefined is not an object (evaluating 'window.vcaisayp.legend.lines.forEach')", 'line': 3, 'column': 41, 'stack': 'eval code@\neval@[native code]\nglobal code@http://127.0.0.1:32628/test.html:4:33'}
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner self.run() File "/usr/lib/python3.11/threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "/home/anil/pyprojects/trado5/lightweight-charts-python/lightweight_charts/chart.py", line 94, in loop raise JavascriptException(f"\n\nscript -> '{arg}',\nerror -> {msg['name']}[{msg['line']}:{msg['column']}]\n{msg['message']}") webview.errors.JavascriptException:
@louisnw01 I think clear_markers missing self._update_markers() call after the clear.
@louisnw01 Hello, good sir. If I understood implementation correctly, saveDrawings() missing type: d._type, which leads to being unable to load them during switch (d.type) case.
saveDrawings = () => {
const drawingMeta = []
for (const d of this._drawingTool.drawings) {
drawingMeta.push({
type: d._type,
points: d.points,
options: d._options
});
}
const string = JSON.stringify(drawingMeta);
window.callbackFunction(`save_drawings${this._handlerID}_~_${string}`)
}
Also it seems like deleting drawings only deletes them visually, but they persist on load/export. Maybe this part is not implimented yet, since workaround is just to pass this.saveDrawings as parameter to delete method and call it. (like in ColorPicker and etc cases).