# Stocks Overview (`pintostudio/stocks-overview`) Actor

This Apify actor fetches stock overview data from Investing.com for a specified country. It retrieves up to 1,000 stock entries with key financial metrics and summarizes market sentiment.

- **URL**: https://apify.com/pintostudio/stocks-overview.md
- **Developed by:** [Pinto Studio](https://apify.com/pintostudio) (community)
- **Categories:** Other, Automation, Developer tools
- **Stats:** 4 total users, 0 monthly users, 80.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$19.99/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period. You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## 📈 Stocks Overview Data (Investing.com) – Apify Actor Documentation

This Apify actor fetches stock overview data from [Investing.com](https://www.investing.com) for a specified country. It retrieves up to 1,000 stock entries with key financial metrics and summarizes market sentiment.

***

### 📌 Overview

The **Stocks Overview Data (Investing.com)** actor retrieves structured financial data for publicly traded companies based on country selection. The actor supports advanced filtering, data enrichment, and result summarization.

Typical use cases include:

- Daily stock performance snapshots
- Investment insights by region
- Real-time reporting dashboards
- Quantitative analysis pipelines

***

### ✅ Output Format

The actor pushes each stock record to the Apify dataset in the following structure:

```json
{
  "country": "united states",
  "name": "Boeing",
  "symbol": "BA",
  "last": 218.52,
  "high": 220.0,
  "low": 214.72,
  "change": "-0.11",
  "change_percentage": "-0.05%",
  "turnover": 6770000.0,
  "currency": "USD",
  "retrieved_at": "2025-07-09T09:00:18.847563",
  "data_type": "stock_overview"
}
```

Additionally, a summary object is saved under the key `stocks_overview_summary` using `Actor.set_value()`:

```json
{
  "country": "united states",
  "n_results": 100,
  "has_data": true,
  "retrieved_at": "2025-07-09T09:00:18.847563",
  "data_format": "list",
  "total_stocks": 100,
  "currencies": ["USD"],
  "sectors_count": 8,
  "avg_stock_price": 103.55,
  "highest_stock_price": 570.1,
  "lowest_stock_price": 3.2,
  "stocks_with_positive_change": 53,
  "stocks_with_negative_change": 47,
  "market_sentiment": "positive",
  "top_performers": [
    {
      "name": "Company A",
      "symbol": "CMPA",
      "change_percentage": "7.12%"
    },
    ...
  ]
}
```

***

### 📥 How It Works

1. **Input Retrieval**: Accepts a country and optional `nResults` (max 1000).
2. **Validation**: Checks that input types and values are valid.
3. **Data Fetching**: Calls `get_stocks_overview()` to retrieve data.
4. **Data Storage**: Stores each record in the dataset.
5. **Summary Generation**: Calculates:

   - Number of stocks
   - Average, highest, and lowest stock prices
   - Count of stocks with price increase/decrease
   - Market sentiment analysis
   - Top 5 performing stocks
6. **Error Handling**: Captures and logs detailed error types (`ValueError`, `IOError`, etc.) with metadata.

***

### 🧠 Key Features

- Supports **48 countries**
- Customizable result count (1–1000)
- Adds enhanced metadata for each entry
- Provides real-time summary and market insight
- Fully async for optimal performance
- Robust error handling and logging

***

### ⚠️ Error Handling

If any error occurs, a record with `data_type: "error"` is pushed, including:

```json
{
  "country": "france",
  "n_results": 100,
  "error_type": "ConnectionError",
  "error_message": "Connection timed out",
  "retrieved_at": "2025-07-09T09:00:18.847563",
  "data_type": "error"
}
```

In addition, `Actor.fail()` is called to mark the run as failed.

***

### 🧪 Example Input

```json
{
  "country": "united states",
  "nResults": 50
}
```

### 📤 Example Output (single record)

```json
{
  "country": "united states",
  "name": "Apple Inc.",
  "symbol": "AAPL",
  "last": 192.64,
  "high": 195.0,
  "low": 190.5,
  "change": "+1.24",
  "change_percentage": "+0.65%",
  "turnover": 98000000,
  "currency": "USD",
  "retrieved_at": "2025-07-09T09:00:18.847563",
  "data_type": "stock_overview"
}
```

***

### 🚀 Deployment

This actor is deployed on the [Apify platform](https://apify.com). You can run it via:

- **Apify Console UI**
- **API call**
- **Schedule (cron-like)**

***

### 🧼 Output Keys

| Field                         | Description                            |
| ----------------------------- | -------------------------------------- |
| `name`                        | Company name                           |
| `symbol`                      | Ticker symbol                          |
| `last`                        | Last traded price                      |
| `high`, `low`                 | Daily high and low prices              |
| `change`, `change_percentage` | Price change and percent delta         |
| `turnover`                    | Trade volume                           |
| `currency`                    | Currency code (e.g., USD, EUR)         |
| `retrieved_at`                | ISO timestamp when data was fetched    |
| `data_type`                   | Either `"stock_overview"` or `"error"` |

***

### Support

If you have any questions or encounter any issues, please consult the Apify documentation or reach out to us through one of the following channels:

- Verify input parameters match the schema requirements
- Check the Apify platform documentation
- Review the actor logs for detailed error messages

* **Telegram**: [@pintoflow](https://t.me/pintoflow)
* **Apify Platform**: You can also contact us directly through this platform.

***

# Actor input Schema

## `country` (type: `string`):

The country where the stock is listed

## `nResults` (type: `integer`):

Number of stocks to retrieve in the overview (1-1000). Default is 100 for the top stocks.

## Actor input object example

```json
{
  "country": "united states",
  "nResults": 100
}
```

# 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 = {
    "nResults": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("pintostudio/stocks-overview").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 = { "nResults": 100 }

# Run the Actor and wait for it to finish
run = client.actor("pintostudio/stocks-overview").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 '{
  "nResults": 100
}' |
apify call pintostudio/stocks-overview --silent --output-dataset

```

## MCP server setup

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

```

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/WcDSsluGUmV411lde/builds/r6Qf3nFO61U2FdXq9/openapi.json
