Mathieu2301 / TradingView-API

šŸ“ˆ Get real-time stocks from TradingView
1.65k stars 359 forks source link

Table Cell Contents Unavailable #251

Open aiyunstunna opened 3 months ago

aiyunstunna commented 3 months ago

This is an awesome API and I tremendously appreciate your work.

Describe the bug When accessing the table of a private indicator, the "cells" key in the JSON object is missing even though I can see in graphicParser.js that it is expected and the table is populated on the chart in TradingView. Just to let you know, there are characters such as "ā†˜" in the chart.

To Reproduce


async function step() {
  const period = { ...chart.periods[0] };

  const times = Object.keys(periods);
  const intrval = times[times.length - 1] - times[times.length - 2];
  if (Number.isNaN(interval) && times.length >= 2) interval = intrval;

  // if (!Number.isNaN(interval) && interval !== intrval) {
    // throw new Error(`Wrong interval: ${intrval} (should be ${interval})`);
  // }

  indicators.forEach(([n, i]) => {
    const plots = { ...i.periods[0] };
    delete plots.$time;
    period[n] = { plots };

    Object.keys(i.graphic).forEach((g) => {
      if (!i.graphic[g].length) return;
      if (!period[n].graphics) period[n].graphics = {};
      period[n].graphics[g] = i.graphic[g];

    });
  });

  periods[period.time] = period;

  console.log('Next ->', period.time, times.length, period.open);
  // console.log(JSON.stringify(period.EMA_50, null, 2))
  // console.log(JSON.stringify(period.Lines, null, 2))
  console.log(JSON.stringify(period, null, 2))
  if (period.graphics){
      process.exit()
  }

  await chart.replayStep(1);
  step();
}

async function addPrivIndicator(name, pineId, version, token, signature = {}) {
  loading += 1;

  const indic = await TradingView.getIndicator(pineId, version, token, signature);

  const std = new chart.Study(indic);

  std.onReady(() => {
    indicators.push([name, std]);
    if (loading === indicators.length) step();
  });

}

Expected behavior I was expecting to see the values in the cells.

Would a character like "ā†˜" lead to an absence of the "cells" key in the JSON object output?

Additional context

This is the current output:

image

Thank you for taking a look!

aiyunstunna commented 3 months ago

Update:

Cell data is still not being received on a simple pineScript which produces a table with all common characters that I tested just now.

PineScript:

//@version=5
indicator("TableTest", overlay=true)

// Define the table
var table tfTable = table.new(position.top_right, 1, 1, border_width = 0)
table.cell(tfTable, 0, 0, "M35", 2, text_color = color.yellow, text_size = size.small)

JSON Received:

"TableTest": {
    "plots": {},
    "graphics": {
      "tables": [
        {
          "id": 1,
          "position": "top_right",
          "rows": 1,
          "columns": 1,
          "bgColor": null,
          "frameColor": null,
          "frameWidth": 0,
          "borderColor": null,
          "borderWidth": 0
        }
      ]
    }
  },