Class RealTimeDataBeta

A class that allows you to receive real-time data from the ForexPro websocket (used by investing.com).

import { RealTimeData } from "investing-com-api";
const realTimeData = new RealTimeData();
realTimeData.on(RealTimeData.ON_OPEN, () => {
realTimeData.subscribe([1057391]);
});

realTimeData.on(RealTimeData.ON_DATA, (data: PidInfo) => {
console.log(data);
})

Hierarchy

  • EventEmitter
    • RealTimeData

Constructors

Properties

prefixed: string | boolean

Methods

  • Beta

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: (...args: any[]) => void
    • Optionalcontext: any

    Returns this

  • Beta

    Close the websocket connection. After calling this method, the close event will be emitted.

    Usage:

    realTimeData.close()
    

    Returns void

  • Beta

    Calls each of the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • ...args: any[]

    Returns boolean

  • Beta

    Return an array listing the events for which the emitter has registered listeners.

    Returns (string | symbol)[]

  • Beta

    Return the number of listeners listening to a given event.

    Parameters

    • event: string | symbol

    Returns number

  • Beta

    Return the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T

    Returns (...args: any[]) => void[]

  • Beta

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optionalfn: (...args: any[]) => void
    • Optionalcontext: any
    • Optionalonce: boolean

    Returns this

  • Beta

    Add a listener for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: (...args: any[]) => void
    • Optionalcontext: any

    Returns this

  • Beta

    Add a one-time listener for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: (...args: any[]) => void
    • Optionalcontext: any

    Returns this

  • Beta

    Remove all listeners, or those of the specified event.

    Parameters

    • Optionalevent: string | symbol

    Returns this

  • Beta

    Remove the listeners of a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optionalfn: (...args: any[]) => void
    • Optionalcontext: any
    • Optionalonce: boolean

    Returns this

  • Beta

    Subscribe to a list of pair ids. You can find the pair id using the searchQuotes function. Call this function after the open event is emitted.

    Parameters

    • pairIds: number[]

      The pair ids to subscribe to.

    Returns void

    realTimeData.subscribe([1057391])
    

Events

ON_CLOSE: string = "close"

Emitted when the websocket connection is closed.

ON_DATA: string = "data"

Emitted when new data is received.

The data received.

ON_ERROR: string = "error"

Emitted when an error occurs.

ON_OPEN: string = "open"

Emitted when the websocket connection is opened.