Metadata-Version: 2.4
Name: metaapi_cloud_sdk
Version: 29.0.0
Summary: SDK for MetaApi, a professional cloud forex API which includes MetaTrader REST API and MetaTrader websocket API. Supports both MetaTrader 5 (MT5) and MetaTrader 4 (MT4). CopyFactory copy trading API included. (https://metaapi.cloud)
Author-email: MetaApi <support@metaapi.cloud>
License: (c) Copyright 2020-2023 MetaApi DMCC. All rights reserved
        
        See https://metaapi.cloud/terms for the license.
        
        The client library is provided as an open-source project to all metaapi.cloud
        users or developers free of charge provided you use it in order to implement
        applications which use metaapi.cloud API service.
        
        Provided the above condition is met and if needed by your project you can
        create derivative works from this code. However we strongly recommend you to
        create issues in our github repository instead, so that we can integrate the
        features you need into this project.
        
        The use of this code in competing projects or for implementing products which
        are not using metaapi.cloud API service is permitted only if you have a written
        approval from the MetaApi project owners.
        
Project-URL: Homepage, https://github.com/metaapi/metaapi-python-sdk
Keywords: metaapi.cloud,MetaTrader,MetaTrader 5,MetaTrader 4,MetaTrader5,MetaTrader4,MT,MT4,MT5,forex,trading,API,REST,websocket,client,sdk,cloud,free,copy trading,copytrade,copy trade,trade copying
Classifier: Programming Language :: Python :: 3
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: aiohttp>=3.7.4
Requires-Dist: python-engineio<4.0.0,>=3.14.2
Requires-Dist: typing-extensions>=4.0.0
Requires-Dist: iso8601
Requires-Dist: pytz
Requires-Dist: python-socketio[asyncio_client]<5.0.0,>=4.6.0
Requires-Dist: requests>=2.28.0
Requires-Dist: httpx<0.29.0,>=0.28.0
Requires-Dist: metaapi-cloud-copyfactory-sdk<13.0.0,>=12.0.0
Requires-Dist: metaapi-cloud-metastats-sdk<7.0.0,>=6.0.0
Requires-Dist: rapidfuzz
Provides-Extra: test
Requires-Dist: pytest==6.2.5; extra == "test"
Requires-Dist: pytest-mock==3.8.2; extra == "test"
Requires-Dist: pytest-asyncio==0.16.0; extra == "test"
Requires-Dist: asynctest==0.13.0; extra == "test"
Requires-Dist: mock==4.0.3; extra == "test"
Requires-Dist: freezegun==1.0.0; extra == "test"
Requires-Dist: respx==0.22.0; extra == "test"
Dynamic: license-file

metaapi.cloud SDK for Python
############################

MetaApi is a powerful, fast, cost-efficient, easy to use and standards-driven cloud forex trading API for MetaTrader 4 and MetaTrader 5 platform designed for traders, investors and forex application developers to boost forex application development process. MetaApi can be used with any broker and does not require you to be a brokerage.

CopyFactory is a simple yet powerful copy-trading API which is a part of MetaApi. See below for CopyFactory readme section.

MetaApi is a paid service, however we may offer a free tier access in some cases.

The `MetaApi pricing <https://metaapi.cloud/#pricing>`_ was developed with the intent to make your charges less or equal to what you would have to pay
for hosting your own infrastructure. This is possible because over time we managed to heavily optimize
our MetaTrader infrastructure. And with MetaApi you can save significantly on application development and
maintenance costs and time thanks to high-quality API, open-source SDKs and convenience of a cloud service.

Official REST and websocket API documentation: https://metaapi.cloud/docs/client/

This SDK requires a 3.8+ version of Python to run.

Please note that this SDK provides an abstraction over REST and websocket API to simplify your application logic.

For more information about SDK APIs please check docstring documentation in source codes located inside lib folder of this package.

Working code examples
=====================
Please check `this short video <https://youtu.be/LIqFOOOLP-g>`_ to see how you can download samples via our web application.

You can find code examples at `examples folder of our github repo <https://github.com/metaapi/metaapi-python-sdk/tree/master/examples>`_ or in the examples folder of the pip package.

We have composed a `short guide explaining how to use the example code <https://metaapi.cloud/docs/client/usingCodeExamples/>`_

Installation
============
.. code-block:: bash

    pip install metaapi-cloud-sdk

Connecting to MetaApi
=====================
Please use one of these ways:

1. https://app.metaapi.cloud/token web UI to obtain your API token.
2. An account access token which grants access to a single account. See section below on instructions on how to retrieve account access token.

Supply token to the MetaApi class constructor.

.. code-block:: python

    from metaapi_cloud_sdk import MetaApi

    token = '...'
    api = MetaApi(token=token)

Retrieving account access token
===============================
Account access token grants access to a single account. You can retrieve account access token via API:

.. code-block:: python

    account_id = '...'
    validity_in_hours = 24
    account_access_token = await api.token_management_api.narrow_down_token(
        {
            'applications': ['trading-account-management-api', 'copyfactory-api', 'metaapi-rest-api', 'metaapi-rpc-api', 'metaapi-real-time-streaming-api', 'metastats-api', 'risk-management-api'],
            'roles': ['reader'],
            'resources': [{'entity': 'account', 'id': account_id}]

        },
        validity_in_hours
    )
    print(account_access_token)

Alternatively, you can retrieve account access token via web UI on https://app.metaapi.cloud/accounts page (see `this video <https://youtu.be/PKYiDns6_xI>`_).

Table of contents
=================

1. `MT account management <https://github.com/metaapi/metaapi-python-sdk/blob/master/docs/metaApi/managingAccounts.rst>`_

2. `MetaApi RPC API <https://github.com/metaapi/metaapi-python-sdk/blob/master/docs/metaApi/rpcApi.rst>`_

3. `MetaApi real-time streaming API (websocket API) <https://github.com/metaapi/metaapi-python-sdk/blob/master/docs/metaApi/streamingApi.rst>`_

4. `Risk management API <https://github.com/metaapi/metaapi-python-sdk/blob/master/docs/riskManagement.rst>`_

5. `CopyFactory copy trading API <https://github.com/metaapi/metaapi-python-sdk/blob/master/docs/copyTrading.rst>`_

6. `MetaStats trading statistics API <https://github.com/metaapi/metaapi-python-sdk/blob/master/docs/metaStats.rst>`_

7. `MetaApi MT manager API <https://github.com/metaapi/metaapi-python-sdk/blob/master/docs/managerApi.rst>`_

8. `Tracking latencies <https://github.com/metaapi/metaapi-python-sdk/blob/master/docs/trackingLatencies.rst>`_

9. `Enable log4js logging <https://github.com/metaapi/metaapi-python-sdk/blob/master/docs/logging.rst>`_

10. `Rate limits & quotas <https://github.com/metaapi/metaapi-python-sdk/blob/master/docs/rateLimits.rst>`_

11. `Token management API <https://github.com/metaapi/metaapi-python-sdk/blob/master/docs/tokenManagementApi.rst>`_
