public class MetaApiConnection extends SynchronizationListener implements ReconnectListener
SynchronizationListener.HealthStatus| Constructor and Description |
|---|
MetaApiConnection(MetaApiWebsocketClient websocketClient,
MetatraderAccount account,
HistoryStorage historyStorage,
ConnectionRegistry connectionRegistry)
Constructs MetaApi MetaTrader Api connection
|
MetaApiConnection(MetaApiWebsocketClient websocketClient,
MetatraderAccount account,
HistoryStorage historyStorage,
ConnectionRegistry connectionRegistry,
cloud.metaapi.sdk.clients.models.IsoTime historyStartTime)
Constructs MetaApi MetaTrader Api connection
|
| Modifier and Type | Method and Description |
|---|---|
void |
addSynchronizationListener(SynchronizationListener listener)
Adds synchronization listener
|
CompletableFuture<MetatraderTradeResponse> |
cancelOrder(String orderId)
Cancels order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<Void> |
close()
Closes the connection.
|
CompletableFuture<MetatraderTradeResponse> |
closeBy(String positionId,
String oppositePositionId,
MarketTradeOptions options)
Fully closes a position (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
closePosition(String positionId,
MarketTradeOptions options)
Fully closes a position (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
closePositionPartially(String positionId,
double volume,
MarketTradeOptions options)
Partially closes a position (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
closePositionsBySymbol(String symbol,
MarketTradeOptions options)
Closes position by a symbol (see https://metaapi.cloud/docs/client/websocket/api/trade/)
|
CompletableFuture<MetatraderTradeResponse> |
createLimitBuyOrder(String symbol,
double volume,
double openPrice,
Double stopLoss,
Double takeProfit,
PendingTradeOptions options)
Creates a limit buy order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createLimitBuyOrder(String symbol,
double volume,
double openPrice,
StopOptions stopLoss,
StopOptions takeProfit,
PendingTradeOptions options)
Creates a limit buy order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createLimitSellOrder(String symbol,
double volume,
double openPrice,
Double stopLoss,
Double takeProfit,
PendingTradeOptions options)
Creates a limit sell order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createLimitSellOrder(String symbol,
double volume,
double openPrice,
StopOptions stopLoss,
StopOptions takeProfit,
PendingTradeOptions options)
Creates a limit sell order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createMarketBuyOrder(String symbol,
double volume,
Double stopLoss,
Double takeProfit,
MarketTradeOptions options)
Creates a market buy order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createMarketBuyOrder(String symbol,
double volume,
StopOptions stopLoss,
StopOptions takeProfit,
MarketTradeOptions options)
Creates a market buy order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createMarketSellOrder(String symbol,
double volume,
Double stopLoss,
Double takeProfit,
MarketTradeOptions options)
Creates a market sell order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createMarketSellOrder(String symbol,
double volume,
StopOptions stopLoss,
StopOptions takeProfit,
MarketTradeOptions options)
Creates a market sell order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createStopBuyOrder(String symbol,
double volume,
double openPrice,
Double stopLoss,
Double takeProfit,
PendingTradeOptions options)
Creates a stop buy order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createStopBuyOrder(String symbol,
double volume,
double openPrice,
StopOptions stopLoss,
StopOptions takeProfit,
PendingTradeOptions options)
Creates a stop buy order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createStopLimitBuyOrder(String symbol,
double volume,
double openPrice,
double stopLimitPrice,
Double stopLoss,
Double takeProfit,
PendingTradeOptions options)
Creates a stop limit buy order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createStopLimitBuyOrder(String symbol,
double volume,
double openPrice,
double stopLimitPrice,
StopOptions stopLoss,
StopOptions takeProfit,
PendingTradeOptions options)
Creates a stop limit buy order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createStopLimitSellOrder(String symbol,
double volume,
double openPrice,
double stopLimitPrice,
Double stopLoss,
Double takeProfit,
PendingTradeOptions options)
Creates a stop limit sell order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createStopLimitSellOrder(String symbol,
double volume,
double openPrice,
double stopLimitPrice,
StopOptions stopLoss,
StopOptions takeProfit,
PendingTradeOptions options)
Creates a stop limit sell order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createStopSellOrder(String symbol,
double volume,
double openPrice,
Double stopLoss,
Double takeProfit,
PendingTradeOptions options)
Creates a stop sell order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
createStopSellOrder(String symbol,
double volume,
double openPrice,
StopOptions stopLoss,
StopOptions takeProfit,
PendingTradeOptions options)
Creates a stop sell order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
MetatraderAccount |
getAccount()
Returns MetaApi account
|
CompletableFuture<MetatraderAccountInformation> |
getAccountInformation()
Returns account information (see
https://metaapi.cloud/docs/client/websocket/api/readTradingTerminalState/readAccountInformation/).
|
CompletableFuture<MetatraderBook> |
getBook(String symbol)
Retrieves latest order book for a symbol (see
https://metaapi.cloud/docs/client/websocket/api/retrieveMarketData/readBook/).
|
CompletableFuture<MetatraderCandle> |
getCandle(String symbol,
String timeframe)
Retrieves latest candle for a symbol and timeframe (see
https://metaapi.cloud/docs/client/websocket/api/retrieveMarketData/readCandle/).
|
CompletableFuture<MetatraderDeals> |
getDealsByPosition(String positionId)
Returns history deals for a specific position id (see
https://metaapi.cloud/docs/client/websocket/api/retrieveHistoricalData/readDealsByPosition/).
|
CompletableFuture<MetatraderDeals> |
getDealsByTicket(String ticket)
Returns history deals with a specific ticket number (see
https://metaapi.cloud/docs/client/websocket/api/retrieveHistoricalData/readDealsByTicket/).
|
CompletableFuture<MetatraderDeals> |
getDealsByTimeRange(cloud.metaapi.sdk.clients.models.IsoTime startTime,
cloud.metaapi.sdk.clients.models.IsoTime endTime,
int offset,
int limit)
Returns history deals with for a specific time range (see
https://metaapi.cloud/docs/client/websocket/api/retrieveHistoricalData/readDealsByTimeRange/).
|
ConnectionHealthMonitor |
getHealthMonitor()
Returns connection health monitor instance
|
CompletableFuture<MetatraderHistoryOrders> |
getHistoryOrdersByPosition(String positionId)
Returns the history of completed orders for a specific position id (see
https://metaapi.cloud/docs/client/websocket/api/retrieveHistoricalData/readHistoryOrdersByPosition/)
|
CompletableFuture<MetatraderHistoryOrders> |
getHistoryOrdersByTicket(String ticket)
Returns the history of completed orders for a specific ticket number (see
https://metaapi.cloud/docs/client/websocket/api/retrieveHistoricalData/readHistoryOrdersByTicket/).
|
CompletableFuture<MetatraderHistoryOrders> |
getHistoryOrdersByTimeRange(cloud.metaapi.sdk.clients.models.IsoTime startTime,
cloud.metaapi.sdk.clients.models.IsoTime endTime,
int offset,
int limit)
Returns the history of completed orders for a specific time range (see
https://metaapi.cloud/docs/client/websocket/api/retrieveHistoricalData/readHistoryOrdersByTimeRange/)
|
HistoryStorage |
getHistoryStorage()
Returns local history storage
|
CompletableFuture<MetatraderOrder> |
getOrder(String orderId)
Returns specific open order (see
https://metaapi.cloud/docs/client/websocket/api/readTradingTerminalState/readOrder/).
|
CompletableFuture<List<MetatraderOrder>> |
getOrders()
Returns open orders (see
https://metaapi.cloud/docs/client/websocket/api/readTradingTerminalState/readOrders/).
|
CompletableFuture<MetatraderPosition> |
getPosition(String positionId)
Returns specific position (see
https://metaapi.cloud/docs/client/websocket/api/readTradingTerminalState/readPosition/).
|
CompletableFuture<List<MetatraderPosition>> |
getPositions()
Returns positions (see
https://metaapi.cloud/docs/client/websocket/api/readTradingTerminalState/readPositions/).
|
List<String> |
getSubscribedSymbols()
Returns list of the symbols connection is subscribed to
|
List<MarketDataSubscription> |
getSubscriptions(String symbol)
Returns subscriptions for a symbol
|
CompletableFuture<MetatraderSymbolPrice> |
getSymbolPrice(String symbol)
Retrieves latest price for a symbol (see
https://metaapi.cloud/docs/client/websocket/api/retrieveMarketData/readSymbolPrice/).
|
CompletableFuture<List<String>> |
getSymbols()
Retrieves available symbols for an account (see
https://metaapi.cloud/docs/client/websocket/api/retrieveMarketData/readSymbols/).
|
CompletableFuture<MetatraderSymbolSpecification> |
getSymbolSpecification(String symbol)
Retrieves specification for a symbol (see
https://metaapi.cloud/docs/client/websocket/api/retrieveMarketData/readSymbolSpecification/).
|
TerminalState |
getTerminalState()
Returns local copy of terminal state
|
CompletableFuture<MetatraderTick> |
getTick(String symbol)
Retrieves latest tick for a symbol (see
https://metaapi.cloud/docs/client/websocket/api/retrieveMarketData/readTick/).
|
CompletableFuture<Void> |
initialize()
Initializes meta api connection
|
boolean |
isSynchronized()
Returns synchronization status
|
CompletableFuture<Boolean> |
isSynchronized(String instanceIndex,
String synchronizationId)
Returns flag indicating status of state synchronization with MetaTrader terminal
|
CompletableFuture<MetatraderTradeResponse> |
modifyOrder(String orderId,
double openPrice,
Double stopLoss,
Double takeProfit)
Modifies a pending order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
modifyOrder(String orderId,
double openPrice,
StopOptions stopLoss,
StopOptions takeProfit)
Modifies a pending order (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
modifyPosition(String positionId,
Double stopLoss,
Double takeProfit)
Modifies a position (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<MetatraderTradeResponse> |
modifyPosition(String positionId,
StopOptions stopLoss,
StopOptions takeProfit)
Modifies a position (see https://metaapi.cloud/docs/client/websocket/api/trade/).
|
CompletableFuture<Void> |
onAccountInformationUpdated(String instanceIndex,
MetatraderAccountInformation accountInformation)
Invoked when MetaTrader account information is updated
|
CompletableFuture<Void> |
onConnected(String instanceIndex,
int replicas)
Invoked when connection to MetaTrader terminal established
|
CompletableFuture<Void> |
onDealSynchronizationFinished(String instanceIndex,
String synchronizationId)
Invoked when a synchronization of history deals on a MetaTrader account have finished
|
CompletableFuture<Void> |
onDisconnected(String instanceIndex)
Invoked when connection to MetaTrader terminal terminated
|
CompletableFuture<Void> |
onOrderSynchronizationFinished(String instanceIndex,
String synchronizationId)
Invoked when a synchronization of history orders on a MetaTrader account have finished
|
CompletableFuture<Void> |
onReconnected()
Invoked when connection to MetaTrader terminal re-established
|
CompletableFuture<Void> |
onStreamClosed(String instanceIndex)
Invoked when a stream for an instance index is closed
|
CompletableFuture<Void> |
onSubscriptionDowngraded(String instanceIndex,
String symbol,
List<MarketDataSubscription> updates,
List<MarketDataUnsubscription> unsubscriptions)
Invoked when subscription downgrade has occurred
|
CompletableFuture<Void> |
reconnect()
Reconnects to the Metatrader terminal (see https://metaapi.cloud/docs/client/websocket/api/reconnect/).
|
CompletableFuture<Void> |
removeApplication()
Clears the order and transaction history of a specified application and removes application (see
https://metaapi.cloud/docs/client/websocket/api/removeApplication/).
|
CompletableFuture<Void> |
removeHistory()
Clears the order and transaction history of a specified application so that it can be synchronized from scratch
(see https://metaapi.cloud/docs/client/websocket/api/removeHistory/).
|
CompletableFuture<Void> |
removeHistory(String application)
Clears the order and transaction history of a specified application so that it can be synchronized from scratch
(see https://metaapi.cloud/docs/client/websocket/api/removeHistory/).
|
void |
removeSynchronizationListener(SynchronizationListener listener)
Removes synchronization listener for specific account
|
CompletableFuture<Void> |
saveUptime(Map<String,Double> uptime)
Sends client uptime stats to the server.
|
CompletableFuture<Void> |
subscribe()
Initiates subscription to MetaTrader terminal
|
CompletableFuture<Void> |
subscribeToMarketData(String symbol)
Subscribes on market data of specified symbol (see
https://metaapi.cloud/docs/client/websocket/marketDataStreaming/subscribeToMarketData/).
|
CompletableFuture<Void> |
subscribeToMarketData(String symbol,
List<MarketDataSubscription> subscriptions)
Subscribes on market data of specified symbol (see
https://metaapi.cloud/docs/client/websocket/marketDataStreaming/subscribeToMarketData/).
|
CompletableFuture<Void> |
subscribeToMarketData(String symbol,
List<MarketDataSubscription> subscriptions,
Integer instanceIndex)
Subscribes on market data of specified symbol (see
https://metaapi.cloud/docs/client/websocket/marketDataStreaming/subscribeToMarketData/).
|
CompletableFuture<Void> |
subscribeToMarketData(String symbol,
List<MarketDataSubscription> subscriptions,
Integer instanceIndex,
Long timeoutInSeconds)
Subscribes on market data of specified symbol (see
https://metaapi.cloud/docs/client/websocket/marketDataStreaming/subscribeToMarketData/).
|
CompletableFuture<Boolean> |
synchronize(String instanceIndex)
Requests the terminal to start synchronization process
(see https://metaapi.cloud/docs/client/websocket/synchronizing/synchronize/)
|
CompletableFuture<Void> |
unsubscribeFromMarketData(String symbol)
Unsubscribes from market data of specified symbol (see
https://metaapi.cloud/docs/client/websocket/marketDataStreaming/unsubscribeFromMarketData/).
|
CompletableFuture<Void> |
unsubscribeFromMarketData(String symbol,
List<MarketDataUnsubscription> subscriptions)
Unsubscribes from market data of specified symbol (see
https://metaapi.cloud/docs/client/websocket/marketDataStreaming/unsubscribeFromMarketData/).
|
CompletableFuture<Void> |
unsubscribeFromMarketData(String symbol,
List<MarketDataUnsubscription> subscriptions,
int instanceIndex)
Unsubscribes from market data of specified symbol (see
https://metaapi.cloud/docs/client/websocket/marketDataStreaming/unsubscribeFromMarketData/).
|
CompletableFuture<Void> |
waitSynchronized()
Waits until synchronization to MetaTrader terminal is completed.
|
CompletableFuture<Void> |
waitSynchronized(SynchronizationOptions options)
Waits until synchronization to MetaTrader terminal is completed.
|
getHostName, getInstanceNumber, onBooksUpdated, onBrokerConnectionStatusChanged, onCandlesUpdated, onDealAdded, onHealthStatus, onHistoryOrderAdded, onOrderCompleted, onOrdersReplaced, onOrderUpdated, onPositionRemoved, onPositionsReplaced, onPositionUpdated, onSymbolPricesUpdated, onSymbolPriceUpdated, onSymbolSpecificationRemoved, onSymbolSpecificationsUpdated, onSymbolSpecificationUpdated, onSynchronizationStarted, onTicksUpdatedpublic MetaApiConnection(MetaApiWebsocketClient websocketClient, MetatraderAccount account, HistoryStorage historyStorage, ConnectionRegistry connectionRegistry)
websocketClient - MetaApi websocket clientaccount - MetaTrader account to connect tohistoryStorage - terminal history storage or null.
By default an instance of MemoryHistoryStorage will be used.connectionRegistry - metatrader account connection registrypublic MetaApiConnection(MetaApiWebsocketClient websocketClient, MetatraderAccount account, HistoryStorage historyStorage, ConnectionRegistry connectionRegistry, cloud.metaapi.sdk.clients.models.IsoTime historyStartTime)
websocketClient - MetaApi websocket clientaccount - MetaTrader account to connect tohistoryStorage - terminal history storage or null.
By default an instance of MemoryHistoryStorage will be used.connectionRegistry - metatrader account connection registryhistoryStartTime - history start sync time, or nullpublic CompletableFuture<MetatraderAccountInformation> getAccountInformation()
public CompletableFuture<List<MetatraderPosition>> getPositions()
public CompletableFuture<MetatraderPosition> getPosition(String positionId)
positionId - position idpublic CompletableFuture<List<MetatraderOrder>> getOrders()
public CompletableFuture<MetatraderOrder> getOrder(String orderId)
orderId - order id (ticket number)public CompletableFuture<MetatraderHistoryOrders> getHistoryOrdersByTicket(String ticket)
ticket - ticket number (order id)public CompletableFuture<MetatraderHistoryOrders> getHistoryOrdersByPosition(String positionId)
positionId - position idpublic CompletableFuture<MetatraderHistoryOrders> getHistoryOrdersByTimeRange(cloud.metaapi.sdk.clients.models.IsoTime startTime, cloud.metaapi.sdk.clients.models.IsoTime endTime, int offset, int limit)
startTime - start of time range, inclusiveendTime - end of time range, exclusiveoffset - pagination offsetlimit - pagination limitpublic CompletableFuture<MetatraderDeals> getDealsByTicket(String ticket)
ticket - ticket number (deal id for MT5 or order id for MT4)public CompletableFuture<MetatraderDeals> getDealsByPosition(String positionId)
positionId - position idpublic CompletableFuture<MetatraderDeals> getDealsByTimeRange(cloud.metaapi.sdk.clients.models.IsoTime startTime, cloud.metaapi.sdk.clients.models.IsoTime endTime, int offset, int limit)
startTime - start of time range, inclusiveendTime - end of time range, exclusiveoffset - pagination offsetlimit - pagination limitpublic CompletableFuture<Void> removeHistory()
public CompletableFuture<Void> removeHistory(String application)
application - application to remove history for, or nullpublic CompletableFuture<Void> removeApplication()
public CompletableFuture<MetatraderTradeResponse> createMarketBuyOrder(String symbol, double volume, Double stopLoss, Double takeProfit, MarketTradeOptions options)
symbol - symbol to tradevolume - order volumestopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nulloptions - optional trade options or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createMarketBuyOrder(String symbol, double volume, StopOptions stopLoss, StopOptions takeProfit, MarketTradeOptions options)
symbol - symbol to tradevolume - order volumestopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nulloptions - optional trade options or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createMarketSellOrder(String symbol, double volume, Double stopLoss, Double takeProfit, MarketTradeOptions options)
symbol - symbol to tradevolume - order volumestopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nulloptions - optional trade options or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createMarketSellOrder(String symbol, double volume, StopOptions stopLoss, StopOptions takeProfit, MarketTradeOptions options)
symbol - symbol to tradevolume - order volumestopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nulloptions - optional trade options or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createLimitBuyOrder(String symbol, double volume, double openPrice, Double stopLoss, Double takeProfit, PendingTradeOptions options)
symbol - symbol to tradevolume - order volumeopenPrice - order limit pricestopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nulloptions - optional trade options or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createLimitBuyOrder(String symbol, double volume, double openPrice, StopOptions stopLoss, StopOptions takeProfit, PendingTradeOptions options)
symbol - symbol to tradevolume - order volumeopenPrice - order limit pricestopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nulloptions - optional trade options or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createLimitSellOrder(String symbol, double volume, double openPrice, Double stopLoss, Double takeProfit, PendingTradeOptions options)
symbol - symbol to tradevolume - order volumeopenPrice - order limit pricestopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nulloptions - optional trade options or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createLimitSellOrder(String symbol, double volume, double openPrice, StopOptions stopLoss, StopOptions takeProfit, PendingTradeOptions options)
symbol - symbol to tradevolume - order volumeopenPrice - order limit pricestopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nulloptions - optional trade options or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createStopBuyOrder(String symbol, double volume, double openPrice, Double stopLoss, Double takeProfit, PendingTradeOptions options)
symbol - symbol to tradevolume - order volumeopenPrice - order stop pricestopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nulloptions - optional trade options or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createStopBuyOrder(String symbol, double volume, double openPrice, StopOptions stopLoss, StopOptions takeProfit, PendingTradeOptions options)
symbol - symbol to tradevolume - order volumeopenPrice - order stop pricestopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nulloptions - optional trade options or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createStopSellOrder(String symbol, double volume, double openPrice, Double stopLoss, Double takeProfit, PendingTradeOptions options)
symbol - symbol to tradevolume - order volumeopenPrice - order stop pricestopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nulloptions - optional trade options or nullTradeException, check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createStopSellOrder(String symbol, double volume, double openPrice, StopOptions stopLoss, StopOptions takeProfit, PendingTradeOptions options)
symbol - symbol to tradevolume - order volumeopenPrice - order stop pricestopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nulloptions - optional trade options or nullTradeException, check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createStopLimitBuyOrder(String symbol, double volume, double openPrice, double stopLimitPrice, Double stopLoss, Double takeProfit, PendingTradeOptions options)
symbol - symbol to tradevolume - order volumeopenPrice - order stop pricestopLimitPrice - the limit order price for the stop limit orderstopLoss - stop loss price, or nulltakeProfit - take profit price, or nulloptions - trade options, or nullTradeException, check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createStopLimitBuyOrder(String symbol, double volume, double openPrice, double stopLimitPrice, StopOptions stopLoss, StopOptions takeProfit, PendingTradeOptions options)
symbol - symbol to tradevolume - order volumeopenPrice - order stop pricestopLimitPrice - the limit order price for the stop limit orderstopLoss - stop loss price, or nulltakeProfit - take profit price, or nulloptions - trade options, or nullTradeException, check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createStopLimitSellOrder(String symbol, double volume, double openPrice, double stopLimitPrice, Double stopLoss, Double takeProfit, PendingTradeOptions options)
symbol - symbol to tradevolume - order volumeopenPrice - order stop pricestopLimitPrice - the limit order price for the stop limit orderstopLoss - stop loss price, or nulltakeProfit - take profit price, or nulloptions - trade options, or nullTradeException, check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> createStopLimitSellOrder(String symbol, double volume, double openPrice, double stopLimitPrice, StopOptions stopLoss, StopOptions takeProfit, PendingTradeOptions options)
symbol - symbol to tradevolume - order volumeopenPrice - order stop pricestopLimitPrice - the limit order price for the stop limit orderstopLoss - stop loss price, or nulltakeProfit - take profit price, or nulloptions - trade options, or nullTradeException, check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> modifyPosition(String positionId, Double stopLoss, Double takeProfit)
positionId - position id to modifystopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> modifyPosition(String positionId, StopOptions stopLoss, StopOptions takeProfit)
positionId - position id to modifystopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> closePositionPartially(String positionId, double volume, MarketTradeOptions options)
positionId - position id to modifyvolume - volume to closeoptions - optional trade options or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> closePosition(String positionId, MarketTradeOptions options)
positionId - position id to modifyoptions - optional trade options or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> closeBy(String positionId, String oppositePositionId, MarketTradeOptions options)
positionId - position id to close by opposite positionoppositePositionId - opposite position id to closeoptions - optional trade options, or nullTradeException, check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> closePositionsBySymbol(String symbol, MarketTradeOptions options)
symbol - symbol to tradeoptions - optional trade options or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> modifyOrder(String orderId, double openPrice, Double stopLoss, Double takeProfit)
orderId - order id (ticket number)openPrice - order stop pricestopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> modifyOrder(String orderId, double openPrice, StopOptions stopLoss, StopOptions takeProfit)
orderId - order id (ticket number)openPrice - order stop pricestopLoss - optional stop loss price or nulltakeProfit - optional take profit price or nullTradeException,
check error properties for error code detailspublic CompletableFuture<MetatraderTradeResponse> cancelOrder(String orderId)
orderId - order id (ticket number)TradeException,
check error properties for error code detailspublic CompletableFuture<Void> reconnect()
public CompletableFuture<Boolean> synchronize(String instanceIndex)
instanceIndex - instance indexpublic CompletableFuture<Void> initialize()
public CompletableFuture<Void> subscribe()
public CompletableFuture<Void> subscribeToMarketData(String symbol)
symbol - symbol (e.g. currency pair or an index)public CompletableFuture<Void> subscribeToMarketData(String symbol, List<MarketDataSubscription> subscriptions)
symbol - symbol (e.g. currency pair or an index)subscriptions - array of market data subscription to create or update. Please
note that this feature is not fully implemented on server-side yetpublic CompletableFuture<Void> subscribeToMarketData(String symbol, List<MarketDataSubscription> subscriptions, Integer instanceIndex)
symbol - symbol (e.g. currency pair or an index)subscriptions - array of market data subscription to create or update. Please
note that this feature is not fully implemented on server-side yetinstanceIndex - instance indexpublic CompletableFuture<Void> subscribeToMarketData(String symbol, List<MarketDataSubscription> subscriptions, Integer instanceIndex, Long timeoutInSeconds)
symbol - symbol (e.g. currency pair or an index)subscriptions - array of market data subscription to create or update. Please
note that this feature is not fully implemented on server-side yetinstanceIndex - instance indextimeoutInSeconds - timeout to wait for prices in seconds, or null. Default is 30public CompletableFuture<Void> unsubscribeFromMarketData(String symbol)
symbol - symbol (e.g. currency pair or an index)public CompletableFuture<Void> unsubscribeFromMarketData(String symbol, List<MarketDataUnsubscription> subscriptions)
symbol - symbol (e.g. currency pair or an index)subscriptions - array of subscriptions to cancelpublic CompletableFuture<Void> unsubscribeFromMarketData(String symbol, List<MarketDataUnsubscription> subscriptions, int instanceIndex)
symbol - symbol (e.g. currency pair or an index)subscriptions - array of subscriptions to cancelinstanceIndex - instance indexpublic CompletableFuture<Void> onSubscriptionDowngraded(String instanceIndex, String symbol, List<MarketDataSubscription> updates, List<MarketDataUnsubscription> unsubscriptions)
SynchronizationListeneronSubscriptionDowngraded in class SynchronizationListenerinstanceIndex - index of an account instance connectedsymbol - symbol to update subscriptions forupdates - array of market data subscription to updateunsubscriptions - array of subscriptions to cancelpublic List<String> getSubscribedSymbols()
public List<MarketDataSubscription> getSubscriptions(String symbol)
symbol - symbol to retrieve subscriptions fornullpublic CompletableFuture<List<String>> getSymbols()
public CompletableFuture<MetatraderSymbolSpecification> getSymbolSpecification(String symbol)
symbol - symbol to retrieve specification forpublic CompletableFuture<MetatraderSymbolPrice> getSymbolPrice(String symbol)
symbol - symbol to retrieve price forpublic CompletableFuture<MetatraderCandle> getCandle(String symbol, String timeframe)
symbol - symbol to retrieve candle fortimeframe - defines the timeframe according to which the candle 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<MetatraderTick> getTick(String symbol)
symbol - symbol to retrieve tick forpublic CompletableFuture<MetatraderBook> getBook(String symbol)
symbol - symbol to retrieve order book forpublic CompletableFuture<Void> saveUptime(Map<String,Double> uptime)
uptime - uptime statistics to send to the serverpublic TerminalState getTerminalState()
public HistoryStorage getHistoryStorage()
public void addSynchronizationListener(SynchronizationListener listener)
listener - synchronization listener to addpublic void removeSynchronizationListener(SynchronizationListener listener)
listener - synchronization listener to removepublic CompletableFuture<Void> onConnected(String instanceIndex, int replicas)
SynchronizationListeneronConnected in class SynchronizationListenerinstanceIndex - index of an account instance connectedreplicas - number of account replicas launchedpublic CompletableFuture<Void> onDisconnected(String instanceIndex)
SynchronizationListeneronDisconnected in class SynchronizationListenerinstanceIndex - index of an account instance connectedpublic CompletableFuture<Void> onDealSynchronizationFinished(String instanceIndex, String synchronizationId)
SynchronizationListeneronDealSynchronizationFinished in class SynchronizationListenerinstanceIndex - index of an account instance connectedsynchronizationId - synchronization request idpublic CompletableFuture<Void> onOrderSynchronizationFinished(String instanceIndex, String synchronizationId)
SynchronizationListeneronOrderSynchronizationFinished in class SynchronizationListenerinstanceIndex - index of an account instance connectedsynchronizationId - synchronization request idpublic CompletableFuture<Void> onAccountInformationUpdated(String instanceIndex, MetatraderAccountInformation accountInformation)
SynchronizationListeneronAccountInformationUpdated in class SynchronizationListenerinstanceIndex - index of an account instance connectedaccountInformation - updated MetaTrader account informationpublic CompletableFuture<Void> onReconnected()
ReconnectListeneronReconnected in interface ReconnectListenerpublic CompletableFuture<Void> onStreamClosed(String instanceIndex)
SynchronizationListeneronStreamClosed in class SynchronizationListenerinstanceIndex - index of an account instance connectedpublic CompletableFuture<Boolean> isSynchronized(String instanceIndex, String synchronizationId)
instanceIndex - index of an account instance connected, or nullsynchronizationId - optional synchronization request id, last synchronization
request id will be used by default, or nullpublic CompletableFuture<Void> waitSynchronized()
public CompletableFuture<Void> waitSynchronized(SynchronizationOptions options)
options - synchronization options, or nullpublic CompletableFuture<Void> close()
public boolean isSynchronized()
public MetatraderAccount getAccount()
public ConnectionHealthMonitor getHealthMonitor()
Copyright © 2023. All rights reserved.