class TelegramNotifier implements Partial<IPublicAction> {
private bot: TelegramBot | null = null;
constructor(
private strategyName: string,
private frameName: string,
private actionName: string
) {}
// Called once during initialization
async init() {
this.bot = new TelegramBot(process.env.TELEGRAM_TOKEN);
await this.bot.connect();
}
// Called on every signal event
async signal(event: IStrategyTickResult) {
if (event.action === 'opened') {
await this.bot.send(
`[${this.strategyName}/${this.frameName}] Signal opened: ${event.signal.side}`
);
}
}
// Called once during cleanup
async dispose() {
await this.bot?.disconnect();
this.bot = null;
}
}
Public action interface for custom action handler implementations.
Extends IAction with an initialization lifecycle method. Action handlers implement this interface to receive strategy events and perform custom logic.
Lifecycle:
Key features:
Common use cases: