Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Black Window running live_data.py; "unexpected token '.' " #429

Open
Coding4Sec opened this issue Jul 18, 2024 · 0 comments
Open

[BUG] Black Window running live_data.py; "unexpected token '.' " #429

Coding4Sec opened this issue Jul 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Coding4Sec
Copy link

Expected Behavior

Hi.

Discovered the library and want to re-create the provided examples on my machine. First tried to run example "2_live_data" within JupyterLab.

Current Behaviour

The example does not work. A black windoww pops up. Then switched to Python script. Same behavior. Got the message:

if (!window.wzdcbbmu.chart.priceScale("right").options.autoScale) window.wzdcbbmu.chart.priceScale("right").applyOptions({autoScale: true}) window.wzdcbbmu.toolBox?.clearDrawings()', error -> SyntaxError[4:33] Unexpected token '.'

hitting CTRL-C:

File "/Users/T800/venvs/Py3_12/lightw-charts/tutorial.py", line 28, in <module> sleep(1) KeyboardInterrupt

Again hitting CTRL-C:

T800s-MacBook-Pro-5:lightw-charts T800$ /usr/local/Cellar/python@3.12/3.12.1_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/resource_tracker.py:254: UserWarning: resource_tracker: There appear to be 14 leaked semaphore objects to clean up at shutdown warnings.warn('resource_tracker: There appear to be %d '

It needs a 3rd Ctrl-C to get back to console.

I searched the ISSUES but only found solutions to similar issues by updating the library since hotfixes are released. Since I am on the latest version, I wonder what causes this behavior.

The very simple example 'setting_data.py' gives the same issue within python script. But I managed to run this simple script in JupyterLab using

if name == 'main':

chart = JupyterChart()

# Columns: time | open | high | low | close | volume 
df = pd.read_csv('ohlcv.csv')
chart.set(df)
chart.load()

Reproducible Example

import pandas as pd
from time import sleep
from lightweight_charts import Chart

# from lightweight_charts import JupyterChart

if __name__ == '__main__':
    chart = Chart()
    #chart = JupyterChart()
    df1 = pd.read_csv('ohlcv.csv')
    df2 = pd.read_csv('next_ohlcv.csv')
    chart.set(df1)

    chart.show()
    #chart.show(block=True)

    #chart.load()

    last_close = df1.iloc[-1]
    for i,series in df2.iterrows():
        chart.update(series)
        
        if series['close'] > 20 and last_close < 20:
            chart.marker(text='The price crossed $20 !!!')

        last_close = series['close']
        
        sleep(0.1)

Environment

- OS:macOS 10.14.6
- Library: lightweight-charts        2.0.1
@Coding4Sec Coding4Sec added the bug Something isn't working label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant