Skip to main content

Python library to retrieve historical and intraday data from Casablanca Stock Exchange via Medias24 API

Project description

casased

casased logo

casased — Casablanca Stock Exchange Data Retriever

A Python library to retrieve historical and intraday data from the Casablanca Stock Exchange (Bourse de Casablanca) using the Medias24 API.

PyPI version License: MIT

Features

  • 📈 Historical Data: Daily OHLCV data for all listed stocks
  • 📊 Index Data: MASI and MSI20 historical data
  • ⏱️ Intraday Data: Real-time intraday prices
  • 🏦 Multiple Assets: Load data for multiple stocks at once
  • 📋 Company Info: Session data, key indicators, dividends
  • 📉 Market Overview: Index summaries and weights

Installation

pip install casased

Quick Start

import casased as cas

# List available assets
assets = cas.notation()

# Get historical data for a stock
df = cas.get_history('BCP', start='2024-01-01', end='2024-12-31')

# Get MASI index history
masi = cas.get_history('MASI')

# Load multiple assets
banks = cas.loadmany(['BCP', 'CIH', 'Attijariwafa'], start='2024-01-01', end='2024-12-31')

# Get intraday data
intraday = cas.get_intraday('BCP')

API Reference

Historical Data

get_history(identifier, start=None, end=None)

Get historical daily data for a stock or index.

# Stock data
df = cas.get_history('Addoha', start='2024-01-01', end='2024-06-30')

# Index data
masi = cas.get_history('MASI')
msi20 = cas.get_history('MSI20')

Returns: DataFrame with columns: Value, Min, Max, Variation, Volume

loadmany(*assets, start=None, end=None, feature='Value')

Load data for multiple assets.

# Load closing prices
df = cas.loadmany(['BCP', 'CIH', 'BOA'], start='2024-01-01', end='2024-12-31')

# Load volumes
volumes = cas.loadmany(['BCP', 'CIH'], feature='Volume')

Intraday Data

get_intraday(identifier)

Get intraday prices for a stock or index.

# Stock intraday
intraday = cas.get_intraday('BCP')

# Market intraday
market = cas.get_intraday('MASI')

Company Information

getCours(name)

Get session data, latest transactions, and order book.

cours = cas.getCours('BOA')
# Returns: {'Données_Seance', 'Meilleur_limit', 'Dernieres_Tansaction', 'Seance_prec'}

getKeyIndicators(name)

Get company key indicators and financial ratios.

indicators = cas.getKeyIndicators('Attijariwafa')
# Returns: {'Info_Societe', 'Actionnaires', 'Chiffres_cles', 'Ratio'}

getDividend(name)

Get dividend history.

dividends = cas.getDividend('BOA')

Market Overview

getIndex()

Get all index summaries.

index = cas.getIndex()
# Returns: {'Resume indice', 'Indice rentabilite', 'Indices en devises', 'Indice FTSE', 'Indices sectoriels'}

getPond()

Get index weights (pondération).

weights = cas.getPond()

getIndexRecap()

Get session recap with top gainers/losers.

recap = cas.getIndexRecap()

Utilities

notation()

Get list of all available asset names.

assets = cas.notation()

get_isin_by_name(name)

Get ISIN code for an asset.

isin = cas.get_isin_by_name('BCP')  # Returns 'MA0000011884'

Data Sources

Requirements

  • Python 3.7+
  • requests
  • beautifulsoup4
  • pandas
  • lxml

Example Notebook

See casased_exemple.ipynb for a complete demonstration of all features.

Release Notes

  • v0.1.2 — 2026-01-06 — Documentation cleanup, branding updates
  • v0.1.1 — 2026-01-06 — Remove demo videos, update branding
  • v0.1.0 — Initial release

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License — see LICENSE for details.

Contact

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

casased-0.1.4.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

casased-0.1.4-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file casased-0.1.4.tar.gz.

File metadata

  • Download URL: casased-0.1.4.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for casased-0.1.4.tar.gz
Algorithm Hash digest
SHA256 7361db145853613029b8c2e6aad62ad9e0de460f3e375fc06a7814c28d59ffa5
MD5 443774733b457dff26c2caaf327c2de8
BLAKE2b-256 547456acd2ef468148ead004b78fab8871c52d24528073774a2ac78376748d67

See more details on using hashes here.

File details

Details for the file casased-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: casased-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for casased-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 aef52132de61af1529ce49928d63b1dbd3d45af7532818684e5c1f2c84b81180
MD5 bb3f2401b1868e4a4bed2d5091faeeab
BLAKE2b-256 dbbe1c1466f049ec7a92ea1ba45b961f1dfcce55e98485f80edabbed711e29b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page