@kumo-charts/core/alert-engine
API 레퍼런스는 소스 코드의 주석에서 생성되며 영어로만 제공됩니다.
import { … } from '@kumo-charts/core/alert-engine';
Functions
createAlertEnginefunction소스
function createAlertEngine(options: AlertEngineOptions = {}): AlertEngine
Evaluates alerts without a chart: give it the bars of a symbol at their source interval, the timeframe they are to be built to, the indicators and drawings its alerts read, and the alerts, and it reports each that fires, as a chart with the same would. Runs anywhere, Node included.
const engine = createAlertEngine({ indicators: [RSI] });
engine.data.set(bars, { interval: '1m' });
engine.data.setTimeframe('15m');
engine.indicators.add({ id: 'rsi', type: 'RSI' });
engine.alerts.add({ source: { kind: 'indicator', id: 'rsi' }, trigger: 'cross-up', value: 70 });
engine.on('alertTrigger', (event) => notify(event));
stream.onTrade((trade) => engine.data.addTrades(trade));Interfaces
AlertEngineinterface소스
interface AlertEngine
Alerts evaluated without a chart, as a chart with the same bars, timeframe, indicators and
drawings evaluates them: on a server, in a worker, or in a page for symbols no chart shows. Its
data, indicators, drawings and alerts work as a chart's, but for what only drawing
needs; an alert's event is never of a replay.
readonly data: Omit<DataApi, 'clear'>readonly indicators: AlertEngineIndicatorsreadonly drawings: Pick<
DrawingsApi,
'set' | 'add' | 'remove' | 'get' | 'list' | 'validate' | 'levels'
>readonly alerts: Omit<AlertsApi, 'clear'>setCalendar(calendar: CalendarInput): voidChanges the trading calendar, as chart.applyOptions({ calendar }) does.
on<K extends keyof AlertEngineEventMap>(
event: K,
listener: (event: AlertEngineEventMap[K]) => void
): () => voidListens to an event; returns the function that stops listening.
destroy(): voidStops reporting and lets the engine go.
AlertEngineEventMapinterface소스
interface AlertEngineEventMap
alertTrigger: AlertTriggerEventAlertEngineIndicatorsinterface소스
interface AlertEngineIndicators extends Pick<
IndicatorsApi,
'add' | 'remove' | 'get' | 'list' | 'register' | 'definition'
>
What an engine computes alerts on: indicators as a chart has them, without drawing them.
valuesAt(id: string, index?: number): IndicatorOutputValue[]The values of an indicator's outputs at displayed bar index; default, the latest bar.
AlertEngineOptionsinterface소스
interface AlertEngineOptions
Options of createAlertEngine.
readonly indicators?: readonly IndicatorDefinition[]The indicator types its alerts may read, as the indicators module takes them, such as
allIndicators; indicators.register() adds others. Default: none.
readonly drawings?: readonly DrawingTypeDefinition[]The drawing types whose lines its alerts may watch, as the drawings module takes them, such
as allDrawings. Default: none.
readonly calendar?: CalendarInputThe trading calendar timeframes are built and trades folded with, as the chart's calendar
option. Default: around the clock, in UTC.
IndicatorOutputValueinterface소스
interface IndicatorOutputValue
The value of an output of an indicator at a bar, null where it has none.
readonly key: stringreadonly value: number | null