public class MetatraderAccount extends Object
| Constructor and Description |
|---|
MetatraderAccount(MetatraderAccountDto data,
MetatraderAccountClient metatraderAccountClient,
MetaApiWebsocketClient metaApiWebsocketClient,
ConnectionRegistry connectionRegistry,
ExpertAdvisorClient expertAdvisorClient,
HistoricalMarketDataClient historicalMarketDataClient)
Constructs a MetaTrader account entity
|
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<MetaApiConnection> |
connect()
Connects to MetaApi with default history storage.
|
CompletableFuture<MetaApiConnection> |
connect(HistoryStorage historyStorage)
Connects to MetaApi.
|
CompletableFuture<MetaApiConnection> |
connect(HistoryStorage historyStorage,
IsoTime historyStartTime)
Connects to MetaApi.
|
CompletableFuture<ExpertAdvisor> |
createExpertAdvisor(String expertId,
ExpertAdvisorClient.NewExpertAdvisorDto expert)
Creates an expert advisor
|
CompletableFuture<Void> |
deploy()
Schedules account for deployment.
|
String |
getAccessToken()
Returns authorization access token to be used for accessing single account data.
|
String |
getApplication()
Returns application name to connect the account to.
|
String |
getBaseCurrency()
Returns 3-character ISO currency code of the account base currency.
|
MetatraderAccountDto.ConnectionStatus |
getConnectionStatus()
Returns terminal and broker connection status
|
List<MetatraderAccountDto.CopyFactoryRole> |
getCopyFactoryRoles()
Returns account roles for CopyFactory2 application
|
CompletableFuture<ExpertAdvisor> |
getExpertAdvisor(String expertId)
Retrieves a expert advisor of current account by id
|
CompletableFuture<List<ExpertAdvisor>> |
getExpertAdvisors()
Retrieves expert advisor of current account
|
List<MetatraderAccountDto.Extension> |
getExtensions()
Returns API extensions
|
CompletableFuture<List<MetatraderCandle>> |
getHistoricalCandles(String symbol,
String timeframe)
Returns historical candles for a specific symbol and timeframe from the MetaTrader account.
|
CompletableFuture<List<MetatraderCandle>> |
getHistoricalCandles(String symbol,
String timeframe,
IsoTime startTime)
Returns historical candles for a specific symbol and timeframe from the MetaTrader account.
|
CompletableFuture<List<MetatraderCandle>> |
getHistoricalCandles(String symbol,
String timeframe,
IsoTime startTime,
Integer limit)
Returns historical candles for a specific symbol and timeframe from the MetaTrader account.
|
CompletableFuture<List<MetatraderTick>> |
getHistoricalTicks(String symbol)
Returns historical ticks for a specific symbol from the MetaTrader account.
|
CompletableFuture<List<MetatraderTick>> |
getHistoricalTicks(String symbol,
IsoTime startTime)
Returns historical ticks for a specific symbol from the MetaTrader account.
|
CompletableFuture<List<MetatraderTick>> |
getHistoricalTicks(String symbol,
IsoTime startTime,
Integer offset,
Integer limit)
Returns historical ticks for a specific symbol from the MetaTrader account.
|
String |
getId()
Returns account id
|
String |
getLogin()
Returns account login
|
int |
getMagic()
Returns MetaTrader magic to place trades using
|
Map<String,Object> |
getMetadata()
Returns extra information which can be stored together with your account
|
String |
getName()
Returns account name
|
String |
getProvisioningProfileId()
Returns id of the account's provisioning profile
|
String |
getReliability()
Returns reliability value.
|
int |
getResourceSlots()
Returns number of resource slots to allocate to account.
|
String |
getServer()
Returns MetaTrader server which hosts the account
|
MetatraderAccountDto.DeploymentState |
getState()
Returns account deployment state
|
List<String> |
getTags()
Returns user-defined account tags
|
String |
getType()
Returns account type.
|
int |
getVersion()
Returns version value.
|
CompletableFuture<Void> |
increaseReliability()
Increases MetaTrader account reliability.
|
boolean |
isManualTrades()
Returns flag indicating if trades should be placed as manual trades on this account
|
CompletableFuture<Void> |
redeploy()
Schedules account for redeployment.
|
CompletableFuture<Void> |
reload()
Reloads MetaTrader account from API
|
CompletableFuture<Void> |
remove()
Removes MetaTrader account.
|
CompletableFuture<Void> |
undeploy()
Schedules account for undeployment.
|
CompletableFuture<Void> |
update(MetatraderAccountUpdateDto account)
Updates MetaTrader account data
|
CompletableFuture<Void> |
waitConnected()
Waits until API server has connected to the terminal and terminal has connected to the broker.
|
CompletableFuture<Void> |
waitConnected(Integer timeoutInSeconds,
Integer intervalInMilliseconds)
Waits until API server has connected to the terminal and terminal has connected to the broker.
|
CompletableFuture<Void> |
waitDeployed(Integer timeoutInSeconds,
Integer intervalInMilliseconds)
Waits until API server has finished deployment and account reached the DEPLOYED state.
|
CompletableFuture<Void> |
waitRemoved(Integer timeoutInSeconds,
Integer intervalInMilliseconds)
Waits until account has been deleted.
|
CompletableFuture<Void> |
waitUndeployed(Integer timeoutInSeconds,
Integer intervalInMilliseconds)
Waits until API server has finished undeployment and account reached the UNDEPLOYED state.
|
public MetatraderAccount(MetatraderAccountDto data, MetatraderAccountClient metatraderAccountClient, MetaApiWebsocketClient metaApiWebsocketClient, ConnectionRegistry connectionRegistry, ExpertAdvisorClient expertAdvisorClient, HistoricalMarketDataClient historicalMarketDataClient)
data - MetaTrader account datametatraderAccountClient - MetaTrader account REST API clientmetaApiWebsocketClient - MetaApi websocket clientconnectionRegistry - metatrader account connection registryexpertAdvisorClient - expert advisor REST API clienthistoricalMarketDataClient - historical market data REST API clientpublic String getId()
public String getName()
public String getType()
public String getLogin()
public String getServer()
public String getProvisioningProfileId()
public String getApplication()
public int getMagic()
public MetatraderAccountDto.DeploymentState getState()
public MetatraderAccountDto.ConnectionStatus getConnectionStatus()
public String getAccessToken()
public boolean isManualTrades()
public List<MetatraderAccountDto.Extension> getExtensions()
public Map<String,Object> getMetadata()
public List<String> getTags()
public List<MetatraderAccountDto.CopyFactoryRole> getCopyFactoryRoles()
public int getResourceSlots()
public String getBaseCurrency()
public String getReliability()
public int getVersion()
public CompletableFuture<Void> reload()
public CompletableFuture<Void> remove()
public CompletableFuture<Void> deploy()
public CompletableFuture<Void> undeploy()
public CompletableFuture<Void> redeploy()
public CompletableFuture<Void> increaseReliability()
public CompletableFuture<Void> waitDeployed(Integer timeoutInSeconds, Integer intervalInMilliseconds)
TimeoutException if account have not reached the DEPLOYED state
withing timeout allowed.timeoutInSeconds - optional wait timeout in seconds, default is 5mintervalInMilliseconds - optional interval between account reloads while waiting for a change, default is 1spublic CompletableFuture<Void> waitUndeployed(Integer timeoutInSeconds, Integer intervalInMilliseconds)
TimeoutException if account have not reached the UNDEPLOYED state
withing timeout allowed.timeoutInSeconds - optional wait timeout in seconds, default is 5mintervalInMilliseconds - optional interval between account reloads while waiting for a change, default is 1spublic CompletableFuture<Void> waitRemoved(Integer timeoutInSeconds, Integer intervalInMilliseconds)
TimeoutException
if account was not deleted withing timeout allowed.timeoutInSeconds - optional wait timeout in seconds, default is 5mintervalInMilliseconds - optional interval between account reloads while waiting for a change, default is 1spublic CompletableFuture<Void> waitConnected()
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.public CompletableFuture<Void> waitConnected(Integer timeoutInSeconds, Integer intervalInMilliseconds)
TimeoutException if account have not connected to the broker
withing timeout allowed.timeoutInSeconds - optional wait timeout in seconds, default is 5mintervalInMilliseconds - optional interval between account reloads while waiting for a change, default is 1spublic CompletableFuture<MetaApiConnection> connect()
public CompletableFuture<MetaApiConnection> connect(HistoryStorage historyStorage)
historyStorage - optional history storage, or nullpublic CompletableFuture<MetaApiConnection> connect(HistoryStorage historyStorage, IsoTime historyStartTime)
historyStorage - optional history storage, or nullhistoryStartTime - history start time, or null. Used for testspublic CompletableFuture<Void> update(MetatraderAccountUpdateDto account)
account - MetaTrader account updatepublic CompletableFuture<List<ExpertAdvisor>> getExpertAdvisors()
public CompletableFuture<ExpertAdvisor> getExpertAdvisor(String expertId)
expertId - expert advisor idpublic CompletableFuture<ExpertAdvisor> createExpertAdvisor(String expertId, ExpertAdvisorClient.NewExpertAdvisorDto expert)
expertId - expert advisor idexpert - expert advisor datapublic CompletableFuture<List<MetatraderCandle>> getHistoricalCandles(String symbol, String timeframe)
symbol - symbol to retrieve candles for (e.g. a currency pair or an index)timeframe - defines the timeframe according to which the candles must be generated.
Allowed values for MT5 are 1m, 2m, 3m, 4m, 5m, 6m, 10m, 12m, 15m, 20m, 30m, 1h, 2h, 3h, 4h,
6h, 8h, 12h, 1d, 1w, 1mn. Allowed values for MT4 are 1m, 5m, 15m 30m, 1h, 4h, 1d, 1w, 1mnpublic CompletableFuture<List<MetatraderCandle>> getHistoricalCandles(String symbol, String timeframe, IsoTime startTime)
symbol - symbol to retrieve candles for (e.g. a currency pair or an index)timeframe - defines the timeframe according to which the candles must be generated.
Allowed values for MT5 are 1m, 2m, 3m, 4m, 5m, 6m, 10m, 12m, 15m, 20m, 30m, 1h, 2h, 3h, 4h,
6h, 8h, 12h, 1d, 1w, 1mn. Allowed values for MT4 are 1m, 5m, 15m 30m, 1h, 4h, 1d, 1w, 1mnstartTime - time to start loading candles from. Note that candles are loaded in backwards
direction, so this should be the latest time. Leave null to request latest candles.public CompletableFuture<List<MetatraderCandle>> getHistoricalCandles(String symbol, String timeframe, IsoTime startTime, Integer limit)
symbol - symbol to retrieve candles for (e.g. a currency pair or an index)timeframe - defines the timeframe according to which the candles must be generated.
Allowed values for MT5 are 1m, 2m, 3m, 4m, 5m, 6m, 10m, 12m, 15m, 20m, 30m, 1h, 2h, 3h, 4h,
6h, 8h, 12h, 1d, 1w, 1mn. Allowed values for MT4 are 1m, 5m, 15m 30m, 1h, 4h, 1d, 1w, 1mnstartTime - time to start loading candles from. Note that candles are loaded in backwards
direction, so this should be the latest time. Leave null to request latest candles.limit - maximum number of candles to retrieve, or null. Must be less or equal to 1000public CompletableFuture<List<MetatraderTick>> getHistoricalTicks(String symbol)
symbol - symbol to retrieve ticks for (e.g. a currency pair or an index)public CompletableFuture<List<MetatraderTick>> getHistoricalTicks(String symbol, IsoTime startTime)
symbol - symbol to retrieve ticks for (e.g. a currency pair or an index)startTime - time to start loading ticks from. Note that ticks are loaded in forward
direction, so this should be the earliest time. Leave null to request latest candles.public CompletableFuture<List<MetatraderTick>> getHistoricalTicks(String symbol, IsoTime startTime, Integer offset, Integer limit)
symbol - symbol to retrieve ticks for (e.g. a currency pair or an index)startTime - time to start loading ticks from. Note that ticks are loaded in forward
direction, so this should be the earliest time. Leave null to request latest candles.offset - number of ticks to skip, or null (you can use it to avoid requesting
ticks from previous request twice)limit - maximum number of ticks to retrieve, or null. Must be less or equal to 1000Copyright © 2021. All rights reserved.