ViiSync API

ViiSync.AccountApi is the .NET client library for ViiSync trading accounts. It is shaped like the MT5 client API (mt5api.dll): the same constructor, the same Connect, OrderSend, OrderClose and OrderModify with MT5's parameter lists and enums, the same model types (Order, SymbolInfo, Quote, Bar, …) and the same events (OnQuote, OnOrderUpdate, …). Code written against the MT5 API ports by changing the using and the host.

Package one file, ViiSync.AccountApi.dll, for .NET 8 and .NET 10, no other dependency
Version 1.1.0
MT5 coverage 774 of 894 applicable MT5 members fully covered (86.6 %), the other 120 partially, none missing
Transport JSON over a WebSocket (wss://), with automatic reconnect
Times UTC everywhere (the ViiSync server clock is UTC)

Where to start

A first program

// Port 443 connects over TLS to wss://<host>/ws; any other port uses ws://<host>:<port>/ws.
var api = new ViiSyncAccountApi(login, password, "server.example.com", 443);
api.OnConnectProgress += (_, e) => Console.WriteLine($"connect: {e.Progress}");
try
{
    api.Connect();   // connect + log in + load symbols, positions, orders and account figures
}
catch (ConnectException ex) when (ex.Code == Msg.INVALID_ACCOUNT)
{
    Console.WriteLine("login or password refused");
    throw;
}
var q = api.GetQuote("EURUSD") ?? throw new InvalidOperationException("no price");
// Same parameter list as MT5's OrderSend. With deviation > 0 and a price, a fill outside price ± deviation
// points is refused with REQUOTE; with deviation 0 the order fills at the live quote.
Order position = api.OrderSend("EURUSD", 0.10, q.Ask, OrderType.Buy,
    sl: 0, tp: 0, deviation: 10, comment: "docs", expertID: 42);
Console.WriteLine($"opened position #{position.Ticket} at {position.OpenPrice}");