Metadata-Version: 2.4
Name: metaapi_cloud_metastats_sdk
Version: 6.0.0
Summary: Python SDK for MetaStats forex trading statistics API. Can calculate metrics for MetaTrader accounts added to MetaApi. Supports both MetaTrader 5 (MT5) and MetaTrader 4 (MT4). (https://metaapi.cloud)
Author-email: MetaApi <support@metaapi.cloud>
License: (c) Copyright 2021-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-metastats-python-sdk
Keywords: metaapi.cloud,MetaTrader,MetaTrader 5,MetaTrader 4,MetaTrader5,MetaTrader4,MT,MT4,MT5,forex,API,REST,client,sdk,cloud,metrics,MetaStats,metastats
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: typing-extensions>=4.0.0
Requires-Dist: iso8601
Requires-Dist: pytz
Requires-Dist: httpx<0.29.0,>=0.28.0
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: mock==4.0.3; extra == "test"
Requires-Dist: respx==0.22.0; extra == "test"
Requires-Dist: freezegun==1.0.0; extra == "test"
Dynamic: license-file

MetaStats forex metrics API
###########################
MetaStats is a fast, cost-efficient, easy to use and standards-driven cloud forex trading statistics API supporting
both MetaTrader 4 and MetaTrader 5 platforms designed to boost forex application development process.

Using MetaStats API you can develop applications similar to Myfxbook or MetriX extremely fast, saving time you
otherwise spend for coding, optimizing and testing your own trading metrics calculation engine, since we already
did it for you.

MetaStats API is a member of MetaApi project (`https://metaapi.cloud <https://metaapi.cloud>`_), a powerful cloud forex
trading API which supports both MetaTrader 4 and MetaTrader 5 platforms.

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

MetaStats API features
======================
Features supported:

- support for MetaTrader 4 and MetaTrader 5 platforms
- metrics calculation for MetaTrader accounts added to MetaApi
- optionally include open positions in metrics calculation
- get historical trades for MetaApi account. The historical trades data is updated when you invoke metrics calculation
  endpoint or when set query parameter updateHistory to true
- get open trades for MetaApi account

The features described above are available for use via a professional, fast, easy to use, standards-driven REST API
which can be easily consumed from any programming language.

The primary intended use of MetaStats API is creating trade monitoring applications.

Pricing
=======
MetaStats is available to all MetaApi users without extra charges at this point.

You pay a fee executing MetaTrader terminal on MetaApi cloud. See
`https://metaapi.cloud/#pricing <https://metaapi.cloud/#pricing>`_ for more details.
In some cases a free tier access can be available.

Frequently asked questions (FAQ)
================================
FAQ is located here: `http://metaapi.cloud/docs/metastats/faq/ <http://metaapi.cloud/docs/metastats/faq/>`_

REST API documentation
======================
MetaStats SDK is built on top of MetaStats REST API.

MetaStats REST API docs are available at
`https://metaapi.cloud/docs/metastats/ <https://metaapi.cloud/docs/metastats/>`_

Code examples
=============
We published some code examples in our github repository, namely:

- Python: `https://github.com/metaapi/metaapi-metastats-python-sdk/tree/master/examples <https://github.com/metaapi/metaapi-metastats-python-sdk/tree/master/>`_

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

    pip install metaapi-cloud-sdk

Retrieving API token
====================
Please visit `https://app.metaapi.cloud/token <https://app.metaapi.cloud/token>`_ web UI to obtain your API token.

Configuring trading statistics
==============================
.. code-block:: python

    from metaapi_cloud_sdk import MetaStats

    token = '...'
    api = MetaStats(token=token)

See in-code documentation for full definition of possible configuration options.

Retrieving trading statistics
=============================
.. code-block:: python

    account_id = '...'  #  MetaApi account id

    # retrieve MetaApi MetaTrader account statistics
    print(await metaStats.get_metrics(account_id=account_id))

    # retrieve MetaApi MetaTrader account statistics including open positions
    print(await metaStats.get_metrics(account_id=account_id, include_open_positions=True))

    # retrieve MetaApi MetaTrader account trades
    print(await metaStats.get_account_trades(account_id=account_id, start_time='2020-01-01 00:00:00.000',
                                             end_time='2021-01-01 00:00:00.000'))

    # retrieve MetaApi MetaTrader account open trades
    print(await metaStats.get_account_open_trades(account_id=account_id))

    # reset MetaApi MetaTrader account metrics
    print(await metaStats.reset_metrics(account_id=account_id))

Quotas and rate limits
======================
API calls you make are subject to rate limits. See `https://metaapi.cloud/docs/metastats/rateLimiting/ <https://metaapi.cloud/docs/metastats/rateLimiting/>`_ for more details.

Related projects:
=================
See our website for the full list of APIs and features supported `https://metaapi.cloud/#features <https://metaapi.cloud/#features>`_

Some of the APIs you might decide to use together with this module:

1. MetaApi cloud forex trading API `https://metaapi.cloud/docs/client/ <https://metaapi.cloud/docs/client/>`_
2. CopyFactory copy trading  API `https://metaapi.cloud/docs/copyfactory/ <https://metaapi.cloud/docs/copyfactory/>`_
3. MetaTrader account management API `https://metaapi.cloud/docs/provisioning/ <https://metaapi.cloud/docs/provisioning/>`_
4. MetaApi MT manager API `https://metaapi.cloud/docs/manager/ <https://metaapi.cloud/docs/manager/>`_
5. MetaApi risk management API `https://metaapi.cloud/docs/risk-management/ <https://metaapi.cloud/docs/risk-management/>`_
