# morroco-stock-prices-scrapper (`fateful_knuckle/morroco-stock-prices-scrapper`) Actor

Scrapes live and historical stock data for Casablanca-listed companies — prices, OHLCV history, order book, market cap, dividends, financials, shareholders, and analyst recommendations — in one structured dataset item per company.

- **URL**: https://apify.com/fateful\_knuckle/morroco-stock-prices-scrapper.md
- **Developed by:** [Fateful Knuckle](https://apify.com/fateful_knuckle) (community)
- **Categories:** Automation, Agents
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN 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/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

## Moroccan Stock Prices Scraper

**Moroccan Stock Prices Scraper** collects **live and historical stock data for companies listed on the Casablanca Stock Exchange**. For each company it gathers current prices, OHLC data, order books, price history, dividends, analyst recommendations and company financials from two public Moroccan financial sources, and returns a single clean JSON record per company. Try it by simply running it with the default input — no configuration needed.

Running on the Apify platform gives you scheduled runs, API access, monitoring, integrations (Google Sheets, Make, Zapier, and more), and the ability to export data in multiple formats.

### Why use Moroccan Stock Prices Scraper?

- **Build datasets** for portfolio tracking, backtesting, or research on the Moroccan market.
- **Monitor prices** by scheduling daily runs after market close.
- **Cross-check sources** — each company combines data from multiple sources so you can validate prices.
- **Skip the reverse-engineering** — the underlying sites hide data behind SSR endpoints and rendered HTML; this Actor handles all of that for you.

### How to use Moroccan Stock Prices Scraper

1. Open the Actor and go to the **Input** tab.
2. Optionally enter specific **tickers** (e.g. `ATW`, `IAM`, `BCP`). Leave empty to scrape every listed company (~80).
3. Optionally toggle **price history** and adjust concurrency.
4. Click **Start** and wait for the run to finish.
5. Open the **Output** tab to browse results, or download the dataset.

### Input

| Field            | Type    | Description                                             |
| ---------------- | ------- | ------------------------------------------------------- |
| `tickers`        | array   | Ticker symbols to scrape. Empty = all listed companies. |
| `includeHistory` | boolean | Include historical OHLCV price data (default `true`).   |
| `maxConcurrency` | integer | Number of companies scraped in parallel (default `5`).  |

Example input:

```json
{
  "tickers": ["ATW", "IAM", "BCP"],
  "includeHistory": true,
  "maxConcurrency": 5
}
````

### Output

Each dataset item is one company — a single record in a stable, canonical schema. Every item has the same keys (values are `null` when no data is available), all field names are English `snake_case`, all dates are ISO 8601, and all numbers are typed. You can download the dataset in various formats such as JSON, HTML, CSV, or Excel.

```json
{
  "ticker": "ATW",
  "name": "ATTIJARIWAFA BANK",
  "name_ar": "التجاري وفا بنك",
  "name_en": "ATTIJARIWAFA BANK",
  "isin": "MA0000012445",
  "exchange": "Casablanca",
  "sector": "Banques",
  "asset_class": "Principal A",
  "market_group": "Marché Principal",
  "currency": "MAD",
  "quotation_mode": "Continu",
  "illiquid": false,
  "shares_outstanding": 215140839,
  "par_value": 10.0,
  "listing_date": "1992-01-13",
  "listing_price": 220.0,
  "market_cap": 152965136529.0,
  "week_52_high": 725.0,
  "week_52_high_date": "2026-04-22",
  "week_52_low": 498.0,
  "week_52_low_date": "2025-06-30",
  "company": {
    "legal_name": "ATTIJARIWAFA BANK",
    "headquarters": "2, boulevard Moulay Youssef, Casablanca",
    "incorporation_date": "1911-05-31",
    "auditor": "Deloitte Audit",
    "fiscal_year_months": 12,
    "business_purpose": "Établissement de crédit ayant pour objet la collecte de dépôts et la distribution de crédits.",
    "management": [
      { "name": "Mohamed El Kettani", "role": "Président Directeur Général" }
    ]
  },
  "market_data": {
    "last_price": 711.0,
    "previous_close": 703.1,
    "open": 703.0,
    "high": 711.0,
    "low": 703.0,
    "change": 7.9,
    "change_percent": 1.12,
    "change_percent_ytd": 18.5,
    "vwap": 707.4,
    "volume_shares": 33519,
    "volume_value": 23712756.7,
    "market_cap": 152965136529.0,
    "trade_count": 142,
    "last_trade_price": 711.0,
    "last_trade_time": "2026-05-15T15:30:30",
    "best_bid_price": 710.0,
    "best_bid_size": 120,
    "best_ask_price": 712.0,
    "best_ask_size": 85,
    "upper_limit": 773.4,
    "lower_limit": 632.8,
    "theoretical_open_price": 705.0,
    "theoretical_open_percent": 0.27,
    "trading_state": "Cotation en continu",
    "last_transactions": []
  },
  "order_book": {
    "bids": [{ "count": 3, "quantity": 120, "price": 710.0 }],
    "asks": [{ "count": 2, "quantity": 85, "price": 712.0 }]
  },
  "analyst": {
    "recommendation": "Acheter",
    "target_price": 760.0,
    "target_currency": "MAD",
    "recommendation_date": "2026-03-18"
  },
  "price_history": [
    {
      "date": "2026-05-15",
      "open": 687.0,
      "high": 705.0,
      "low": 685.0,
      "close": 703.1,
      "volume_shares": 10302,
      "volume_value": 7165420.0,
      "change": 16.1,
      "change_percent": 2.34
    }
  ],
  "dividends": [
    {
      "year": 2023,
      "type": "Ordinaire",
      "amount_gross": 15.5,
      "amount_net": 13.36,
      "ex_date": "2023-07-03",
      "payment_date": "2023-07-10"
    }
  ],
  "key_figures": [
    {
      "year": 2023,
      "revenue": 29512000000.0,
      "net_income": 8200000000.0,
      "operating_income": 14300000000.0,
      "equity": 62100000000.0,
      "share_capital": 2151408390.0,
      "shares_outstanding": 215140839,
      "consolidated": true
    }
  ],
  "shareholders": {
    "as_of_date": "2025-12-31",
    "holders": [{ "name": "Al Mada", "percentage": 46.5 }]
  },
  "scraped_at": "2026-05-17T10:00:00+00:00",
  "scrape_ok": true
}
```

### Data table

| Field                                          | Description                                                      |
| ---------------------------------------------- | ---------------------------------------------------------------- |
| `ticker`                                       | Casablanca Bourse ticker symbol                                  |
| `name` / `name_ar` / `name_en`                 | Company name (French, Arabic, English)                           |
| `isin`                                         | ISIN code                                                        |
| `sector` / `asset_class` / `market_group`      | Classification                                                   |
| `currency`                                     | Trading currency                                                 |
| `shares_outstanding`                           | Number of listed shares                                          |
| `par_value` / `listing_date` / `listing_price` | Listing details                                                  |
| `market_cap`                                   | Market capitalisation                                            |
| `week_52_high` / `week_52_low`                 | 52-week price range                                              |
| `company`                                      | Issuer info: legal name, headquarters, auditor, management       |
| `market_data`                                  | Live prices, OHLC, volume, VWAP, order-book tops, trading limits |
| `order_book`                                   | Live `bids` and `asks`                                           |
| `price_history`                                | Historical OHLCV records                                         |
| `key_figures`                                  | Yearly revenue, net income, equity                               |
| `dividends`                                    | Dividend history                                                 |
| `shareholders`                                 | Shareholder structure with percentages                           |
| `analyst`                                      | Analyst recommendation and target price                          |
| `scrape_ok`                                    | Whether any data was collected                                   |

### Cost estimation

Both sources are lightweight HTTP requests (2–4 requests per company), so scraping the full list of ~80 companies consumes only a small number of compute units. Disable `includeHistory` for even faster, cheaper runs. The Apify free tier is more than enough for daily runs of the entire market.

### Tips

- **Faster runs:** set `includeHistory` to `false` and raise `maxConcurrency`.
- **Targeted runs:** pass only the `tickers` you care about.
- **Scheduling:** run the Actor after the Casablanca market close (~15:30 local time) to capture end-of-day prices.

### FAQ, disclaimers, and support

**Is scraping this data legal?** This Actor only collects publicly available data from public web pages. It does not bypass authentication or access restricted content. You are responsible for complying with each site's Terms of Service and applicable laws when using the data.

**Why is some data missing?** Both sites occasionally undergo maintenance or backend outages. When a source is unavailable the Actor still returns a record for each company with `scrape_ok` reflecting whether data was obtained. Quotes from public sources may be delayed.

For issues or feature requests, use the **Issues** tab on the Actor page.

# Actor input Schema

## `tickers` (type: `array`):

Casablanca Bourse ticker symbols to scrape (e.g. ATW, IAM, BCP). Leave empty to scrape every listed company.

## `includeHistory` (type: `boolean`):

Include historical OHLCV price data. Disable for faster, lighter runs.

## `maxConcurrency` (type: `integer`):

Maximum number of companies scraped in parallel.

## Actor input object example

```json
{
  "tickers": [
    "ATW",
    "IAM",
    "BCP"
  ],
  "includeHistory": true,
  "maxConcurrency": 5
}
```

# Actor output Schema

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

No description

# 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 = {
    "tickers": [
        "ATW",
        "IAM",
        "BCP"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("fateful_knuckle/morroco-stock-prices-scrapper").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 = { "tickers": [
        "ATW",
        "IAM",
        "BCP",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("fateful_knuckle/morroco-stock-prices-scrapper").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "tickers": [
    "ATW",
    "IAM",
    "BCP"
  ]
}' |
apify call fateful_knuckle/morroco-stock-prices-scrapper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=fateful_knuckle/morroco-stock-prices-scrapper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "morroco-stock-prices-scrapper",
        "description": "Scrapes live and historical stock data for Casablanca-listed companies — prices, OHLCV history, order book, market cap, dividends, financials, shareholders, and analyst recommendations — in one structured dataset item per company.",
        "version": "1.0",
        "x-build-id": "bc0yiNS5waFNRf7CR"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/fateful_knuckle~morroco-stock-prices-scrapper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-fateful_knuckle-morroco-stock-prices-scrapper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/fateful_knuckle~morroco-stock-prices-scrapper/runs": {
            "post": {
                "operationId": "runs-sync-fateful_knuckle-morroco-stock-prices-scrapper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/fateful_knuckle~morroco-stock-prices-scrapper/run-sync": {
            "post": {
                "operationId": "run-sync-fateful_knuckle-morroco-stock-prices-scrapper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "tickers": {
                        "title": "Tickers",
                        "type": "array",
                        "description": "Casablanca Bourse ticker symbols to scrape (e.g. ATW, IAM, BCP). Leave empty to scrape every listed company.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "includeHistory": {
                        "title": "Include price history",
                        "type": "boolean",
                        "description": "Include historical OHLCV price data. Disable for faster, lighter runs.",
                        "default": true
                    },
                    "maxConcurrency": {
                        "title": "Max concurrency",
                        "minimum": 1,
                        "maximum": 20,
                        "type": "integer",
                        "description": "Maximum number of companies scraped in parallel.",
                        "default": 5
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
