Benzinga Market Data: Fetches Benzinga news, analyst ratings, earnings, guidance, dividends, splits, IPO, and economic calendars via API, with a news list view.
| 1 | import { definePlugin, defineView } from '@jaspers-ai/sdk' |
| 2 | import { z } from 'zod' |
| 3 | import { news } from './news' |
| 4 | import { earnings, guidance, ratings } from './calendars-analyst' |
| 5 | import { dividends, economics, ipos, splits } from './calendars-corporate' |
| 6 | import { NewsView } from './NewsView' |
| 7 | |
| 8 | export default definePlugin({ |
| 9 | id: 'benzinga', |
| 10 | secrets: { apikey: { label: 'Benzinga API token' } }, |
| 11 | sources: { news, ratings, earnings, dividends, splits, ipos, economics, guidance }, |
| 12 | views: { |
| 13 | news: defineView(NewsView, { |
| 14 | title: 'Benzinga news', |
| 15 | state: z.object({ |
| 16 | tickers: z.array(z.string()).max(50).default([]).describe('Tickers to show news for; empty for all news.'), |
| 17 | channels: z.array(z.string()).max(20).default([]).describe('Benzinga channels to filter on, like Earnings.'), |
| 18 | pageSize: z.number().int().min(1).max(100).default(30).describe('How many headlines.'), |
| 19 | }), |
| 20 | output: z.object({ |
| 21 | tickers: z.array(z.string()), |
| 22 | count: z.number(), |
| 23 | headlines: z.array(z.object({ created: z.string(), title: z.string() })), |
| 24 | }), |
| 25 | instructions: |
| 26 | 'A scrolling list of recent Benzinga headlines, newest first. Set state.tickers (like ["AAPL"]), optionally state.channels and state.pageSize.', |
| 27 | renders: [news], |
| 28 | summarize: (state, output) => |
| 29 | `Benzinga news ${state.tickers?.length ? state.tickers.join(',') : 'all'}: ${output.count} headlines`, |
| 30 | }), |
| 31 | }, |
| 32 | }) |