-Back to API

# WebSockets

Contents

SubscribeToAccountsAuth

Request

{"action": "subscribe_accounts"}

Body

Required Fields

Params

login: Admin

password: masterkey

Response

Subscribes to account updates which happen every 5 seconds

{
    "status": "Ok",
    "message": "subscribe_accounts",
    "data": null
}

After subscription, you will receive all the updates, each in a separate JSON message:

{
    "status": "Ok",
    "message": "Account",
    "data": {
        "ExternalAccountId": "",
        "TraderID": 1123,
        "Equity": 49612.39,
        "Balance": 49916.56,
        "Margin": 13.43,
        "FreeMargin": 49598.96,
        "UPL": -304.17,
        "PureProfit": 0.0,
        "PersonalAccountID": 1521,
        "IsLocked": false,
        "IsDisabled": false,
        "IsReadonly": false,
        "TradeGroupId": 132
    }
}

UnsubscribeFromAccountsAuth

Request

{"action": "unsubscribe_accounts"}

Body

Required Fields

Params

login: Admin

password: masterkey

Response

Removes subscription from orders

{
    "status": "Ok",
    "message": "unsubscribe_accounts",
    "data": null
}

SubscribeToAccountChanges

Request

{"action": "subscribe_accountChanges"}

Body

Required Fields

Params

login: Admin

password: masterkey

Response

Subscribes to account updates which happen every 5 seconds

{
    "status": "Ok",
    "message": "subscribe_accountChanges",
    "data": null
}

After subscription, once account isLocked or Isinvestor or IsDisabled you will receive the following JSON message:

{
    "status": "Ok",
    "message": "AccountChanges",
    "data": {
        "ExternalAccountId": "",
        "TraderID": 773,
        "Equity": 99719.6400,
        "Balance": 99719.0400,
        "Margin": 22.68,
        "FreeMargin": 99696.3600,
        "UPL": 0.60,
        "PureProfit": -280.9600,
        "PersonalAccountID": 1161,
        "IsLocked": false,
        "IsDisabled": false,
        "IsReadonly": false,
        "TradeGroupId": 12
    }
}

UnsubscribeFromAccountsChanges

Request

{"action": "unsubscribe_accountChanges"}

Body

Required Fields

Params

login: Admin

password: masterkey

Response

Removes subscription from orders

{
    "status": "Ok",
    "message": "unsubscribe_accountChanges",
    "data": null
}

SubscribeAccountChangesAndEquity

Request

{"action": "subscribe_accountChangesAndEquity"}

Body

Required Fields

Params

login: Admin

password: masterkey

Response

Subscribe to receive accountChanges. Each 5 sec you will be reiceving message "AccountSnapshots" with actual equity change. And each time there would be any change to account you will recieve extra message "AccountChanges" with data

{
{
    "status": "Ok",
    "message": "AccountChanges",
    "data": {
        "ExternalAccountId": "",
        "TraderID": 773,
        "Equity": 99993.8500,
        "Balance": 99994.1500,
        "Margin": 23.4600,
        "FreeMargin": 99970.3900,
        "UPL": -0.30,
        "PureProfit": -5.8300,
        "PersonalAccountID": 1161,
        "IsLocked": false,
        "IsDisabled": false,
        "IsReadonly": false,
        "TradeGroupId": 12
    }
}
{
{
    "status": "Ok",
    "message": "AccountSnapshots",
    "data": {
        "AccountSnapshots": [
            {
                "ExternalAccountId": "",
                "TraderID": 773,
                "Equity": 99993.85,
                "Balance": 99994.15,
                "Margin": 23.46,
                "FreeMargin": 99970.39,
                "UPL": -0.3,
                "PureProfit": 0.0,
                "PersonalAccountID": 1161,
                "IsLocked": false,
                "IsDisabled": false,
                "IsReadonly": false,
                "TradeGroupId": 12
            }
        ]
    }
}

GetAllSymbols

Request

{"action":"get_symbols"}

Body

Required Fields

Response

Returns all symbols which the client can subscribe to

{
    "status": "Ok",
    "message": "get_symbols",
    "data": "[{\"SymbolId\":1,\"SymbolName\":\"USDCHF\",\"SymbolCategoryId\":1,\"SymbolCategory\":\"Forex\"},{\"SymbolId\":2,\"SymbolName\":\"GBPUSD\",\"SymbolCategoryId\":1,\"SymbolCategory\":\"Forex\"},...]"
}

GetParticularFeedSymbols

Request

{"action":"get_symbols_for_trade_group", "params":"default"}

Body

Required Fields

Response

Returns all symbols which the client can subscribe to

{
"status":"Ok",
"Message":"get_symbols_for_trade_group",
"data":
"[{\"SymbolId\":1,\"SymbolName\":\"USDCHF\",\"SymbolCategoryId\":1,\"SymbolCategory\":\"Forex\"},{\"SymbolId\":2,\"SymbolName\":\"GBPUSD\",\"SymbolCategoryId\":1,\"SymbolCategory\":\"Forex\"},...]"
}

SubscribeToSymbol(s)

Request

{"action":"subscribe","params":"USD/CAD,USD/JPY"}

Body

Required Fields

Response

Subscribes to the specified symbols

{
    "status": "Ok",
    "message": "subscribe",
    "data": null
}

UnsubscribeToSymbol(s)

Request

{"action":"unsubscribe"}

Body

Required Fields

Response

Unsubscribes from all the symbols the client was subscribed to

{
    "status": "Ok",
    "message": "unsubscribe",
    "data": null
}

SubscribeToOrders

Request

{"action": "subscribe_orders"}

Body

Required Fields

Response

Subscribes to one or more orders by ids, separated by commas

{
    "status": "Ok",
    "message": "subscribe_orders",
    "data": null
}

After subscription, you will receive all the updates, each in a separate JSON message:

{
    "status": "Ok",
    "message": "Order",
    "data": {
        "OrderStates": [
            {
                "OrderID": "int",
                "StateID": "int",
                "TraderID": "int",
                "SymbolID": "int",
                "OrderTypeID": "int",
                "Volume": "decimal",
                "OpenPrice": "decimal",
                "StopLoss": "decimal",
                "TakeProfit": "decimal",
                "TrailingStop": "int",
                "CommandVolume": "decimal",
                "CommandPrice": "decimal",
                "CommandTime": "DateTime",
                "CommandTypeID": "int",
                "CommandOriginID": "int",
                "CommandSenderID": "int",
                "Margin": "decimal",
                "CommandMargin": "decimal",
                "Comment": "string",
                "ExpirationDate": "DateTime",
                "ClientOrderID": "string",
                "DealID": "int",
                "CommandVolumeUSD": "decimal",
                "CommandVolumeAC": "decimal",
                "VolumeUSD": "decimal",
                "VolumeAC": "decimal",
                "AccountingDocuments": [
                    {
                        "DocumentID": "int",
                        "IncomeItemID": "int",
                        "Amount": "decimal"
                    }
                ]
            }
        ]
    }
}

SubscribeToAccounts

Request

{"action": "subscribe_accounts"}

Body

Required Fields

Response

Subscribes to account updates which happen every 5 seconds

{
    "status": "Ok",
    "message": "subscribe_accounts",
    "data": null
}

After subscription, you will receive all the updates, each in a separate JSON message:

{
    "status": "Ok",
    "message": "Account",
    "data": [
        {
            "TraderId": "int",
            "Balance": "decimal",
            "Equity": "decimal",
            "Margin": "decimal",
            "FreeMargin": "decimal",
            "UPL": "decimal",
            "PureProfit": "decimal"
        }
    ]
}

UnsubscribeFromOrders

Request

{"action": "unsubscribe_orders"}

Body

Required Fields

Response

Removes subscription from orders.

{
    "status": "Ok",
    "message": "unsubscribe_orders",
    "data": null
}

UnsubscribeFromAccounts

Request

{"action": "unsubscribe_accounts"}

Body

Required Fields

Response

Removes subscription from orders

{
    "status": "Ok",
    "message": "unsubscribe_accounts",
    "data": null
}

ErrorResponses

Response

If an error occurs, you’ll get a response of the following type (in this case the specified symbol doesn’t exist):

{
    "status": "Error",
    "message": "Error while subscribing: Symbol 'US/CAD' doesn't exist",
    "data": null
}

StreamedData

Response

After subscribing to any symbol(s) you’ll be receiving prices every 5 seconds.

First message:

{
    "status": "Ok",
    "message": "Prices",
    "data": [
        {
            "Symbol": "USD/CAD",
         "SymbolID": 1001,
            "Bid": 1.38333,
            "Ask": 1.38341,
            "Spread": 0.00008,
            "Timestamp": "2023-10-30T13:09:58.741Z"
        }
    ]
}

Second message:

{
    "status": "Ok",
    "message": "Prices",
    "data": [
        {
            "Symbol": "USD/CAD",
 "SymbolID": 1001,
            "Bid": 1.38331,
            "Ask": 1.38339,
            "Spread": 0.00008,
            "Timestamp": "2023-10-30T13:10:57.577Z"
        }
    ]
}