The example below is designed to demonstrate how to use some of the basic protobuf messages for authorizing your application, getting accounts information and market data, and trading with your application. You can find the full source come of the example here.

The steps below intend that you have added and activated your app and got the client ID, Client Secret and access token, as it is described in the Getting Started section of this documentation.


To start using your application you should add your credentials - Client ID, Client Secret and access token to your app. Check the open authentication section above for more details.


clientId = "353_hX10YJ24gg7Gv9dfkA6n6INayHrC6vBlfKoNxjkaP4lvAgiwg4";

clientSecret = "cEQQgmFGLZ5YlXEwpSuKErvd4CFvJr2sWyo8ifgj9iemvxvQA0";

token = "uSjOgU_Q2jpY3LJmqFeVJGdPkzpjFbssqqm51GEiPqo";

Then you can authorize your application by using:

CreateAppAuthorizationRequest(_clientId, \_clientSecret)

with your Client ID and Client Secret respectively.

To authorize the required account use:

CreateAccAuthorizationRequest(_token, \_accountID)

with your access token and the required account ID respectively.

To get the required accounts ID use:


with your access token.

As a result you will get the list of the trading accounts IDs as follows:

Send: ProtoMessage{GetAccountsByAccessTokenReq}

Received: ProtoMessage{GetAccountsByAccessTokenRes{ID: 104989

ID: 104990

ID: 104462


Getting Market Data

To get the symbols list use:


To get the list of all the account deals IDs use:

CreateDealsListRequest(_accountID, startDate.ToUnixTimeMilliseconds(),

To get the list of all the account orders use:


To get the account transactions history use:

CreateCashflowHistoryRequest(_accountID, 1,

To get the list of all the trendbars use:


The result is expected to be returned in the form of the Open, High, Low, and Close positions x-axis values:

Received: ProtoMessage{Trendbars{Open: 6

High: 21

Low: 115677

Close: 21

Open: 1

High: 15

Low: 115698

Close: 15...

To get the tick data run:

CreateTickDataRequest(_accountID, 1,
((DateTimeOffset)DateTime.Now).ToUnixTimeMilliseconds(), ProtoOAQuoteType.BID);

To subscribe for the spots use:

CreateSubscribeForSpotsRequest(_accountID, 1);

To unsubscribe from the spots use:


Trading operations

To create a Market Order use:

CreateMarketOrderRequest(Convert.ToInt32(_accountID), \_token, 1,
ProtoOATradeSide.BUY, Convert.ToInt64(100000))

Response example:

Received: ProtoMessage{OrderAccepted{Order{orderId:649095, orderType:MARKET, tradeSide:BUY, symbolName:1, requestedVolume:100000, executedVolume:0, closingOrder:FALSE}, Position{positionId:396536, positionStatus:unknown, tradeSide:BUY, symbolId:1, volume:0, Price:0, swap:0, commission:0, openTimestamp:0}}}

Received: ProtoMessage{OrderFilled{Order{orderId:649095, orderType:MARKET, tradeSide:BUY, symbolName:1, requestedVolume:100000, executedVolume:100000, closingOrder:FALSE, executionPrice:1.15725}, Position{positionId:396536, positionStatus:OPENED, tradeSide:BUY, symbolId:1, volume:100000, Price:1.15725, swap:0, commission:-3, openTimestamp:1536579322377}}}

To create a Stop Order use:

CreateStopOrderRequest(Convert.ToInt32(_accountID), \_token, 1,
ProtoOATradeSide.BUY, Convert.ToInt64(100000), 1.2);

To send a Limit Order use:

CreateLimitOrderRequest(Convert.ToInt32(_accountID), \_token, 1,
ProtoOATradeSide.BUY, Convert.ToInt64(100000), 1.1);

To create a Stop Limit Order use:

CreateStopLimitOrderRequest(Convert.ToInt32(_accountID), \_token, 1,
ProtoOATradeSide.BUY, Convert.ToInt64(100000), 1.2,5);

To close a Position use:

CreateClosePositionRequest(Convert.ToInt32(_accountID), \_token,
Convert.ToInt64(txtPositionID.Text), Convert.ToInt64(txtVolume.Text))

To amend Stop Loss/Take Profit run:

\_token, Convert.ToInt64(txtPositionIDTPSL.Text),
Convert.ToDouble(txtStopLoss.Text), Convert.ToDouble(txtTakeProfit.Text));