Yourfintech
Yourfintech
Yourfintech
  • Yourfintech
  • Trading Platform Overview
  • Socket Integration
    • JSON format socket
      • General messages structure
      • Server messages spec
      • Client messages spec
      • Root Models
    • Yft Manager API
      • General messages structure
      • Server message spec
      • Client Messages spec
      • Root Models
  • Trading Platform Integration
    • Account Integration
      • ProtoFile
    • Trading Engine Integration
      • ProtoFile
    • Trading Settings Integration
      • ProtoFile
Powered by GitBook
On this page
  • AuthResult
  • BidAsk
  • AccountEvent
  • Position event
  • Pending position
  1. Socket Integration
  2. JSON format socket

Server messages spec

The YftJsonIntegrationServerMessage enum defines the different types of messages that the server can send to the client. Each message type corresponds to a specific information or event that the client needs to handle.

Message Types:

  • AuthResult

  • BidAsk

  • AccountEvent

  • Position

  • PendingPosition

AuthResult

The AuthResult message communicates the outcome of an authentication attempt by the client.

{
  "message_id": "test",
  "message_type": {
    "server_message": {
      "auth_result": {
        "result": "auth_failed",
        "session_id": null
      }
    }
  }
}

{
  "message_id": "test",
  "message_type": {
    "server_message": {
      "auth_result": {
        "result": "success",
        "session_id": "id"
      }
    }
  }
}

{
  "message_id": "test",
  "message_type": {
    "server_message": {
      "auth_result": {
        "result": "unauthorized",
        "session_id": null
      }
    }
  }
}

Name
Type
Desc

Result

[String] Enum: Success; AuthFailed - tech issues; Unauthorized;

Result status

Session Id

String (Optional)

Uuid of session

BidAsk

The BidAsk message provides the latest bid and ask prices for a specific financial instrument.

{
  "message_id": "test",
  "message_type": {
    "server_message": {
      "bid_ask": //bidask
    }
  }
}
Name
Type
Description

bid_ask

BidAsk

AccountEvent

The AccountEvent message notifies the client about events or changes related to their account.

{
  "message_id": "feb227ed-c238-497c-acfe-a00ffab009de",
  "message_type": {
    "server_message": {
      "account_event": {
        "account_update": {
          "account": {
            "id": "9020b4e5-dade-46da-9469-7a58fa25fd56",
            "trader_id": "8bb66514-657e-4fad-8619-41daa873f4aa",
            "currency": "USD",
            "balance": 6401.125104675008,
            "trading_disabled": false,
            "leverage": 10,
            "trading_group": "Main",
            "stop_out": 100,
            "create_date": 1727193913548382,
            "last_update_date": 1731655889733785,
            "last_update_process_id": "ns-profile-update-1731655886904146",
            "create_process_id": "2024-09-24T16:05:13.547609+00:00",
            "metadata": {}
          },
          "operation": {
            "id": "ed79287b-4e04-4acf-b2cf-180b52c3a457",
            "trader_id": "8bb66514-657e-4fad-8619-41daa873f4aa",
            "account_id": "9020b4e5-dade-46da-9469-7a58fa25fd56",
            "operation_type": "Trading",
            "process_id": "202411-15T1241:31.153-juv78vbcw",
            "delta": -0.49939999999990503,
            "date_time_unix_ms": 1731674491244930,
            "comment": "Trading result",
            "reference_operation_id": "69bfec4b-26cf-43b2-857b-e5a9fef9e24e"
          }
        }
      }
    }
  }
}

{
  "message_id": "feb227ed-c238-497c-acfe-a00ffab009de",
  "message_type": {
    "server_message": {
      "account_event": {
        "account_added": {
            "id": "9020b4e5-dade-46da-9469-7a58fa25fd56",
            "trader_id": "8bb66514-657e-4fad-8619-41daa873f4aa",
            "currency": "USD",
            "balance": 0.0,
            "trading_disabled": false,
            "leverage": 10,
            "trading_group": "Main",
            "stop_out": 100,
            "create_date": 1727193913548382,
            "last_update_date": 1731655889733785,
            "last_update_process_id": "ns-profile-update-1731655886904146",
            "create_process_id": "2024-09-24T16:05:13.547609+00:00",
            "metadata": {}
          }
      }
    }
  }
}

Account Event is an enum, so you have 2 possible options there;

Name
Type
Description

Account Added

New account added to system

AccountUpdated

Exsisted account updated

AccountUpdate

Name
Type
Description

Account

Account model after update

Balance Operation

Only if balance was updated

Position event

The Position message informs the client about their trading positions, including opening, updating, or closing positions.

{
  "message_id": "7b87bf1c-e88d-4251-bb6c-8bd40ab34dcb",
  "message_type": {
    "server_message": {
      "position": {
        "created": {
          "id": "be06c5da-35d4-4ca1-8865-f9b24b9038a3",
          "trader_id": "8bb66514-657e-4fad-8619-41daa873f4aa",
          "account_id": "9020b4e5-dade-46da-9469-7a58fa25fd56",
          "asset_pair": "BTCUSD",
          "lost_amount": 0.01,
          "side": "Buy",
          "leverage": 0,
          "create_date": 1731675320616142,
          "tp_in_instrument_price": null,
          "tp_in_currency": null,
          "sl_in_instrument_price": null,
          "sl_in_currency": null,
          "create_process_id": "202411-15T1255:20.549-5cqofxibb",
          "profit": -0.00009999999997489795,
          "metadata": {},
          "last_update_date": 1731675320616143,
          "last_update_process_id": "202411-15T1255:20.549-5cqofxibb",
          "asset_open_price": 89788.01,
          "asset_open_bid_ask": {
            "id": "BTCUSD",
            "bid": 89788,
            "ask": 89788.01,
            "date": 1731675320544000,
            "base": "BTC",
            "quote": "USD"
          },
          "open_date": 1731675320616145,
          "open_process_id": "202411-15T1255:20.549-5cqofxibb",
          "close_date": null,
          "close_reason": null,
          "asset_close_price": null,
          "asset_close_bid_ask": null,
          "close_process_id": null,
          "base": "BTC",
          "quote": "USD",
          "collateral_currency": "USD",
          "margin_price": 89788.01,
          "margin_bid_ask": {
            "id": "BTCUSD",
            "bid": 89788,
            "ask": 89788.01,
            "date": 1731675320544000,
            "base": "BTC",
            "quote": "USD"
          },
          "profit_price": 1,
          "profit_bid_ask": {
            "id": "",
            "bid": 1,
            "ask": 1,
            "date": 1731675320616059,
            "base": "",
            "quote": ""
          },
          "swaps": [],
          "lots_amount": 0.01,
          "lots_size": 1,
          "commission": 0.105
        }
      }
    }
  }
}

{
  "message_id": "7b87bf1c-e88d-4251-bb6c-8bd40ab34dcb",
  "message_type": {
    "server_message": {
      "position": {
        "updated": {
          "id": "be06c5da-35d4-4ca1-8865-f9b24b9038a3",
          "trader_id": "8bb66514-657e-4fad-8619-41daa873f4aa",
          "account_id": "9020b4e5-dade-46da-9469-7a58fa25fd56",
          "asset_pair": "BTCUSD",
          "lost_amount": 0.01,
          "side": "Buy",
          "leverage": 0,
          "create_date": 1731675320616142,
          "tp_in_instrument_price": 25.0,
          "tp_in_currency": null,
          "sl_in_instrument_price": null,
          "sl_in_currency": null,
          "create_process_id": "202411-15T1255:20.549-5cqofxibb",
          "profit": -0.00009999999997489795,
          "metadata": {},
          "last_update_date": 1731675320616143,
          "last_update_process_id": "202411-15T1255:20.549-5cqofxibb",
          "asset_open_price": 89788.01,
          "asset_open_bid_ask": {
            "id": "BTCUSD",
            "bid": 89788,
            "ask": 89788.01,
            "date": 1731675320544000,
            "base": "BTC",
            "quote": "USD"
          },
          "open_date": 1731675320616145,
          "open_process_id": "202411-15T1255:20.549-5cqofxibb",
          "close_date": null,
          "close_reason": null,
          "asset_close_price": null,
          "asset_close_bid_ask": null,
          "close_process_id": null,
          "base": "BTC",
          "quote": "USD",
          "collateral_currency": "USD",
          "margin_price": 89788.01,
          "margin_bid_ask": {
            "id": "BTCUSD",
            "bid": 89788,
            "ask": 89788.01,
            "date": 1731675320544000,
            "base": "BTC",
            "quote": "USD"
          },
          "profit_price": 1,
          "profit_bid_ask": {
            "id": "",
            "bid": 1,
            "ask": 1,
            "date": 1731675320616059,
            "base": "",
            "quote": ""
          },
          "swaps": [],
          "lots_amount": 0.01,
          "lots_size": 1,
          "commission": 0.105
        }
      }
    }
  }
}

{
  "message_id": "9f937f34-1ef9-480c-957c-a9cc551ef90a",
  "message_type": {
    "server_message": {
      "position": {
        "closed": {
          "id": "be06c5da-35d4-4ca1-8865-f9b24b9038a3",
          "trader_id": "8bb66514-657e-4fad-8619-41daa873f4aa",
          "account_id": "9020b4e5-dade-46da-9469-7a58fa25fd56",
          "asset_pair": "BTCUSD",
          "lost_amount": 0.01,
          "side": "Buy",
          "leverage": 0,
          "create_date": 1731675320616142,
          "tp_in_instrument_price": 100000,
          "tp_in_currency": null,
          "sl_in_instrument_price": null,
          "sl_in_currency": null,
          "create_process_id": "202411-15T1255:20.549-5cqofxibb",
          "profit": -0.7826999999998634,
          "metadata": {},
          "last_update_date": 1731675396857970,
          "last_update_process_id": "202411-15T1256:36.788-1c97kq1nr",
          "asset_open_price": 89788.01,
          "asset_open_bid_ask": {
            "id": "BTCUSD",
            "bid": 89788,
            "ask": 89788.01,
            "date": 1731675320544000,
            "base": "BTC",
            "quote": "USD"
          },
          "open_date": 1731675320616145,
          "open_process_id": "202411-15T1255:20.549-5cqofxibb",
          "close_date": null,
          "close_reason": null,
          "asset_close_price": null,
          "asset_close_bid_ask": null,
          "close_process_id": null,
          "base": "BTC",
          "quote": "USD",
          "collateral_currency": "USD",
          "margin_price": 89788.01,
          "margin_bid_ask": {
            "id": "BTCUSD",
            "bid": 89788,
            "ask": 89788.01,
            "date": 1731675320544000,
            "base": "BTC",
            "quote": "USD"
          },
          "profit_price": 1,
          "profit_bid_ask": {
            "id": "",
            "bid": 1,
            "ask": 1,
            "date": 1731675320616059,
            "base": "",
            "quote": ""
          },
          "swaps": [],
          "lots_amount": 0.01,
          "lots_size": 1,
          "commission": 0.105
        }
      }
    }
  }
}

Position Event is an enum, so you have 3 possible options there;

Name
Type
Description

Created

Position created

Updated

Position updated

Closed

Position closed

Pending position

The PendingPosition message notifies the client about positions that are pending execution, such as limit or stop orders.

{
  "message_id": "4478debd-2de1-47d3-a26e-3be9730f3a1f",
  "message_type": {
    "server_message": {
      "pending_position": {
        "created": {
          "id": "a29df815-31a8-4958-8c75-3df892dcc568",
          "trader_id": "8bb66514-657e-4fad-8619-41daa873f4aa",
          "account_id": "9020b4e5-dade-46da-9469-7a58fa25fd56",
          "asset_pair": "BTCUSD",
          "lots_amount": 0.01,
          "side": "Sell",
          "create_date": 1731675673786120,
          "tp_in_instrument_price": null,
          "tp_in_currency": null,
          "sl_in_instrument_price": null,
          "sl_in_currency": null,
          "create_process_id": "202411-15T1301:13.713-baz556did",
          "metadata": {},
          "last_update_date": 1731675673786123,
          "last_update_process_id": "202411-15T1301:13.713-baz556did",
          "base": "BTC",
          "quote": "USD",
          "collateral_currency": "USD",
          "desire_price": 10,
          "lots_size": 1,
          "execute_price": 0,
          "order_type": "Limit",
          "init_price": 89813.57
        }
      }
    }
  }
}

Position Event is an enum, so you have 5 possible options there;

Name
Type
Description

Created

Created

Updated

Updated

Canceled

Canceled

Failed

Failed to execute

Executed

Success execute

PreviousGeneral messages structureNextClient messages spec

Last updated 7 months ago

(Optional)

BidAskModel
Account
AccountUpdate
Account
BalanceOpeartion
Position
Position
Position
PendingPosition
PendingPosition
PendingPosition
PendingPosition
PendingPosition