Value-Betting-Bot
Dieses Beispiel erstellt einen Discord/Telegram-Bot, der Sie in Echtzeit über +EV-Möglichkeiten benachrichtigt.
Architektur
SharpAPI SSE Stream → Bot Server → Discord/TelegramImplementierung
1. Abhängigkeiten einrichten
npm install eventsource discord.js dotenv2. Den Bot erstellen
// ev-bot.js
import EventSource from 'eventsource';
import { Client, GatewayIntentBits, EmbedBuilder } from 'discord.js';
const SHARP_API_KEY = process.env.SHARP_API_KEY;
const DISCORD_TOKEN = process.env.DISCORD_TOKEN;
const CHANNEL_ID = process.env.DISCORD_CHANNEL_ID;
// Discord setup
const discord = new Client({ intents: [GatewayIntentBits.Guilds] });
discord.once('ready', () => {
console.log('Discord bot ready');
startEVStream();
});
// EV Stream
function startEVStream() {
const url = `https://api.sharpapi.io/api/v1/stream?channel=opportunities&min_ev=3.0&api_key=${SHARP_API_KEY}`;
const es = new EventSource(url);
es.addEventListener('ev:detected', async (e) => {
const { opportunities } = JSON.parse(e.data).data;
for (const opp of opportunities) {
await sendAlert(opp);
}
});
es.onerror = (err) => {
console.error('Stream error:', err);
};
}
// Send Discord alert
async function sendAlert(opp) {
const channel = await discord.channels.fetch(CHANNEL_ID);
const embed = new EmbedBuilder()
.setColor(opp.ev_percentage >= 5 ? 0xFF0000 : 0x00FF00)
.setTitle(`${opp.ev_percentage >= 5 ? '🔥' : '✅'} +EV Alert`)
.setDescription(`**${opp.game}**`)
.addFields(
{ name: 'Selection', value: opp.selection, inline: true },
{ name: 'Book', value: opp.sportsbook, inline: true },
{ name: 'Odds', value: String(opp.odds_american), inline: true },
{ name: 'EV', value: `+${opp.ev_percentage}%`, inline: true },
{ name: 'Kelly', value: `${opp.kelly_percent.toFixed(2)}%`, inline: true },
{ name: 'Devig', value: `${opp.no_vig_odds} (${opp.sharp_book})`, inline: true },
)
.setTimestamp();
await channel.send({ embeds: [embed] });
}
discord.login(DISCORD_TOKEN);3. Ausführen
SHARP_API_KEY=sk_live_xxx \
DISCORD_TOKEN=xxx \
DISCORD_CHANNEL_ID=xxx \
node ev-bot.jsFilterung
Passen Sie an, welche Benachrichtigungen Sie erhalten:
es.addEventListener('ev:detected', async (e) => {
const { opportunities } = JSON.parse(e.data).data;
for (const opp of opportunities) {
// Only high EV
if (opp.ev_percentage < 5) continue;
// Only certain sports
if (!['nba', 'nfl'].includes(opp.sport)) continue;
// Only certain books
if (!['draftkings', 'fanduel'].includes(opp.sportsbook)) continue;
await sendAlert(opp);
}
});Telegram-Version
import TelegramBot from 'node-telegram-bot-api';
const bot = new TelegramBot(process.env.TELEGRAM_TOKEN, { polling: false });
const chatId = process.env.TELEGRAM_CHAT_ID;
async function sendTelegramAlert(opp) {
const message = `
${opp.ev_percentage >= 5 ? '🔥' : '✅'} *+EV Alert*
*${opp.game}*
Selection: ${opp.selection}
Book: ${opp.sportsbook}
Odds: ${opp.odds_american}
EV: +${opp.ev_percentage}%
Kelly: ${opp.kelly_percent.toFixed(2)}%
`.trim();
await bot.sendMessage(chatId, message, { parse_mode: 'Markdown' });
}Siehe auch
- Konzepte der EV-Berechnung - Wie SharpAPI den Erwartungswert berechnet
- Beispiel für einen Arbitrage-Scanner - Ähnlicher Bot zur Echtzeit-Arbitrage-Erkennung
- +EV Opportunities API - Endpoint-Referenz
Last updated on