MetaTrader5 Python API: official NumPy dtype/schema for rates and ticks

Hello,

I need clarification about the official, version-specific Python/NumPy representation contract of the MetaTrader5 Python package.

Could MetaQuotes please confirm whether this exact combination is officially supported?

MetaTrader5 Python package: 5.0.6231
Platform: Windows AMD64 (win_amd64)
CPython: 3.13.14 / cp313
NumPy: 2.5.3
Wheel: metatrader5-5.0.6231-cp313-cp313-win_amd64.whl

If this exact combination is not supported, please provide one exact currently supported MetaTrader5 / Windows / CPython / NumPy combination instead.

For a supported combination, I need the normative representation specification for the rates and ticks returned by the official MetaTrader5 Python API.

For rates, could you please confirm:

  1. Exact container type, rank and shape, including empty, single-row and multiple-row results.

  2. Complete field names and their order.

  3. Exact dtype kind and bit/byte width of every field.

  4. Integer signedness and byte order.

  5. Field offsets, total itemsize, alignment, padding and applicable stride/contiguity guarantees.

  6. Whether object-containing, nested, subarray or variable-size fields can occur.

  7. Exact Python/NumPy scalar class returned when each field is indexed.

For ticks, could you please confirm:

  1. Exact container and row representation.

  2. Complete field names and order.

  3. Exact dtype kind, width and signedness for every field.

  4. Exact Python/NumPy scalar classes returned when fields are indexed.

  5. Byte order, offsets, itemsize, alignment and padding where applicable.

  6. Any officially supported alternative representations.

For time fields, could you please confirm the normative semantics of:

  • rate time

  • tick time

  • tick time_msc

Specifically: epoch, UTC semantics, units, precision, supported range, zero/missing/sentinel behavior, and the required consistency relationship between seconds and milliseconds.

I would also like to know whether missing, additional or reordered fields, different shapes, or different scalar representations can ever be returned for a supported version combination, and how such variants are distinguished.

I am specifically asking about the guaranteed Python binding representation, not example output or only the native MQL5 MqlRates structure.

If these details are already specified in official version-specific documentation or inspectable MetaQuotes binding source code, a link to the exact specification/source would be ideal.

No account investigation, terminal initialization or market-data collection is required for this question. I only need the documented Python binding contract.

Thank you.

Moh.shokouhi:
I need clarification about the official, version-specific Python/NumPy representation contract of the MetaTrader5 Python package.

Caution: Brave browser AI reply...

Prompt

mt5 numpy python requirements

Response

To integrate **MetaTrader 5** with **Python**, you must use **Python 3.6 to 3.12** (specifically the **64-bit** version) and strictly manage the **NumPy** dependency.


**Python Version Requirements**

*   **Supported Range**: The official `metatrader5` package supports **Python 3.6 through 3.12**.

*   **Architecture**: You must use the **64-bit** version of Python; the 32-bit version is not supported.

*   **Installation Command**:

    ```bash

    pip install MetaTrader5

    ```


**NumPy Compatibility Constraints**

*   **Critical Conflict**: The `MetaTrader5` package is compiled against **NumPy 1.x**. It is **incompatible** with **NumPy 2.x**.

*   **Required Version**: You must install **NumPy 1.26.4** (or any version `< 2.0`) to prevent `ImportError` or runtime crashes.

*   **Installation Command**:

    ```bash

    pip install numpy<2.0

    # Specifically recommended:

    pip install numpy==1.26.4

    ```


**Additional Setup Notes**

*   **MT5 Terminal**: The **MetaTrader 5 desktop terminal** must be installed and **running** on your system before initializing the connection in Python.

*   **Common Libraries**: For data analysis, install **Pandas** and **Matplotlib** alongside NumPy:

    ```bash

    pip install pandas matplotlib

    ```

*   **Connection Initialization**: After installation, initialize the connection in your script using:

    ```python

    import MetaTrader5 as mt5

    if not mt5.initialize():

        print("Error initializing MT5")

    ```

Moh, the Python 3.12 ceiling in reply #1 does not match the current release files. MetaQuotes publishes metatrader5-5.0.6231-cp313-cp313-win_amd64.whl on PyPI:
That establishes an available CPython 3.13 Windows wheel. It does not certify your exact NumPy 2.5.3 combination or a binary layout contract.

The official copy_rates_from page documents a NumPy array, named columns and None on error. It does not specify field offsets, alignment or scalar classes:

The ticks page shows why example output cannot substitute for that contract: its Return Value section names five columns, while its example rows contain eight values:

I cannot confirm the full version combination or the missing layout guarantees from those sources. Your request needs a versioned statement from MetaQuotes covering the Python binding. Neither the native MqlRates structure nor a successful local sample establishes those guarantees.