# Financial Seasonality Data (`khnaami/seasonality-actor`) Actor

- Integrated multi-source market data engine Yahoo Finance, Stooq 100Y, and FRED direct macro scraper without API key

- Implemented multi-period cumulative seasonal trajectories 5Y, 10Y, 15Y, 20Y, All-time

- Added monthly return matrix Day-of-Week win rates and quarterly probability distributions.

- **URL**: https://apify.com/khnaami/seasonality-actor.md

- **Developed by:** [khalid naami](https://apify.com/khnaami) (community)

- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks

- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Financial Seasonality & Multi-Asset Probability Analytics Actor 📈

Analyze **historical seasonal trajectories**, **calendar win rates**, **day-of-week probabilities**, and **quarterly performance metrics** across Stocks, ETFs, Forex pairs, Cryptocurrencies, Commodities, and Federal Reserve (FRED) macroeconomic series.

Built for **algorithmic traders**, **quantitative researchers**, **portfolio managers**, and **AI Agents (MCP & LLMs)** seeking pre-calculated market biases.

***

### 🌟 Key Features

- **Multi-Asset Coverage**: Analyzes US Equities (`AAPL`, `NVDA`), ETFs (`SPY`, `QQQ`), Commodities (`GC=F` Gold, `CL=F` Crude Oil, `SI=F` Silver), Forex (`EURUSD`, `GBPUSD`, `USDJPY`), Crypto (`BTC-USD`, `ETH-USD`), and Macro (`CPI`, `FEDFUNDS`, `US10Y`).
- **Triple Data Source Engine**:
  - **Yahoo Finance**: Real-time global market data.
  - **Stooq**: Direct CSV scraper with up to **100+ years of historical data** (e.g. S\&P 500, Gold, Dow Jones) without requiring any API keys.
  - **FRED (Federal Reserve)**: Direct scraper for central bank interest rates, inflation, and macro indicators without API keys.
- **Multi-Period Seasonal Trajectories**: Pre-calculated day-by-day cumulative curves for **5-Year**, **10-Year**, **15-Year**, **20-Year**, and **All-Time** historical benchmarks.
- **Calendar & Probability Matrix**:
  - **Monthly Analysis**: Month-by-month win rate (%), mean return, median, max/min, volatility, and positive/negative year counts.
  - **Day-of-Week Probabilities**: Monday through Friday closing probability and average returns.
  - **Quarterly Breakdown**: Q1, Q2, Q3, and Q4 performance distributions.
  - **Full Monthly Matrix**: Complete historical Year x Month returns table.
- **AI Agent & MCP Ready**: Generates an executive market summary with bias classifications (`BULLISH` / `BEARISH`) and current month historical outlooks ready for LLMs, Claude, ChatGPT, and LangChain.

***

### 📥 Input Configuration

| Parameter | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `symbols` | `Array<string>` | `["SPY", "GC=F", "BTC-USD", "EURUSD=X"]` | List of tickers or symbols to analyze. |
| `dataProvider` | `String` | `"auto"` | Choose `"auto"` (longest history wins), `"yahoo"`, `"stooq"`, or `"fred"`. |
| `yearsBack` | `Integer` | `0` | Number of years to analyze (`0` for all available history). |
| `seasonalPeriods` | `Array<number>` | `[5, 10, 15, 20]` | Lookback periods for cumulative seasonal curves. |
| `includeMonthlyMatrix`| `Boolean` | `true` | Include the full Year x Month return matrix. |
| `includeProbabilities` | `Boolean` | `true` | Include Day-of-Week and Quarterly win rates. |
| `includeDailyCurves` | `Boolean` | `true` | Include daily normalized cumulative seasonal trajectories. |

#### Example Input (`input.json`):

```json
{
  "symbols": ["SPY", "GC=F", "BTC-USD", "EURUSD=X", "CPI"],
  "dataProvider": "auto",
  "yearsBack": 0,
  "seasonalPeriods": [5, 10, 20],
  "includeMonthlyMatrix": true,
  "includeProbabilities": true,
  "includeDailyCurves": true
}
```

***

### 📤 Output Dataset Format

Each dataset record contains comprehensive statistics and AI insights:

```json
{
  "symbol": "SPY",
  "name": "SPDR S&P 500 ETF",
  "assetType": "ETF",
  "dataProvider": "Stooq",
  "tickerUsed": "SPY.US",
  "yearsAnalyzed": 31,
  "historyRange": "1994 - 2025",
  "latestPrice": 580.45,
  "lastUpdated": "2026-09-26",
  "aiInsights": {
    "overallBias": "BULLISH",
    "bestMonthHistorical": {
      "month": "Nov",
      "avgReturnPct": 2.45,
      "winRatePct": 80.6
    },
    "worstMonthHistorical": {
      "month": "Sep",
      "avgReturnPct": -0.85,
      "winRatePct": 45.2
    },
    "currentMonthOutlook": {
      "month": "Sep",
      "historicalWinRatePct": 45.2,
      "historicalAvgReturnPct": -0.85,
      "bias": "BEARISH"
    },
    "executiveSummary": "SPY (SPDR S&P 500 ETF) historical seasonality spans 31 years (1994-2025). Strongest calendar month is Nov (+2.45% avg, 80.6% win rate)..."
  },
  "monthlyStatistics": [
    {
      "month": "Jan",
      "monthNumber": 1,
      "winRatePct": 61.3,
      "averageReturnPct": 1.12,
      "medianReturnPct": 1.45,
      "maxReturnPct": 8.05,
      "minReturnPct": -8.57,
      "volatilityPct": 4.12,
      "positiveYears": 19,
      "negativeYears": 12,
      "totalYears": 31
    }
  ],
  "dayOfWeekProbabilities": [
    { "day": "Monday", "winRatePct": 54.2, "averageReturnPct": 0.045 },
    { "day": "Tuesday", "winRatePct": 55.1, "averageReturnPct": 0.062 },
    { "day": "Wednesday", "winRatePct": 56.4, "averageReturnPct": 0.078 },
    { "day": "Thursday", "winRatePct": 53.8, "averageReturnPct": 0.039 },
    { "day": "Friday", "winRatePct": 52.1, "averageReturnPct": 0.028 }
  ],
  "quarterlyStatistics": [
    { "quarter": "Q1", "winRatePct": 67.7, "averageReturnPct": 2.85 },
    { "quarter": "Q2", "winRatePct": 71.0, "averageReturnPct": 3.42 },
    { "quarter": "Q3", "winRatePct": 58.1, "averageReturnPct": 0.95 },
    { "quarter": "Q4", "winRatePct": 80.6, "averageReturnPct": 4.65 }
  ],
  "seasonalTrajectories": {
    "5Y": [0.0, 0.12, 0.35, 0.48],
    "10Y": [0.0, 0.08, 0.22, 0.41],
    "20Y": [0.0, 0.05, 0.18, 0.36],
    "allTime": [0.0, 0.06, 0.19, 0.38]
  }
}
```

***

### 🤖 AI Agent & MCP Integration

Because this Actor outputs clean, pre-calculated probabilities and executive summaries, it is 100% plug-and-play with **Apify Model Context Protocol (MCP)** servers, OpenAI GPTs, Claude Tools, and LangChain/CrewAI agents.

#### Apify Python Client Example:

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_API_TOKEN>")

run_input = {
    "symbols": ["SPY", "GC=F", "EURUSD=X", "BTC-USD"],
    "dataProvider": "auto"
}

run = client.actor("khnaami/financial-seasonality-actor").call(run_input=run_input)

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(f"Symbol: {item['symbol']} | Best Month: {item['aiInsights']['bestMonthHistorical']['month']}")
```

#### Apify JavaScript / TypeScript Client Example:

```typescript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

const run = await client.actor('khnaami/financial-seasonality-actor').call({
    symbols: ['SPY', 'GC=F', 'EURUSD=X'],
    dataProvider: 'auto',
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

***

### ⚖️ Disclaimer

*This Actor provides statistical and historical seasonality metrics for educational and analytical purposes only. It is not financial or investment advice.*

# Actor input Schema

## `symbols` (type: `array`):

List of tickers to analyze (e.g. SPY, QQQ, GC=F, XAUUSD, BTC-USD, EURUSD, CPI, DGS10). Supports Stocks, ETFs, Forex, Commodities, Crypto, and FRED Macro Series.

## `dataProvider` (type: `string`):

Choose preferred market data source. 'auto' automatically selects the source with the longest historical track record.

## `yearsBack` (type: `integer`):

Number of recent historical years to include in the seasonality calculations. Set 0 for the entire available historical dataset.

## `seasonalPeriods` (type: `array`):

Custom lookback periods to calculate average seasonal trajectories (e.g., \[5, 10, 15, 20]).

## `includeMonthlyMatrix` (type: `boolean`):

Whether to return the complete historical monthly return table for each calendar year.

## `includeProbabilities` (type: `boolean`):

Calculate Day-of-the-Week (Mon-Fri) and Quarterly (Q1-Q4) win rates and return distributions.

## `includeDailyCurves` (type: `boolean`):

Return normalized day-by-day average cumulative return curves for multi-period seasonal charting.

## Actor input object example

```json
{
  "symbols": [
    "SPY",
    "GC=F",
    "BTC-USD",
    "EURUSD=X"
  ],
  "dataProvider": "auto",
  "yearsBack": 0,
  "seasonalPeriods": [
    5,
    10,
    15,
    20
  ],
  "includeMonthlyMatrix": true,
  "includeProbabilities": true,
  "includeDailyCurves": true
}
```

# Actor output Schema

## `results` (type: `string`):

Calculated multi-asset seasonality curves, probabilities, and monthly matrices

## `summary` (type: `string`):

Pre-calculated executive market biases, win rates, and summaries

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "symbols": [
        "SPY",
        "GC=F",
        "BTC-USD",
        "EURUSD=X"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("khnaami/seasonality-actor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "symbols": [
        "SPY",
        "GC=F",
        "BTC-USD",
        "EURUSD=X",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("khnaami/seasonality-actor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "symbols": [
    "SPY",
    "GC=F",
    "BTC-USD",
    "EURUSD=X"
  ]
}' |
apify call khnaami/seasonality-actor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,khnaami/seasonality-actor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/CDIfyjteJdTJEphSp/builds/D8ulOSUoyu6kbtF1a/openapi.json
