syntax = "proto3";

package worldmonitor.market.v1;

import "sebuf/http/annotations.proto";
import "worldmonitor/market/v1/list_market_quotes.proto";
import "worldmonitor/market/v1/list_crypto_quotes.proto";
import "worldmonitor/market/v1/list_commodity_quotes.proto";
import "worldmonitor/market/v1/get_sector_summary.proto";
import "worldmonitor/market/v1/list_stablecoin_markets.proto";
import "worldmonitor/market/v1/list_etf_flows.proto";
import "worldmonitor/market/v1/get_country_stock_index.proto";
import "worldmonitor/market/v1/list_gulf_quotes.proto";
import "worldmonitor/market/v1/analyze_stock.proto";
import "worldmonitor/market/v1/backtest_stock.proto";
import "worldmonitor/market/v1/get_stock_analysis_history.proto";
import "worldmonitor/market/v1/list_stored_stock_backtests.proto";
import "worldmonitor/market/v1/list_crypto_sectors.proto";
import "worldmonitor/market/v1/list_defi_tokens.proto";
import "worldmonitor/market/v1/list_ai_tokens.proto";
import "worldmonitor/market/v1/list_other_tokens.proto";
import "worldmonitor/market/v1/get_fear_greed_index.proto";
import "worldmonitor/market/v1/list_earnings_calendar.proto";
import "worldmonitor/market/v1/get_cot_positioning.proto";
import "worldmonitor/market/v1/get_insider_transactions.proto";
import "worldmonitor/market/v1/get_market_breadth_history.proto";
import "worldmonitor/market/v1/get_gold_intelligence.proto";
import "worldmonitor/market/v1/get_hyperliquid_flow.proto";

// MarketService provides APIs for financial market data from Finnhub, Yahoo Finance, and CoinGecko.
service MarketService {
  option (sebuf.http.service_config) = {base_path: "/api/market/v1"};

  // ListMarketQuotes retrieves stock and index quotes.
  rpc ListMarketQuotes(ListMarketQuotesRequest) returns (ListMarketQuotesResponse) {
    option (sebuf.http.config) = {path: "/list-market-quotes", method: HTTP_METHOD_GET};
  }

  // ListCryptoQuotes retrieves cryptocurrency quotes from CoinGecko.
  rpc ListCryptoQuotes(ListCryptoQuotesRequest) returns (ListCryptoQuotesResponse) {
    option (sebuf.http.config) = {path: "/list-crypto-quotes", method: HTTP_METHOD_GET};
  }

  // ListCommodityQuotes retrieves commodity price quotes from Yahoo Finance.
  rpc ListCommodityQuotes(ListCommodityQuotesRequest) returns (ListCommodityQuotesResponse) {
    option (sebuf.http.config) = {path: "/list-commodity-quotes", method: HTTP_METHOD_GET};
  }

  // GetSectorSummary retrieves market sector performance data from Finnhub.
  rpc GetSectorSummary(GetSectorSummaryRequest) returns (GetSectorSummaryResponse) {
    option (sebuf.http.config) = {path: "/get-sector-summary", method: HTTP_METHOD_GET};
  }

  // ListStablecoinMarkets retrieves stablecoin peg health and market data from CoinGecko.
  rpc ListStablecoinMarkets(ListStablecoinMarketsRequest) returns (ListStablecoinMarketsResponse) {
    option (sebuf.http.config) = {path: "/list-stablecoin-markets", method: HTTP_METHOD_GET};
  }

  // ListEtfFlows retrieves BTC spot ETF flow estimates from Yahoo Finance.
  rpc ListEtfFlows(ListEtfFlowsRequest) returns (ListEtfFlowsResponse) {
    option (sebuf.http.config) = {path: "/list-etf-flows", method: HTTP_METHOD_GET};
  }

  // GetCountryStockIndex retrieves the primary stock index for a country from Yahoo Finance.
  rpc GetCountryStockIndex(GetCountryStockIndexRequest) returns (GetCountryStockIndexResponse) {
    option (sebuf.http.config) = {path: "/get-country-stock-index", method: HTTP_METHOD_GET};
  }

  // ListGulfQuotes retrieves Gulf region market quotes (indices, currencies, oil).
  rpc ListGulfQuotes(ListGulfQuotesRequest) returns (ListGulfQuotesResponse) {
    option (sebuf.http.config) = {path: "/list-gulf-quotes", method: HTTP_METHOD_GET};
  }

  // AnalyzeStock retrieves a premium stock analysis report with technicals, news, and AI synthesis.
  rpc AnalyzeStock(AnalyzeStockRequest) returns (AnalyzeStockResponse) {
    option (sebuf.http.config) = {path: "/analyze-stock", method: HTTP_METHOD_GET};
  }

  // GetStockAnalysisHistory retrieves shared premium stock analysis history from the backend store.
  rpc GetStockAnalysisHistory(GetStockAnalysisHistoryRequest) returns (GetStockAnalysisHistoryResponse) {
    option (sebuf.http.config) = {path: "/get-stock-analysis-history", method: HTTP_METHOD_GET};
  }

  // BacktestStock replays premium stock-analysis signals over recent price history.
  rpc BacktestStock(BacktestStockRequest) returns (BacktestStockResponse) {
    option (sebuf.http.config) = {path: "/backtest-stock", method: HTTP_METHOD_GET};
  }

  // ListStoredStockBacktests retrieves stored premium backtest snapshots from the backend store.
  rpc ListStoredStockBacktests(ListStoredStockBacktestsRequest) returns (ListStoredStockBacktestsResponse) {
    option (sebuf.http.config) = {path: "/list-stored-stock-backtests", method: HTTP_METHOD_GET};
  }

  // ListCryptoSectors retrieves crypto sector performance averages.
  rpc ListCryptoSectors(ListCryptoSectorsRequest) returns (ListCryptoSectorsResponse) {
    option (sebuf.http.config) = {path: "/list-crypto-sectors", method: HTTP_METHOD_GET};
  }

  // ListDefiTokens retrieves DeFi token prices and changes.
  rpc ListDefiTokens(ListDefiTokensRequest) returns (ListDefiTokensResponse) {
    option (sebuf.http.config) = {path: "/list-defi-tokens", method: HTTP_METHOD_GET};
  }

  // ListAiTokens retrieves AI-focused crypto token prices and changes.
  rpc ListAiTokens(ListAiTokensRequest) returns (ListAiTokensResponse) {
    option (sebuf.http.config) = {path: "/list-ai-tokens", method: HTTP_METHOD_GET};
  }

  // ListOtherTokens retrieves other/trending crypto token prices and changes.
  rpc ListOtherTokens(ListOtherTokensRequest) returns (ListOtherTokensResponse) {
    option (sebuf.http.config) = {path: "/list-other-tokens", method: HTTP_METHOD_GET};
  }

  // GetFearGreedIndex retrieves the composite Fear & Greed sentiment index.
  rpc GetFearGreedIndex(GetFearGreedIndexRequest) returns (GetFearGreedIndexResponse) {
    option (sebuf.http.config) = {path: "/get-fear-greed-index", method: HTTP_METHOD_GET};
  }

  // ListEarningsCalendar retrieves upcoming and recent earnings releases.
  rpc ListEarningsCalendar(ListEarningsCalendarRequest) returns (ListEarningsCalendarResponse) {
    option (sebuf.http.config) = {path: "/list-earnings-calendar", method: HTTP_METHOD_GET};
  }

  // GetCotPositioning retrieves CFTC COT institutional positioning data.
  rpc GetCotPositioning(GetCotPositioningRequest) returns (GetCotPositioningResponse) {
    option (sebuf.http.config) = {path: "/get-cot-positioning", method: HTTP_METHOD_GET};
  }

  // GetInsiderTransactions retrieves SEC insider buy/sell activity from Finnhub.
  rpc GetInsiderTransactions(GetInsiderTransactionsRequest) returns (GetInsiderTransactionsResponse) {
    option (sebuf.http.config) = {path: "/get-insider-transactions", method: HTTP_METHOD_GET};
  }

  // GetMarketBreadthHistory retrieves historical % of S&P 500 stocks above 20/50/200-day SMAs.
  rpc GetMarketBreadthHistory(GetMarketBreadthHistoryRequest) returns (GetMarketBreadthHistoryResponse) {
    option (sebuf.http.config) = {path: "/get-market-breadth-history", method: HTTP_METHOD_GET};
  }

  // GetGoldIntelligence retrieves gold pricing, cross-currency XAU, ratios, and CFTC positioning.
  rpc GetGoldIntelligence(GetGoldIntelligenceRequest) returns (GetGoldIntelligenceResponse) {
    option (sebuf.http.config) = {path: "/get-gold-intelligence", method: HTTP_METHOD_GET};
  }

  // GetHyperliquidFlow retrieves Hyperliquid perp positioning flow (funding/OI/basis composite scores).
  rpc GetHyperliquidFlow(GetHyperliquidFlowRequest) returns (GetHyperliquidFlowResponse) {
    option (sebuf.http.config) = {path: "/get-hyperliquid-flow", method: HTTP_METHOD_GET};
  }
}
