Note: The Java SDK was updated long time ago and lacks important bugfixes and updates. We plan to update the java SDK soon. Meanwhile we recommend you to use javascript or python SDK instead.
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), a powerful cloud forex trading API which supports both MetaTrader 4 and MetaTrader 5 platforms.
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
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.
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 for more details.
MetaApi provides a free tier so that you can test our APIs without any charges.
FAQ is located here: http://metaapi.cloud/docs/metastats/faq/
MetaStats SDK is built on top of MetaStats REST API.
MetaStats REST API docs are available at https://metaapi.cloud/docs/metastats/
We published some code examples in our github repository, namely:
If you use Apache Maven, add this to <dependencies>
in your pom.xml
:
<dependency>
<groupId>cloud.metaapi.sdk</groupId>
<artifactId>metaapi-java-sdk</artifactId>
<version>14.0.0</version>
</dependency>
Other options can be found on this page.
In order to run the examples, follow these steps:
- Make sure that you have installed Maven and its command
mvn
is accessible. - Navigate to the root folder of the example project (where its
pom.xml
is located). - Build the project with
mvn package
. - Run
mvn exec:java@
ExampleClassName
whereExampleClassName
is the example to execute, e.g.mvn exec:java@MetaStatsExample
.
Example parameters such as token or account id can be passed via environment variables, or set directly in the example source code. In the last case you need to rebuild the example with mvn package
.
Please visit https://app.metaapi.cloud/token web UI to obtain your API token.
import cloud.metaapi.sdk.MetaStats;
String token = "...";
MetaStats metaStats = new MetaStats(token);
See javadoc in-code documentation for full definition of possible configuration options.
String accountId = "..."; // MetaApi account id
// retrieve MetaApi MetaTrader account statistics
System.out.println(metaStats.getMetrics(accountId).join());
// retrieve MetaApi MetaTrader account statistics including open positions
System.out.println(metaStats.getMetrics(accountId, true).join());
API calls you make are subject to rate limits. See https://metaapi.cloud/docs/metastats/rateLimiting/ for more details.
See our website for the full list of APIs and features supported https://metaapi.cloud/#features
Some of the APIs you might decide to use together with this module:
- MetaApi cloud forex trading API https://metaapi.cloud/docs/client/
- CopyFactory copy trading API https://metaapi.cloud/docs/copyfactory/
- MetaTrader account management API https://metaapi.cloud/docs/provisioning/