INNER CODE UNIT · TypeScript
main
alexanderwanyoike/the0 · example-bots/typescript-price-alerts/main.ts:53
async function main(): Promise<void> {
// Parse configuration from environment (set by the platform)
const { id, config } = parse<BotConfig>();
// Extract configuration with defaults
const symbol = config.symbol || "BTC/USD";
const basePrice = config.base_price || 45000;
const alertThreshold = config.alert_threshold || 1.0;
const updateInterval = config.update_interval_ms || 5000;
// Load persistent state from previous runs
const persisted = state.get<PersistedState>("bot_state", {
priceHistory: [],
alertCount: 0,
});
logger.info(
{ botId: id, symbol, alertThreshold, loadedHistory: persisted?.priceHistory?.length ?? 0 },