Use a Controller object to add the generator to a chart:
const newsGenerator = controller.addGenerator('PriceTarget');
type PriceTargetDataPoint = {
startDate: number,
endDate: number,
mean: number,
high: number,
low: number
};
type PriceTargetFetcher = (params: { instrument: string, currency?: string }) => Promise<PriceTargetDataPoint[]>;
The generator exposes several public methods.
Type
declare class NewsGenerator {
static setDataInterface(priceTargetFetcher: PriceTargetFetcher): void
}
Details
setDataInterface adds the callback to the generator which are required for loading data.
priceTargetFetch is used to fetch price target data. The instrument and an optional currency will be passed to the function, which needs to return a PriceTargetDataPoint array.
Type
interface NewsGenerator {
setDataPoints(articles: ArticleData[]): void;
}
Details
setDataPoints takes a PriceTargetDataPoint array and adds those to the chart. May be used as a very simple alternative to the setDataInterface method, though this requires manual calling when the instrument or currency of the chart changes.
The generator has a built-in permission check, which is called in its onStart method. It calls the provided checkPermission method (via Controller) with the key PriceTarget.