Table of Contents

Method ConnectAsync

Namespace
WhalesSecret.ScriptApiLib
Assembly
WhalesSecret.ScriptApiLib.dll

ConnectAsync(ExchangeMarket, ConnectionOptions?)

Connects to exchangeMarket and does appropriate API initialization to allow fully-fledged trading.

If the logged in WhalesSecret account is already connected to the exchange, the operation succeeds immediately.

If the connection is lost, an automatic reconnect is attempted.

public Task<ITradeApiClient> ConnectAsync(ExchangeMarket exchangeMarket, ConnectionOptions? connectionOptions = null)

Parameters

exchangeMarket ExchangeMarket

Exchange market to connect to.

connectionOptions ConnectionOptions

Options allowing to specify a connection timeout or register callbacks. If the value is null, Default is used.

Returns

Task<ITradeApiClient>

ITradeApiClient when a connection to exchangeMarket was established and it is ready for trading.

Remarks

Behavior of this method is exchange-specific. Typically, it is necessary to establish a persistent connection with a proper exchange server and subscribe account data updates to detect (partial) fills, etc.

This API method is based on "all or nothing" principle - either a remote API server fully works or we suppose that it does not work at all.

Exceptions

ConnectionInitializationException

Thrown if the connection could not be fully established and initialized with the remote exchange server.

OperationCanceledException

Thrown if the operation was canceled thanks to timeout defined in ConnectionTimeout.

ExchangeIsUnderMaintenanceException

Thrown if the exchange is in the maintenance mode and does not accept new connections.

InvalidArgumentException

Thrown if an unsupported exchange market is passed or if unsupported connection strategy is used.

NotConnectedException

Thrown if the request cannot be sent to the exchange.

OperationFailedException

Thrown if the operation failed.

MalfunctionException

Thrown if an internal unexpected error occurred.