API Reference
Namespaces
Classes
Events
Global
Externals

Global

Members


<constant> configuration

Configuration object for the ChartIQ AI Spark Proxy Server


<constant> express

ChartIQ AI Proxy Server

This server acts as a proxy between client applications and the AI API, providing different modes of operation for interacting with ChartIQ's CLI registry.

CONFIGURATION: The server uses config.js for configuration settings:

  • api_url: The AI API endpoint URL
  • apiKey: API key (empty by default, prompted at startup if not set)
  • systemPrompt: System prompt content (populated at runtime from prompt files)

USAGE: node server.js [mode]

On startup, the server will prompt for an API key if not configured in config.js. The API key is used for all requests and includes infinite retry capability - if an API key becomes invalid during operation, the server will prompt for a new key and continue processing the request without losing it.

MODES: tools (default) - Function calling mode with ChartIQ CLI tools - Loads prompt from prompt_tools.txt - Generates OpenAI function definitions from CLI registry - Executes tool functions when called by AI - Returns structured response with executed commands

json - JSON response mode with chart commands as context - Loads prompt from prompt_json.txt - Appends chart command documentation to system prompt - Forces JSON object response format - Parses AI response as JSON and extracts message/cmd fields

EXAMPLES: node server.js # Runs in tools mode (default) node server.js tools # Runs in tools mode (explicit) node server.js json # Runs in JSON mode

The server will start on port 3000 and accept POST requests with user queries. Different modes provide different ways for the AI to interact with ChartIQ functionality. API authentication is handled at server startup with robust error recovery.


instanceID

InstanceID is needed to match a Study instance to the corresponding CIQ.Studies library entry.

This is necessary due to the decision not to store a CIQ.ChartEngine instance per-dataset in favor of always relying on the passed-in CIQ.ChartEngine.

By assocating each dataset with a CIQ.ChartEngine we could handle this mapping automatically, but since we rely on the passed-in CIQ.ChartEngine, we must register separate CIQ.Studies library entries, since the callback functions StudyDescriptor instance

Methods


$$(id [, source])

Shorthand for getElementById().

Equivalent to prototype style $(), which is faster but less powerful than jQuery style $().

Parameters:
Name Type Argument Description
id string

An ID tag for a valid DOM element.

source HTMLElement <optional>

A valid DOM node to search within. If not provided, the entire document is searched.

Returns:

The DOM node associated with the ID, or null if a node is not found.

Type
HTMLElement

$$$(selector [, source])

Functional equivalent of querySelector().

Functionally equivalent to jQuery $(). Uses querySelectorAll to maintain compatibility with Internet Explorer 9.

Note: If multiple elements match the selector, only the first is returned.

Parameters:
Name Type Argument Description
selector string

CSS style selector.

source HTMLElement <optional>

Node to select within. If not provided, the entire document is searched.

Returns:

The first element to match the selector.

Type
HTMLElement

Executor(registry [, rpcClient])

Executor — a command interpreter for string input.

Parameters:
Name Type Argument Description
registry object | function

command registry; can be a function that overrides the default executor

rpcClient object <optional>

JSON-RPC client; optional. If not passed in the executor will not be able to execute RPC commands.

Since:
  • 9.6.0

Returns:

a function that interprets string input and executes commands

Type
function
Example
const executor = Executor(function (input) {
		// note: you must call this in an environment where `this.echo` is defined
		fetch("http://llm.example.com/v1/chat/completions", {
			method: "POST",
			headers: {
				"Content-Type": "application/json",
				Authorization: `Bearer ${apikey}`
			},
			body: JSON.stringify({
				model: "ng-3.5-turbo",
				messages: [{ role: "system", content: input }]
			})
		})
			.then((response) => response.json())
			.then(this.echo)
			.catch(this.echo);
	});

constructMessagePayload()

Constructs the message payload for the API request, including mode-specific configuration.


<async> executeAPIRequest()

Executes the API request to the AI API


init()

Initialize the component.

Since:
  • 8.3.0


<async> initializeChartIQRegistryAPI()

Async function to load the registry and generate tools or chart commands


normalizeColors(parameters)

Normalizes color fields in study parameters to ensure they are strings for mobile compatibility. Handles cases where colors might be returned as objects.

Parameters:
Name Type Description
parameters Array

Array of study parameter objects

Since:
  • 10.0.0

Returns:

Normalized parameters with color fields as strings

Type
Array

processResponseAndExecuteTools()

Processes the API response and executes any tool calls


registerFDC3(stx [, config])

Registers the chart with the FDC3 connector.

To enable this function, include the fdc3.js file (in the js/extras folder of the library) in your application. The file provides access to the open protocols established by the Financial Desktop Connectivity and Collaboration Consortium (FDC3) and FINOS for desktop inter-application messaging.

Parameters:
Name Type Argument Description
stx CIQ.ChartEngine

The chart engine instance.

config object <optional>

Configuration options. Provide only those specifications you want to customize. The rest of the configuration will be the default values shown below.

Properties
Name Type Argument Default Description
broadcastAsIntent boolean <optional>
true

Whether to respond to a broadcast as if responding to an intent.

maxSymbols number <optional>
16

Maximum number of comparison symbols allowed.

swatchColors Array.<string> <optional>

Color codes to use for comparison series plots. See the parameters.color parameter of CIQ.ChartEngine#addSeries for accepted formats of the color strings.

In the default implementation, defaultSeriesParams, the colors are selected sequentially as comparison series are added to the chart. When the last color in the array has been used, selection resumes at the first color in the array. To ensure unique colors for all comparison series, create an array maxSymbols in length filled with unique color values.

Default

["#8ec648", "#00afed", "#ee652e", "#912a8e", "#fff126", "#e9088c", "#ea1d2c",
 "#00a553", "#00a99c", "#0056a4", "#f4932f", "#0073ba", "#66308f", "#323390"]
defaultSeriesParams function <optional>

Provides parameters to the CIQ.ChartEngine#addSeries function based on symbol. Customize this parameter by assigning a function that contains custom specifications.

The function has three parameters which are supplied with arguments when the function is called:

  • symbol — The symbol of the comparison series added to the chart. Use this parameter to create symbol-specific customizations.
  • instrCount — The numerical order in which the series is added to the chart; for example, 3 indicates that the series is the third comparison series added to the chart.
  • colors — A array of colors from which the color of the comparison series plot can be selected. See swatchColors.

Default

(symbol, instrCount, colors) => {
    return {
        renderer: "Lines",
        color: colors[instrCount % colors.length],
        width: 1,
        pattern: "solid"
    };
}
defaultPeriodicity function <optional>

Provides periodicity to the CIQ.ChartEngine#loadChart function in a multiseries chart. See CIQ.ChartEngine~PeriodicityParameters. Customize this parameter by assigning a function that contains custom specifications.

The function has a single boolean parameter that indicates whether the chart shows holdings (that is, positions or a portfolio), in which case you may want to show a different periodicity. An argument is provided when the function is called.

Default

(isHolding) => {
    if (isHolding)
        return {
            interval: "day"
        };
    return {
        period: 1,
        interval: 5,
        timeUnit: "minute"
    };
}
Since:
  • 8.2.0
  • 8.2.1 Added the config parameter.

<async> renewAPIKey()

Prompts the user to enter an API key via the terminal and updates the configuration


setBounds(bounds)

Sets the min, max, and step of the slider.

Parameters:
Name Type Description
bounds object

Contains min, max, and step values.

Since:
  • 8.3.0


setConfigBasedUI(context)

Replaces default CrossPlot dropdown menus with a context-based menu.

Parameters:
Name Type Description
context CIQ.UI.Context

The context for the chart.


setValue( [data])

Sets the high and low values of the slider.

The high and low values are restricted to the range of the max and min.

Parameters:
Name Type Argument Description
data object <optional>

Contains high and low values.

Since:
  • 8.3.0


startActiveTrader(stx)

Starts the Active Trader module

Parameters:
Name Type Description
stx CIQ.ChartEngine

Chart Engine

Returns:

Chart Engine (same object as the input parameter)

Type
CIQ.ChartEngine

<async> startServer()

Main function to initialize the server with API key prompt


updateVisual()

Updates the slider view based on the slider attributes.

Since:
  • 8.3.0


validateAndParseRequest()

Validates and parses the incoming request data