MT5Client

class MT5Client(gatewayUrl: String, tzOffsetHours: Int, httpTimeoutMs: Long = 5000, retryAttempts: Int = 3)

Low-level HTTP client for the mt5-gateway service.

One client per MT5Broker. Handles JSON serialization, retries on GETs (POST /order is deliberately not retried — duplicate placement is worse than a surfaced failure), timezone offsets between the venue clock and UTC, and basic error parsing.

Constructors

Link copied to clipboard
constructor(gatewayUrl: String, tzOffsetHours: Int, httpTimeoutMs: Long = 5000, retryAttempts: Int = 3)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun cancelOrder(ticket: Long): String
Link copied to clipboard

Fetch the venue's working (pending) orders. Empty list if the gateway doesn't expose /orders (returns 404 → handled by getWithRetry returning null).

Link copied to clipboard
fun getPositions(magic: Int? = null): List<MT5Position>
Link copied to clipboard
fun getTick(brokerSymbol: String): MT5Tick?
Link copied to clipboard
Link copied to clipboard

Modify a working order. Returns the gateway's MT5OrderResponse — successful when MT5OrderResult.retcode is MT5_TRADE_RETCODE_DONE.

Link copied to clipboard