1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python and lightweight_charts: asyncio.run() cannot be called from a running event...

Discussão em 'Python' iniciado por Stack, Setembro 15, 2024.

  1. Stack

    Stack Membro Participativo

    I'm running the following code in VSC notebook:

    from ipynb.fs.full.tool_read_db import get_table2df_pastdays
    from lightweight_charts import Chart

    table = get_table2df_pastdays('BTCUSDTBB5m',10,1)
    table.rename(columns={'openDateTime':'date'},inplace=True)
    table.head()
    date open high low close volume
    0 2024-09-05 18:15:00 56052.6 56109.5 55962.0 55995.5 482.592
    1 2024-09-05 18:20:00 55995.5 56232.5 55940.5 56203.8 804.477
    2 2024-09-05 18:25:00 56203.8 56294.5 56151.4 56173.2 761.775
    3 2024-09-05 18:30:00 56173.2 56214.0 56044.7 56135.2 567.344
    4 2024-09-05 18:35:00 56135.2 56325.8 56135.2 56206.0 732.861

    chart = Chart()
    chart.set(table.iloc)
    chart.show(block=True)


    I'm getting following error:

    ----> 3 chart.show(block=True)

    RuntimeError: asyncio.run() cannot be called from a running event loop


    Function get_table2df_pastdays just queries the table using SQL Alchemy and spits it out in the form of a Pandas DataFrame. So table is a DataFrame object.

    I've tried methods from this thread marked as a solution and wrapping my code generating chart in async main or asyncio.run, but none of this works. What's funny is that the chart popup with caldlestick chart does pop up with correct data only to immediately throw the error I've pasted. How to tackle this issue ?

    Continue reading...

Compartilhe esta Página