"""market_news tool — delegates to NewsService and returns JSON."""

from __future__ import annotations

import json

from finagent_pro.services.news import NewsService

_service = NewsService()


def market_news(
    query: str,
    ticker: str | None = None,
    days_back: int = 7,
) -> str:
    """Fetch recent market news articles."""
    articles = _service.get_news(ticker=ticker, query=query, days_back=days_back)
    return json.dumps(articles, default=str)
