> ## Documentation Index
> Fetch the complete documentation index at: https://aisa.one/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> - Base URLs: models `https://api.aisa.one/v1` (Gemini GenerateContent: `https://api.aisa.one/v1beta`); data APIs `https://api.aisa.one/apis/v1`. The `servers` of each operation in https://aisa.one/openapi.yaml is authoritative.
> - Auth: `Authorization: Bearer $AISA_API_KEY`. Never print, log, or commit the key.
> - MCP (preferred for agents): `https://mcp.aisa.one/mcp`, signed in with OAuth, so there is no key to paste.
> - Agent Skill: `npx skills add AIsa-team/agent-skills --skill aisa`. Fallback with the AIsa CLI: `aisa skills install aisa`.
> - Spending: docs, https://aisa.one/models, https://aisa.one/api, `/v1/models`, and MCP `search`, `list_categories`, `get_details`, `batch_quote`, and the `account` operation are free. Quote the exact calls before running them (MCP `batch_quote`, CLI `aisa quote --json`). If the quote reports `auto_execute_eligible: true`, run it unless the user set a tighter limit or asked only for a quote. Otherwise, tell the user in one message the planned calls, the quoted price, and a total USD budget for the task, then wait for approval. Direct HTTP calls follow the stricter rule at https://aisa.one/docs/get-started/cli.md#direct-http-fallback. Do not make paid calls to test availability. Full rule: https://aisa.one/llms.txt

# Trend Forecast

> 基于预测市场、社交信号、新闻和市场数据进行趋势预测。

[在 GitHub 上查看 →](https://github.com/AIsa-team/agent-skills/tree/main/financial/trend-forecast)

**多信号源趋势预测。** 结合预测市场、社交数据、新闻和市场走势，生成带置信度评分的分析报告。

## 安装

```bash npx skills theme={null}
npx skills add AIsa-team/agent-skills --skill trend-forecast
```

```bash AIsa CLI theme={null}
npm install -g @aisa-one/cli
aisa skills install trend-forecast
```

安装完成后请启动新的智能体会话，以加载该 Skill。

## 智能体能用它做什么？

> [card] 趋势简报
>
> 将混合信号转化为简明的趋势预测。

> [card] 预测市场信号
>
> 利用 Polymarket 和 Kalshi 的赔率作为概率依据。

> [card] 社交情绪
>
> 读取 X/Twitter 上围绕话题、实体和叙事的动态。

> [card] 市场背景
>
> 在相关时补充股票、加密货币和宏观经济背景。

## 上下文

你是一个趋势预测智能体。当用户询问某个话题的走向、前景或概率时，你通过 AIsa 的统一 API 从五个独立数据源收集信号，然后综合生成带置信度评分的预测。

这个 Skill 不是网络搜索工具。它是一个**多信号聚合引擎**，从预测市场、社交媒体、新闻和金融市场拉取结构化数据，再使用 LLM 综合生成趋势报告。

所有端点共用同一个认证 Header：`Authorization: Bearer $AISA_API_KEY`。REST 接口位于 `https://api.aisa.one/apis/v1`；OpenAI 兼容的 LLM 网关位于 `https://api.aisa.one/v1`（注意：没有 `/apis`）。

## 示例提示词

* “未来 6 个月 AI 芯片市场的前景如何？”
* “美联储会在 9 月之前降息吗？”
* “根据当前情绪预测特斯拉股票的趋势”
* “预测市场对 2026 年中期选举怎么看？”
* “远程办公普及的趋势分析——结合社交、新闻和市场数据”

## 环境变量

```bash theme={null}
export AISA_API_KEY="your-aisa-api-key"
```

## 架构

```
┌─────────────────────────────────────────────────────────┐
│                    USER QUERY                           │
│          "What's the outlook on X?"                     │
└──────────────────────┬──────────────────────────────────┘
                       │
                       ▼
┌─────────────────────────────────────────────────────────┐
│              QUERY DECOMPOSITION (LLM)                  │
│  Break topic into search terms per data source          │
└──────────────────────┬──────────────────────────────────┘
                       │
          ┌────────────┼────────────┬────────────┐
          ▼            ▼            ▼            ▼
    ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
    │Prediction│ │ Twitter  │ │  News    │ │  Stock   │
    │ Markets  │ │Sentiment │ │ Velocity │ │  Data    │
    │ (odds)   │ │ (volume) │ │ (tavily) │ │(financial)│
    └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘
         │            │            │             │
         └────────────┴─────┬──────┴─────────────┘
                            ▼
┌─────────────────────────────────────────────────────────┐
│              SIGNAL SYNTHESIS (LLM)                     │
│  Weigh signals, detect agreement/conflict,              │
│  produce confidence score (0-100) + forecast            │
└─────────────────────────────────────────────────────────┘
```

## 工作流程

按以下步骤依次执行。每一步都调用特定的 AIsa API 端点。

### 第 1 步：分解查询

使用 AIsa LLM 网关将用户查询拆解为各数据源的搜索词。

```bash theme={null}
curl -X POST "https://api.aisa.one/v1/chat/completions" \
  -H "Authorization: Bearer $AISA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4.1-mini",
    "messages": [
      {
        "role": "system",
        "content": "You decompose a user query into search terms for 4 data sources. Respond ONLY with JSON: {\"prediction_market_query\": \"...\", \"twitter_query\": \"...\", \"news_query\": \"...\", \"stock_symbols\": [\"...\"], \"topic_summary\": \"...\"}. stock_symbols must be real tickers (AAPL, NVDA, TLT) — never institution abbreviations like FED/SEC/FDA."
      },
      {"role": "user", "content": "<USER_QUERY>"}
    ],
    "temperature": 0.2
  }'
```

### 第 2 步：收集预测市场信号

使用已挂载的预测市场发现端点收集市场上下文。AIsa 目前提供 Polymarket 的市场/事件发现和 Kalshi 的市场/交易接口；当预测需要可执行赔率时，请使用各平台原生 API 或交易系统获取当前价格和订单簿。

```bash theme={null}
# Polymarket markets
curl "https://api.aisa.one/apis/v1/polymarket/markets?limit=5" \
  -H "Authorization: Bearer $AISA_API_KEY"

# Polymarket events
curl "https://api.aisa.one/apis/v1/polymarket/events?limit=5" \
  -H "Authorization: Bearer $AISA_API_KEY"
```

Kalshi 端点：

```bash theme={null}
curl "https://api.aisa.one/apis/v1/kalshi/markets?limit=5&status=open" \
  -H "Authorization: Bearer $AISA_API_KEY"

curl "https://api.aisa.one/apis/v1/kalshi/trades?limit=5&is_block_trade=false" \
  -H "Authorization: Bearer $AISA_API_KEY"
```

提取：市场标题、状态、成交量/流动性字段、截止时间和近期交易上下文。

### 第 3 步：收集 Twitter/X 社交情绪

搜索 Twitter 上的近期讨论量和情绪信号。推文搜索端点为 `/twitter/tweet/advanced_search`，参数包括 `query` 和 `queryType`（`Latest` 或 `Top`）。

```bash theme={null}
curl "https://api.aisa.one/apis/v1/twitter/tweet/advanced_search?query=<TWITTER_QUERY>&queryType=Latest" \
  -H "Authorization: Bearer $AISA_API_KEY"
```

提取：推文数量、互动指标（点赞、转发、回复）、讨论该话题的知名账号，以及整体情绪基调。

### 第 4 步：收集新闻信号

使用 AIsa 的 Tavily 中继搜索该话题的近期新闻。

```bash theme={null}
curl -X POST "https://api.aisa.one/apis/v1/tavily/search" \
  -H "Authorization: Bearer $AISA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "<NEWS_QUERY>",
    "search_depth": "advanced",
    "max_results": 10,
    "topic": "news",
    "days": 7
  }'
```

提取：文章数量、来源多样性、标题情绪、发布速度（文章数量在加速还是减速？）。

### 第 5 步：收集股票/市场信号（如适用）

如果话题涉及上市公司、行业板块或金融工具，请查询 AIsa 的 MarketPulse `/financial/` 端点。每个 ticker 拉取三类信号：

```bash theme={null}
# Historical prices (interval is required: day, week, month, etc.)
curl "https://api.aisa.one/apis/v1/financial/prices?ticker=<STOCK_SYMBOL>&interval=day" \
  -H "Authorization: Bearer $AISA_API_KEY"

# Real-time financial metrics snapshot
curl "https://api.aisa.one/apis/v1/financial/financial-metrics/snapshot?ticker=<STOCK_SYMBOL>" \
  -H "Authorization: Bearer $AISA_API_KEY"

# Company news
curl "https://api.aisa.one/apis/v1/financial/news?ticker=<STOCK_SYMBOL>" \
  -H "Authorization: Bearer $AISA_API_KEY"
```

提取：近期价格走势（1 天、5 天、30 天）、估值/盈利指标和标题情绪。若需更深入的信号，可补充 `/financial/analyst-estimates`、`/financial/insider-trades`，或宏观端点 `/financial/macro/interest-rates/snapshot`。

只使用真实的 ticker 符号（AAPL、NVDA、TLT）——绝不要将机构缩写（FED、SEC、FDA）传入 `/financial/` 端点，否则会失败。如果没有相关的股票符号，跳过此步骤并注明 “N/A — non-financial topic”。

### 第 6 步：综合预测

将所有收集到的信号传入 AIsa LLM 网关进行综合分析。

```bash theme={null}
curl -X POST "https://api.aisa.one/v1/chat/completions" \
  -H "Authorization: Bearer $AISA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4.1-mini",
    "messages": [
      {
        "role": "system",
        "content": "You are a trend analyst. Given structured signals from prediction markets, Twitter, news, and stock data, produce a forecast. Output JSON: {\"trend_direction\": \"bullish|bearish|neutral|mixed\", \"confidence_score\": 0-100, \"time_horizon\": \"...\", \"headline\": \"...\", \"analysis\": \"...\", \"signal_agreement\": \"high|medium|low\", \"key_signals\": [...], \"risks\": [...], \"data_gaps\": [...]}"
      },
      {
        "role": "user",
        "content": "TOPIC: <TOPIC_SUMMARY>\n\nPREDICTION MARKETS:\n<PM_DATA>\n\nTWITTER SENTIMENT:\n<TWITTER_DATA>\n\nNEWS VELOCITY:\n<NEWS_DATA>\n\nMARKET DATA:\n<STOCK_DATA>"
      }
    ],
    "temperature": 0.3
  }'
```

### 第 7 步：格式化并交付

以如下格式向用户展示预测结果：

```
📈 TREND FORECAST: <headline>

Direction: <trend_direction>
Confidence: <confidence_score>/100
Signal Agreement: <signal_agreement>
Time Horizon: <time_horizon>

ANALYSIS:
<analysis paragraph>

KEY SIGNALS:
- <signal 1>
- <signal 2>
- <signal 3>

RISKS & CAVEATS:
- <risk 1>
- <risk 2>

DATA GAPS:
- <any sources that returned no data>
```

## 规则

* 在综合之前**必须**调用至少 3 个数据源（共 4 个）。如果预测基于不足 3 个数据源，必须包含醒目的 “LOW CONFIDENCE — limited data sources” 警告。
* **绝不要**将预测市场赔率当作确定事实。始终表述为“预测市场目前将 X 定价为 Y%”，而非“X 会发生”。
* **绝不要**提供理财建议。所有输出都应定位为信息性分析，而非投资建议。涉及股票数据时须附加免责声明。
* 股票信号只使用真实 ticker 符号。绝不要将机构缩写（FED、SEC、FDA）传入 `/financial/` 端点——它们会失败。
* 如果 AISA\_API\_KEY 未设置，请提示用户设置，并提供 [https://aisa.one](https://aisa.one) 的链接以创建账号。
* 如果任何 API 调用失败，记录错误，继续使用剩余数据源，并在最终输出中注明缺口。

## 自动化

如需定期预测，可使用 Python 脚本：

```bash theme={null}
python3 scripts/trend_forecast.py "Will the Fed cut rates in 2026?" --output json
python3 scripts/trend_forecast.py "Tesla outlook" --output markdown --save report.md
python3 scripts/trend_forecast.py "Bitcoin outlook" --model gpt-5.4
```

完整实现参见 `scripts/trend_forecast.py`，完整的 AIsa 端点文档参见 `references/api_endpoints.md`。

## 开始使用

1. 在 [aisa.one](https://aisa.one) 注册并在控制台中创建 API key。
2. 在 shell 中设置：`export AISA_API_KEY="your-key"`。
3. 使用[安装](#安装)部分的命令安装 Skill，然后启动新的智能体会话。

## 相关

> [card] [Prediction Market Data](https://aisa.one/docs/zh/agent-skills/prediction-market-data.md)
>
> 市场赔率、价格和交易历史。

> [card] [Twitter Autopilot](https://aisa.one/docs/zh/agent-skills/twitter-autopilot.md)
>
> X/Twitter 搜索与社交情报。

> [card] [MarketPulse](https://aisa.one/docs/zh/agent-skills/marketpulse.md)
>
> 股票、财报和宏观市场背景。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.