Class MetatraderAccount


  • public class MetatraderAccount
    extends Object
    Implements a MetaTrader account entity
    • Constructor Detail

      • MetatraderAccount

        public MetatraderAccount​(MetatraderAccountDto data,
                                 MetatraderAccountClient metatraderAccountClient,
                                 MetaApiWebsocketClient metaApiWebsocketClient,
                                 ConnectionRegistry connectionRegistry)
        Constructs a MetaTrader account entity
        Parameters:
        data - MetaTrader account data
        metatraderAccountClient - MetaTrader account REST API client
        metaApiWebsocketClient - MetaApi websocket client
        connectionRegistry - metatrader account connection registry
    • Method Detail

      • getId

        public String getId()
        Returns account id
        Returns:
        account id
      • getName

        public String getName()
        Returns account name
        Returns:
        account name
      • getType

        public String getType()
        Returns account type. Possible values are cloud and self-hosted.
        Returns:
        account type
      • getLogin

        public String getLogin()
        Returns account login
        Returns:
        account login
      • getServer

        public String getServer()
        Returns MetaTrader server which hosts the account
        Returns:
        MetaTrader server which hosts the account
      • getProvisioningProfileId

        public String getProvisioningProfileId()
        Returns id of the account's provisioning profile
        Returns:
        id of the account's provisioning profile
      • getTimeConverter

        public String getTimeConverter()
        Returns algorithm used to parse your broker timezone. Supported values are icmarkets for America/New_York DST switch and roboforex for EET DST switch (the values will be changed soon)
        Returns:
        algorithm used to parse your broker timezone
      • getApplication

        public String getApplication()
        Returns application name to connect the account to. Currently allowed values are MetaApi and AgiliumTrade
        Returns:
        application name to connect the account to
      • getMagic

        public int getMagic()
        Returns MetaTrader magic to place trades using
        Returns:
        MetaTrader magic to place trades using
      • getAccessToken

        public String getAccessToken()
        Returns authorization access token to be used for accessing single account data. Intended to be used in browser API.
        Returns:
        authorization token
      • isManualTrades

        public boolean isManualTrades()
        Returns flag indicating if trades should be placed as manual trades on this account
        Returns:
        flag indicating if trades should be placed as manual trades on this account
      • reload

        public CompletableFuture<Void> reload()
        Reloads MetaTrader account from API
        Returns:
        completable future resolving when MetaTrader account is updated
      • remove

        public CompletableFuture<Void> remove()
        Removes MetaTrader account. Cloud account transitions to DELETING state. It takes some time for an account to be eventually deleted. Self-hosted account is deleted immediately.
        Returns:
        completable future resolving when account is scheduled for deletion
      • deploy

        public CompletableFuture<Void> deploy()
        Schedules account for deployment. It takes some time for API server to be started and account to reach the DEPLOYED state
      • undeploy

        public CompletableFuture<Void> undeploy()
        Schedules account for undeployment. It takes some time for API server to be stopped and account to reach the UNDEPLOYED state
      • redeploy

        public CompletableFuture<Void> redeploy()
        Schedules account for redeployment. It takes some time for API server to be restarted and account to reach the DEPLOYED state
      • waitDeployed

        public CompletableFuture<Void> waitDeployed​(Integer timeoutInSeconds,
                                                    Integer intervalInMilliseconds)
        Waits until API server has finished deployment and account reached the DEPLOYED state. Completes exceptionally with TimeoutException if account have not reached the DEPLOYED state withing timeout allowed.
        Parameters:
        timeoutInSeconds - optional wait timeout in seconds, default is 5m
        intervalInMilliseconds - optional interval between account reloads while waiting for a change, default is 1s
        Returns:
        completable future which resolves when account is deployed
      • waitUndeployed

        public CompletableFuture<Void> waitUndeployed​(Integer timeoutInSeconds,
                                                      Integer intervalInMilliseconds)
        Waits until API server has finished undeployment and account reached the UNDEPLOYED state. Completes exceptionally with TimeoutException if account have not reached the UNDEPLOYED state withing timeout allowed.
        Parameters:
        timeoutInSeconds - optional wait timeout in seconds, default is 5m
        intervalInMilliseconds - optional interval between account reloads while waiting for a change, default is 1s
        Returns:
        completable future which resolves when account is undeployed
      • waitRemoved

        public CompletableFuture<Void> waitRemoved​(Integer timeoutInSeconds,
                                                   Integer intervalInMilliseconds)
        Waits until account has been deleted. Completes exceptionally with TimeoutException if account was not deleted withing timeout allowed.
        Parameters:
        timeoutInSeconds - optional wait timeout in seconds, default is 5m
        intervalInMilliseconds - optional interval between account reloads while waiting for a change, default is 1s
        Returns:
        completable future which resolves when account is deleted
      • waitConnected

        public CompletableFuture<Void> waitConnected()
        Waits until API server has connected to the terminal and terminal has connected to the broker. Completes exceptionally with TimeoutException if account have not connected to the broker withing timeout allowed. Wait timeout in seconds is 5m and interval between account reloads while waiting for a change is 1s.
        Returns:
        completable future which resolves when API server is connected to the broker
      • waitConnected

        public CompletableFuture<Void> waitConnected​(Integer timeoutInSeconds,
                                                     Integer intervalInMilliseconds)
        Waits until API server has connected to the terminal and terminal has connected to the broker. Completes exceptionally with TimeoutException if account have not connected to the broker withing timeout allowed.
        Parameters:
        timeoutInSeconds - optional wait timeout in seconds, default is 5m
        intervalInMilliseconds - optional interval between account reloads while waiting for a change, default is 1s
        Returns:
        completable future which resolves when API server is connected to the broker
      • connect

        public CompletableFuture<MetaApiConnection> connect()
        Connects to MetaApi with default history storage. There is only one connection per account. Subsequent calls to this method will return the same connection.
      • connect

        public CompletableFuture<MetaApiConnection> connect​(HistoryStorage historyStorage)
        Connects to MetaApi. There is only one connection per account. Subsequent calls to this method will return the same connection.
        Parameters:
        historyStorage - optional history storage