Skip to main content

LightningChart and AI

Generating code with large language models (LLMs) is a rapidly growing area of interest for developers. While LLMs are often capable of generating working code it can be a challenge to consistently generate code for libraries like LightningChart JS Trader that have several different versions and use cases.

This section is dedicated to hosting resources to help developers use AI tools with LightningChart JS Trader better.

tip

Please share your own experiences with AI/LLM tools capability to work with LightningChart JS Trader API at [email protected]

Guiding LLMs

In our experience LLM's are very poor at working with specific 3rd party libraries out of the box, because their training data is a mix of all the existing versions of that library. They also tend to hallucinate results by mixing data from various different libraries.

tip

Better results can be achieved by pointing your agents to use a specific set of LLM-friendly resources when thinking how to use LightningChart JS Trader.

For this purpose, we provide versions of our developer documentation and API reference in LLM friendly formats here:

Our recommendation is to ensure your LLM has access to these files and specifically instruct the LLM to use them as the source of truth on all matters LightningChart JS.

If in practice your LLM attempts un-optimal approaches such as:

Then it is most likely a sign that you should tweak or alter your prompt and reattempt the command.

Working with Agents

Our recommendation is to download lcjstrader-docs-llms.txt and lcjstrader-api-llms.txt to your repository and add following section to your AGENTS.md, CLAUDE.md or equivalent:

- You MUST always use the local files lcjstrader-docs-llms.txt and lcjstrader-api-llms.txt as the only sources of truth for all matters regarding how to use LightningChart JS Trader library / lcjstrader

Importance of type checking

As LightningChart JS Trader is a strongly typed library, probably the single best thing you can do to improve the work quality of your agents is to instruct them to run a type check after any code change:

- After any code change, confirm that typings are OK using `npm run typecheck`

Where typecheck script will just run tsc --noEmit or equivalent. Then, if there are type errors (which are extremely common due to hallucinations or outdated training data), the agent will reattempt immediately rather than waiting for you to tell that it doesn't work.

Working with chat-based LLMs

In our experience, chat-based LLMs have much more trouble following a seemingly simple instruction like "refer to X for guidance". Furthermore, there are great differences between platforms. For example:

  • GPT-5.2 - the LLM tells you that it will stick strictly to the specified documentation, then proceeds to dump hallucinated API usages that have never existed in the library
  • Sonnet 4.5 / Opus 4.5 - these models were able to follow the instructions well and provide up to date and well referenced recommendations

You can confirm whether the model is listening to your requirement by additionally asking it to cite all references, and checking if it lists external sources. When receiving non-working results, the reason is often referencing several years old API documentation pages or just answering directly from training data.

Ideally it would be sufficient to just include this in every new chat context:

- You MUST always use the https://lightningchart.com/js-charts/trader/docs/llms.txt and https://lightningchart.com/js-charts/trader/api-documentation/v4.1.1/llms.txt as the only sources of truth for all matters regarding how to use LightningChart JS Trader library / lcjstrader
info

No one likes hallucinated chart code - please help us maintain an effective instruction set by sharing what works best for you at [email protected]

Here is also an alternate version of developer documentation intended for LLMs where all text content is put into one large file. In our experience, this doesn't work too well but you can give it a try.