Resumen
Este flujo de trabajo ejecuta cada hora to assemble un completo mercado context for trading agents. It pulls breaking news de Google, sentiment de Reddit financial communities, y analisis de YouTube mercado commentary. El agregado context feeds directamente en trading decision logic, giving agents un multi-source view ese haria tomar un human analyst horas to compile manualmente.
Desencadenador
Cron programar (cada hora durante mercado horas)
Programación
Ejecuta cada hora durante mercado horas (9:30 AM - 4 PM ET)
Pasos del flujo de trabajo
Define active tickers
Cargar el lista of tickers el trading agent es currently monitoreo.
Obtener breaking news
Search Google News for cada ticker to obtener el ultimo headlines y developments.
Pull Reddit sentiment
Search Reddit financial subreddits for discussion threads on cada ticker.
Get YouTube commentary
Search YouTube for reciente mercado analisis videos mentioning el ticker.
Agregar en context objeto
Fusionar news, sentiment, y commentary en un single structured context per ticker.
Feed to trading agent
Escribir el context to el agent's entrada queue o shared estado for toma de decisiones.
Implementacion en Python
import requests
import json
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime
from pathlib import Path
API_KEY = "your_scavio_api_key"
TICKERS = ["NVDA", "AAPL", "TSLA", "MSFT", "AMZN"]
def search(platform: str, query: str) -> list[dict]:
res = requests.post(
"https://api.scavio.dev/api/v1/search",
headers={"x-api-key": API_KEY},
json={"platform": platform, "query": query},
timeout=10,
)
res.raise_for_status()
return res.json().get("organic", [])[:5]
def fetch_ticker_context(ticker: str) -> dict:
news_query = f"{ticker} stock news today"
reddit_query = f"{ticker} stock discussion"
youtube_query = f"{ticker} market analysis"
with ThreadPoolExecutor(max_workers=3) as pool:
news_future = pool.submit(search, "google", news_query)
reddit_future = pool.submit(search, "reddit", reddit_query)
youtube_future = pool.submit(search, "youtube", youtube_query)
return {
"ticker": ticker,
"timestamp": datetime.utcnow().isoformat(),
"news": [{"title": r.get("title", ""), "snippet": r.get("snippet", ""), "link": r.get("link", "")} for r in news_future.result()],
"reddit": [{"title": r.get("title", ""), "score": r.get("score", 0), "subreddit": r.get("subreddit", "")} for r in reddit_future.result()],
"youtube": [{"title": r.get("title", ""), "channel": r.get("channel", ""), "views": r.get("views", 0)} for r in youtube_future.result()],
}
def run():
contexts = []
for ticker in TICKERS:
ctx = fetch_ticker_context(ticker)
contexts.append(ctx)
output = {
"run_time": datetime.utcnow().isoformat(),
"tickers": contexts,
}
# Write to agent input queue
output_path = Path("trading_context.json")
output_path.write_text(json.dumps(output, indent=2))
print(f"Context assembled for {len(TICKERS)} tickers at {output['run_time']}")
for ctx in contexts:
print(f" {ctx['ticker']}: {len(ctx['news'])} news, {len(ctx['reddit'])} reddit, {len(ctx['youtube'])} youtube")
if __name__ == "__main__":
run()Implementacion en JavaScript
const API_KEY = "your_scavio_api_key";
const TICKERS = ["NVDA", "AAPL", "TSLA", "MSFT", "AMZN"];
async function search(platform, query) {
const res = await fetch("https://api.scavio.dev/api/v1/search", {
method: "POST",
headers: { "x-api-key": API_KEY, "content-type": "application/json" },
body: JSON.stringify({ platform, query }),
});
if (!res.ok) throw new Error(`scavio ${res.status}`);
return ((await res.json()).organic ?? []).slice(0, 5);
}
async function fetchTickerContext(ticker) {
const [news, reddit, youtube] = await Promise.all([
search("google", `${ticker} stock news today`),
search("reddit", `${ticker} stock discussion`),
search("youtube", `${ticker} market analysis`),
]);
return {
ticker,
timestamp: new Date().toISOString(),
news: news.map((r) => ({ title: r.title ?? "", snippet: r.snippet ?? "", link: r.link ?? "" })),
reddit: reddit.map((r) => ({ title: r.title ?? "", score: r.score ?? 0, subreddit: r.subreddit ?? "" })),
youtube: youtube.map((r) => ({ title: r.title ?? "", channel: r.channel ?? "", views: r.views ?? 0 })),
};
}
async function run() {
const fs = await import("fs/promises");
const contexts = await Promise.all(TICKERS.map(fetchTickerContext));
const output = { runTime: new Date().toISOString(), tickers: contexts };
await fs.writeFile("trading_context.json", JSON.stringify(output, null, 2));
console.log(`Context assembled for ${TICKERS.length} tickers at ${output.runTime}`);
for (const ctx of contexts) {
console.log(` ${ctx.ticker}: ${ctx.news.length} news, ${ctx.reddit.length} reddit, ${ctx.youtube.length} youtube`);
}
}
run();Plataformas utilizadas
Búsqueda web con grafo de conocimiento, PAA y resúmenes de IA
YouTube
Búsqueda de videos con transcripciones y metadatos
Comunidad, publicaciones y comentarios en hilos de cualquier subreddit