Chartbreaker
    Preparing search index...

    interface for a custom time series data loader.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    events?: {
        invalidate: () => void;
        push: (data: Result<{ data: null | boolean | DataLoaderTPush }>) => void;
    }

    Phantom data for type inference

    Methods

    • Type Parameters

      • Type extends "push" | "invalidate"
      • Callback extends
            | ((data: Result<{ data: null | boolean | DataLoaderTPush }>) => void)
            | (() => void)

      Parameters

      Returns this

      adds a listener to the end of the listeners array for the specified event.

    • destroy loader object

      this is called once the timeseries is no longer visible in any charts, and also removed from the internal data cache

      the implementation should unregister any active push updates or other subscriptions here

      Returns boolean

    • Type Parameters

      • Type extends "push" | "invalidate"
      • Callback extends
            | ((data: Result<{ data: null | boolean | DataLoaderTPush }>) => void)
            | (() => void)

      Parameters

      Returns boolean

      execute each of the listeners in order with the supplied parameters.

    • Type Parameters

      • Type extends "push" | "invalidate"
      • Callback extends
            | ((data: Result<{ data: null | boolean | DataLoaderTPush }>) => void)
            | (() => void)

      Parameters

      Returns Callback[]

      returns an array of listeners for the specified event.

    • load data for the specified resolution

      data needs to be structured as follows: [ [timestamp:integer,close:float,open:float,high:float,low:float,volume:float]* ] timestamps are represented as unix timestamps (in milliseconds) if volume is not available, the implementation should provide 0 values if only one value is available, provide the same values for close,open,high,low

      The retrieved data should NOT be cached/stored; this is handled automatically by the TSData object.

      To update the initially provided historical data the delegate can forward updates in the form of DataLoader.TPush objects to the push-event. The provided objects can either contain individual prices (only a quote value) or whole OHLCV values. The most recent data set can be updated by providing an object with a timestamp in the same candle range, containing a OHLCV values. Older data can not be modified anymore; timestamps before the beginning of the current candle are therefore not accepted. The logic for ticks is similar: Ticks smaller than the previously provided value are not accepted. Each object has to at least specify a timestamp and either a price or a set of OHLCV values. Tick numbers are optional except for tick resolution, where they are mandatory.

      NOTE: when not providing ticks, the implementation will use an automatically assigned number that increases by one for every provided object. It does not distinguish between UPDATE/REPLACE/APPEND, so it is encouraged to provide ticks manually.

      The 'push'-event is also used to forward state information to the library. Boolean arguments signify if the push is currently busy catching up / synchronizing; true: push updates are working on catching up false or null: streaming push updates are in sync (again), no error Alternatively an instance of ChartbreakerError or RecoverableChartbreakerError can be provided. If a RecoverableChartbreakerError is provided, the library might call the resumePush method at a later time to trigger recovery. NOTE: Errors can be cleared by the loader, by providing false or null.

      The 'invalidate'-event can be called to invalidate the provided data and force a reload of any chart currently displaying it.

      the context object can contain arbitrary information about the environment in the key "env". it can be provided when constructing the Controller/ChartSet for example, when generating charts on the server, this object could be used to hold authentication information about the request (e.g. userId, permissions), that are required when loading data. values stored unter "env" must not be modified. additionally, there are also values stored under the key "pass". These get automatically reset every time data is loaded, and can be modified by loaders. For example, these values could be used to keep track of which permissions where actually used to construct a specific chart.

      Parameters

      Returns Promise<
          | { err: ChartbreakerError; metaData?: undefined; values?: undefined }
          | { err?: undefined; metaData: DataLoaderTMetaData; values: OHLCVData[] },
      >

    • map options and current defaults to a unique timeseries identifier

      timeseries identifiers must be distinct. This means that "options" that result in different data must also generate a different unique identifier

      when the value of an option provided via the metadata object changes, this method is called to generate the new identifier. the timeseries is then automatically replaced, and a new loader is created for the new identifier.

      Example: Assume a loader called "Instrument" has an option to switch between "bid" and "ask" values. The initial identifier is "Instrument(APPL,bid)". When the option "quoteType" is set to "ask" this implementation should return "Instrument(AAPL,ask)"

      Additionally, this method is use to finalize any default values, to make sure that even if the default value changes in the future, a serialized chart will ALWAYS look the same.

      Example: Assume the loader mentioned in the previous example is created via the identifier "Instrument(AAPL)". As the quote type is not specified, the implementation automatically uses "bid". When this method is called, the implementation should return "Instrument(AAPL,bid)"

      Returns string

      identifier matching the specified options

    • Type Parameters

      • Type extends "push" | "invalidate"
      • Callback extends
            | ((data: Result<{ data: null | boolean | DataLoaderTPush }>) => void)
            | (() => void)

      Parameters

      Returns this

      alias for addListener

    • Type Parameters

      • Type extends "push" | "invalidate"
      • Callback extends
            | ((data: Result<{ data: null | boolean | DataLoaderTPush }>) => void)
            | (() => void)

      Parameters

      Returns this

      adds a one time listener for the event. This listener is invoked only the next time the event is fired, after which it is removed.

    • Recover previously suspended push updates

      This method can be called by the library if the loader previously called the pushCb provided to load with an instance of RecoverableChartbreakerError

      Should return true if a recovery was attemped, false otherwise

      NOTE: if true is returned, recovery can still have failed immediately; in this case the loader could even signal another error before returning. But if false is returned, it must not signal a change in push state

      Returns boolean

    • Type Parameters

      • Type extends "push" | "invalidate"

      Parameters

      Returns this

      removes all listeners, or those of the specified event.

    • Type Parameters

      • Type extends "push" | "invalidate"
      • Callback extends
            | ((data: Result<{ data: null | boolean | DataLoaderTPush }>) => void)
            | (() => void)

      Parameters

      Returns this

      remove a listener from the listener array for the specified event.

    • Parameters

      • maxListeners: number

      Returns this

      by default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default which helps finding memory leaks. Obviously not all Emitters should be limited to 10. This function allows that limit to be increased. Set to zero for unlimited.

    • Parameters

      • maxGapDuration: number
      • pushFn: (id: string, cb: (data: DataLoaderTPush) => void) => { unbind: () => void }

      Returns void

    • Method to subscribe to push data from the source determined by the setPush method

      Parameters

      Returns { unbind: () => void }

    • static fuction to handle portfolio invalidates default dummy implementation

      Parameters

      • portfolioId: number
      • cb: (data: any) => void

      Returns { unbind(): void }

    • static function to subscribe to push data default dummy implementation

      Parameters

      Returns { unbind: () => void }

    • Parameters

      • auth: { clientId: string; locale?: string; token: () => Promise<null | string> }

      Returns void

    • Parameters

      • maxListeners: number

      Returns void

      set default amount for limit warning

    • static function to override invalidate function with cusotm implementation

      Parameters

      • cb: (portfolioId: number, cb: (data: any) => void) => { unbind: () => void }

      Returns void

    • static function to override push function with custom implementation

      Parameters

      • maxGapDuration: number
      • pushFn: (
            portfolioId: string,
            cb: (data: DataLoaderTPush) => void,
        ) => { unbind: () => void }

      Returns void

    • optional method to set custom URLs.

      Parameters

      • data: { apiURL?: string }

        Record containing a key/URL pairing.

      Returns void