feat(ctrader-openapi): vendor and compile cTrader protobuf definitions
Downloads 4 proto files from spotware/openapi-proto-messages (MIT license), compiles with prost-build, and adds payload-type constants + dispatch helpers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
22
ctrader-openapi/build.rs
Normal file
22
ctrader-openapi/build.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let proto_files = &[
|
||||
"proto/OpenApiCommonMessages.proto",
|
||||
"proto/OpenApiCommonModelMessages.proto",
|
||||
"proto/OpenApiMessages.proto",
|
||||
"proto/OpenApiModelMessages.proto",
|
||||
];
|
||||
|
||||
let includes = &["proto/"];
|
||||
|
||||
let mut config = prost_build::Config::new();
|
||||
config.protoc_arg("--experimental_allow_proto3_optional");
|
||||
|
||||
config.compile_protos(proto_files, includes)?;
|
||||
|
||||
// Re-run if any proto file changes
|
||||
for proto in proto_files {
|
||||
println!("cargo:rerun-if-changed={proto}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
31
ctrader-openapi/proto/OpenApiCommonMessages.proto
Normal file
31
ctrader-openapi/proto/OpenApiCommonMessages.proto
Normal file
@@ -0,0 +1,31 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option go_package = "/openapi";
|
||||
|
||||
option java_multiple_files = true;
|
||||
option java_generate_equals_and_hash = true;
|
||||
option java_package = "com.xtrader.protocol.proto.commons";
|
||||
option java_outer_classname = "ContainerCommonMessages";
|
||||
|
||||
import "OpenApiCommonModelMessages.proto";
|
||||
|
||||
/** Base message that is used for all messages that are sent to/from Open API proxy of cTrader platform. */
|
||||
message ProtoMessage {
|
||||
required uint32 payloadType = 1; // Contains id of ProtoPayloadType or other custom PayloadTypes (e.g. ProtoOAPayloadType).
|
||||
optional bytes payload = 2; // Serialized protobuf message that corresponds to payloadType.
|
||||
optional string clientMsgId = 3; // Request message id, assigned by the client that will be returned in the response.
|
||||
}
|
||||
|
||||
/** Error response that is sent from Open API proxy when error occurs. */
|
||||
message ProtoErrorRes {
|
||||
optional ProtoPayloadType payloadType = 1 [default = ERROR_RES];
|
||||
|
||||
required string errorCode = 2; // Contains name of ProtoErrorCode or other custom ErrorCodes (e.g. ProtoCHErrorCode).
|
||||
optional string description = 3; // Error description.
|
||||
optional uint64 maintenanceEndTimestamp = 4; // The Unix time in milliseconds of the end of the maintenance.
|
||||
}
|
||||
|
||||
/** Event that is sent from Open API proxy and can be used as criteria that connection is healthy when no other messages are sent by cTrader platform. Open API client can send this message when he needs to keep the connection open for a period without other messages longer than 30 seconds. */
|
||||
message ProtoHeartbeatEvent {
|
||||
optional ProtoPayloadType payloadType = 1 [default = HEARTBEAT_EVENT];
|
||||
}
|
||||
34
ctrader-openapi/proto/OpenApiCommonModelMessages.proto
Normal file
34
ctrader-openapi/proto/OpenApiCommonModelMessages.proto
Normal file
@@ -0,0 +1,34 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option go_package = "/openapi";
|
||||
|
||||
option java_multiple_files = true;
|
||||
option java_generate_equals_and_hash = true;
|
||||
option java_package = "com.xtrader.protocol.proto.commons.model";
|
||||
option java_outer_classname = "ContainerCommonModelMessages";
|
||||
|
||||
|
||||
// --- INTENSIVE COMMANDS 1 - 49
|
||||
// --- COMMON API 50 - 69
|
||||
enum ProtoPayloadType {
|
||||
// common intensive
|
||||
PROTO_MESSAGE = 5;
|
||||
// common commands
|
||||
ERROR_RES = 50;
|
||||
HEARTBEAT_EVENT = 51;
|
||||
}
|
||||
|
||||
// COMMON error codes 1 - 99
|
||||
enum ProtoErrorCode {
|
||||
UNKNOWN_ERROR = 1; // Generic error.
|
||||
UNSUPPORTED_MESSAGE = 2; // Message is not supported. Wrong message.
|
||||
INVALID_REQUEST = 3; // Generic error. Usually used when input value is not correct.
|
||||
TIMEOUT_ERROR = 5; // Deal execution is reached timeout and rejected.
|
||||
ENTITY_NOT_FOUND = 6; // Generic error for requests by id.
|
||||
CANT_ROUTE_REQUEST = 7; // Connection to Server is lost or not supported.
|
||||
FRAME_TOO_LONG = 8; // Message is too large.
|
||||
MARKET_CLOSED = 9; // Market is closed.
|
||||
CONCURRENT_MODIFICATION = 10; // Order is blocked (e.g. under execution) and change cannot be applied.
|
||||
BLOCKED_PAYLOAD_TYPE = 11; // Message is blocked by server or rate limit is reached.
|
||||
}
|
||||
|
||||
795
ctrader-openapi/proto/OpenApiMessages.proto
Normal file
795
ctrader-openapi/proto/OpenApiMessages.proto
Normal file
@@ -0,0 +1,795 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option go_package = "/openapi";
|
||||
|
||||
option java_multiple_files = true;
|
||||
|
||||
option java_generate_equals_and_hash = true;
|
||||
|
||||
option java_package = "com.xtrader.protocol.openapi.v2";
|
||||
|
||||
option java_outer_classname = "ContainerOpenApiV2Messages";
|
||||
|
||||
import "OpenApiModelMessages.proto";
|
||||
|
||||
/** Request for the authorizing an application to work with the cTrader platform Proxies. */
|
||||
message ProtoOAApplicationAuthReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_APPLICATION_AUTH_REQ];
|
||||
|
||||
required string clientId = 2; // The unique Client ID provided during the registration.
|
||||
required string clientSecret = 3; // The unique Client Secret provided during the registration.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOAApplicationAuthReq request. */
|
||||
message ProtoOAApplicationAuthRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_APPLICATION_AUTH_RES];
|
||||
}
|
||||
|
||||
/** Request for authorizing of the trading account session. Requires established authorized connection with the client application using ProtoOAApplicationAuthReq. */
|
||||
message ProtoOAAccountAuthReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ACCOUNT_AUTH_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // The unique identifier of the trader's account in cTrader platform.
|
||||
required string accessToken = 3; // The Access Token issued for providing access to the Trader's Account.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOAApplicationAuthRes request. */
|
||||
message ProtoOAAccountAuthRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ACCOUNT_AUTH_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // The unique identifier of the trader's account in cTrader platform.
|
||||
}
|
||||
|
||||
/** Generic response when an ERROR occurred. */
|
||||
message ProtoOAErrorRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ERROR_RES];
|
||||
|
||||
optional int64 ctidTraderAccountId = 2; // The unique identifier of the trader's account in cTrader platform.
|
||||
required string errorCode = 3; // The name of the ProtoErrorCode or the other custom ErrorCodes (e.g. ProtoCHErrorCode).
|
||||
optional string description = 4; // The error description.
|
||||
optional int64 maintenanceEndTimestamp = 5; // The Unix time in seconds when the current maintenance session will be ended.
|
||||
optional uint64 retryAfter = 6; // When you hit rate limit with errorCode=BLOCKED_PAYLOAD_TYPE, this field will contain amount of seconds until related payload type will be unlocked.
|
||||
}
|
||||
|
||||
/** Event that is sent when the connection with the client application is cancelled by the server. All the sessions for the traders' accounts will be terminated. */
|
||||
message ProtoOAClientDisconnectEvent {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_CLIENT_DISCONNECT_EVENT];
|
||||
|
||||
optional string reason = 2; // The disconnection reason explained. For example: The application access was blocked by cTrader Administrator.
|
||||
}
|
||||
|
||||
/** Event that is sent when a session to a specific trader's account is terminated by the server but the existing connections with the other trader's accounts are maintained. Reasons to trigger: account was deleted, cTID was deleted, token was refreshed, token was revoked. */
|
||||
message ProtoOAAccountsTokenInvalidatedEvent {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ACCOUNTS_TOKEN_INVALIDATED_EVENT];
|
||||
|
||||
repeated int64 ctidTraderAccountIds = 2; // The unique identifier of the trader's account in cTrader platform.
|
||||
optional string reason = 3; // The disconnection reason explained. For example: Access Token is expired or recalled.
|
||||
}
|
||||
|
||||
/** Request for getting the proxy version. Can be used to check the current version of the Open API scheme. */
|
||||
message ProtoOAVersionReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_VERSION_REQ];
|
||||
}
|
||||
|
||||
/** Response to the ProtoOAVersionReq request. */
|
||||
message ProtoOAVersionRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_VERSION_RES];
|
||||
|
||||
required string version = 2; // The current version of the server application.
|
||||
}
|
||||
|
||||
/** Request for sending a new trading order. Allowed only if the accessToken has the "trade" permissions for the trading account. */
|
||||
message ProtoOANewOrderReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_NEW_ORDER_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // The unique identifier of the trader's account in cTrader platform.
|
||||
required int64 symbolId = 3; // The unique identifier of a symbol in cTrader platform.
|
||||
required ProtoOAOrderType orderType = 4; // The type of an order - MARKET, LIMIT, STOP, MARKET_RANGE, STOP_LIMIT.
|
||||
required ProtoOATradeSide tradeSide = 5; // The trade direction - BUY or SELL.
|
||||
required int64 volume = 6; // The volume represented in 0.01 of a unit (e.g. 1000 in protocol means 10.00 units).
|
||||
optional double limitPrice = 7; // The limit price, can be specified for the LIMIT order only.
|
||||
optional double stopPrice = 8; // Stop Price, can be specified for the STOP and the STOP_LIMIT orders only.
|
||||
optional ProtoOATimeInForce timeInForce = 9 [default = GOOD_TILL_CANCEL]; // The specific order execution or expiration instruction - GOOD_TILL_DATE, GOOD_TILL_CANCEL, IMMEDIATE_OR_CANCEL, FILL_OR_KILL, MARKET_ON_OPEN.
|
||||
optional int64 expirationTimestamp = 10; // The Unix time in milliseconds of Order expiration. Should be set for the Good Till Date orders.
|
||||
optional double stopLoss = 11; // The absolute Stop Loss price (1.23456 for example). Not supported for MARKET orders.
|
||||
optional double takeProfit = 12; // The absolute Take Profit price (1.23456 for example). Unsupported for MARKET orders.
|
||||
optional string comment = 13; // User-specified comment. MaxLength = 512.
|
||||
optional double baseSlippagePrice = 14; // Base price to calculate relative slippage price for MARKET_RANGE order.
|
||||
optional int32 slippageInPoints = 15; // Slippage distance for MARKET_RANGE and STOP_LIMIT order.
|
||||
optional string label = 16; // User-specified label. MaxLength = 100.
|
||||
optional int64 positionId = 17; // Reference to the existing position if the Order is intended to modify it.
|
||||
optional string clientOrderId = 18; // Optional user-specific clientOrderId (similar to FIX ClOrderID). MaxLength = 50.
|
||||
optional int64 relativeStopLoss = 19; // Relative Stop Loss that can be specified instead of the absolute as one. Specified in 1/100000 of unit of a price. (e.g. 123000 in protocol means 1.23, 53423782 means 534.23782) For BUY stopLoss = entryPrice - relativeStopLoss, for SELL stopLoss = entryPrice + relativeStopLoss.
|
||||
optional int64 relativeTakeProfit = 20; // Relative Take Profit that can be specified instead of the absolute one. Specified in 1/100000 of unit of a price. (e.g. 123000 in protocol means 1.23, 53423782 means 534.23782) For BUY takeProfit = entryPrice + relativeTakeProfit, for SELL takeProfit = entryPrice - relativeTakeProfit.
|
||||
optional bool guaranteedStopLoss = 21; // If TRUE then stopLoss is guaranteed. Required to be set to TRUE for the Limited Risk accounts (ProtoOATrader.isLimitedRisk=true).
|
||||
optional bool trailingStopLoss = 22; // If TRUE then the Stop Loss is Trailing.
|
||||
optional ProtoOAOrderTriggerMethod stopTriggerMethod = 23 [default = TRADE]; // Trigger method for the STOP or the STOP_LIMIT pending order.
|
||||
}
|
||||
|
||||
/** Event that is sent following the successful order acceptance or execution by the server. Acts as response to the ProtoOANewOrderReq, ProtoOACancelOrderReq, ProtoOAAmendOrderReq, ProtoOAAmendPositionSLTPReq, ProtoOAClosePositionReq requests. Also, the event is sent when a Deposit/Withdrawal took place. */
|
||||
message ProtoOAExecutionEvent {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_EXECUTION_EVENT];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required ProtoOAExecutionType executionType = 3; // Type of the order operation. For example: ACCEPTED, FILLED, etc.
|
||||
optional ProtoOAPosition position = 4; // Reference to the position linked with the execution
|
||||
optional ProtoOAOrder order = 5; // Reference to the initial order.
|
||||
optional ProtoOADeal deal = 6; // Reference to the deal (execution).
|
||||
optional ProtoOABonusDepositWithdraw bonusDepositWithdraw = 7; // Reference to the Bonus Deposit or Withdrawal operation.
|
||||
optional ProtoOADepositWithdraw depositWithdraw = 8; // Reference to the Deposit or Withdrawal operation.
|
||||
optional string errorCode = 9; // The name of the ProtoErrorCode or the other custom ErrorCodes (e.g. ProtoCHErrorCode).
|
||||
optional bool isServerEvent = 10; // If TRUE then the event generated by the server logic instead of the trader's request. (e.g. stop-out).
|
||||
}
|
||||
|
||||
/** Request for cancelling existing pending order. Allowed only if the accessToken has "trade" permissions for the trading account. */
|
||||
message ProtoOACancelOrderReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_CANCEL_ORDER_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 orderId = 3; // The unique ID of the order.
|
||||
}
|
||||
|
||||
/** Request for amending the existing pending order. Allowed only if the Access Token has "trade" permissions for the trading account. */
|
||||
message ProtoOAAmendOrderReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_AMEND_ORDER_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 orderId = 3; // The unique ID of the order.
|
||||
optional int64 volume = 4; // Volume, represented in 0.01 of a unit (e.g. 1000 in protocol means 10.00 units).
|
||||
optional double limitPrice = 5; // The Limit Price, can be specified for the LIMIT order only.
|
||||
optional double stopPrice = 6; // The Stop Price, can be specified for the STOP and the STOP_LIMIT orders.
|
||||
optional int64 expirationTimestamp = 7; // The Unix timestamp in milliseconds of Order expiration. Should be set for the Good Till Date orders.
|
||||
optional double stopLoss = 8; // The absolute Stop Loss price (e.g. 1.23456). Not supported for MARKET orders.
|
||||
optional double takeProfit = 9; // The absolute Take Profit price (e.g. 1.23456). Not supported for MARKET orders.
|
||||
optional int32 slippageInPoints = 10; // Slippage distance for the MARKET_RANGE and the STOP_LIMIT orders.
|
||||
optional int64 relativeStopLoss = 11; // The relative Stop Loss can be specified instead of the absolute one. Specified in 1/100000 of a unit of price. (e.g. 123000 in protocol means 1.23, 53423782 means 534.23782) For BUY stopLoss = entryPrice - relativeStopLoss, for SELL stopLoss = entryPrice + relativeStopLoss.
|
||||
optional int64 relativeTakeProfit = 12; // The relative Take Profit can be specified instead of the absolute one. Specified in 1/100000 of a unit of price. (e.g. 123000 in protocol means 1.23, 53423782 means 534.23782) For BUY takeProfit = entryPrice + relativeTakeProfit, for SELL takeProfit = entryPrice - relativeTakeProfit.
|
||||
optional bool guaranteedStopLoss = 13; // If TRUE then the Stop Loss is guaranteed. Available for the French Risk or the Guaranteed Stop Loss Accounts.
|
||||
optional bool trailingStopLoss = 14; // If TRUE then the Trailing Stop Loss is applied.
|
||||
optional ProtoOAOrderTriggerMethod stopTriggerMethod = 15 [default = TRADE]; // Trigger method for the STOP or the STOP_LIMIT pending order.
|
||||
}
|
||||
|
||||
/** Request for amending StopLoss and TakeProfit of existing position. Allowed only if the accessToken has "trade" permissions for the trading account. */
|
||||
message ProtoOAAmendPositionSLTPReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_AMEND_POSITION_SLTP_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 positionId = 3; // The unique ID of the position to amend.
|
||||
optional double stopLoss = 4; // Absolute Stop Loss price (1.23456 for example).
|
||||
optional double takeProfit = 5; // Absolute Take Profit price (1.26543 for example).
|
||||
optional bool guaranteedStopLoss = 7; //If TRUE then the Stop Loss is guaranteed. Available for the French Risk or the Guaranteed Stop Loss Accounts.
|
||||
optional bool trailingStopLoss = 8; //If TRUE then the Trailing Stop Loss is applied.
|
||||
optional ProtoOAOrderTriggerMethod stopLossTriggerMethod = 9 [default = TRADE]; // The Stop trigger method for the Stop Loss/Take Profit order.
|
||||
}
|
||||
|
||||
/** Request for closing or partially closing of an existing position. Allowed only if the accessToken has "trade" permissions for the trading account. */
|
||||
message ProtoOAClosePositionReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_CLOSE_POSITION_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 positionId = 3; // The unique ID of the position to close.
|
||||
required int64 volume = 4; // Volume to close, represented in 0.01 of a unit (e.g. 1000 in protocol means 10.00 units).
|
||||
}
|
||||
|
||||
/** Event that is sent when the level of the Trailing Stop Loss is changed due to the price level changes. */
|
||||
message ProtoOATrailingSLChangedEvent {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_TRAILING_SL_CHANGED_EVENT];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 positionId = 3; // The unique ID of the position.
|
||||
required int64 orderId = 4; // The unique ID of the order.
|
||||
required double stopPrice = 5; // New value of the Stop Loss price.
|
||||
required int64 utcLastUpdateTimestamp = 6; // The Unix time in milliseconds when the Stop Loss was updated.
|
||||
}
|
||||
|
||||
/** Request for the list of assets available for a trader's account. */
|
||||
message ProtoOAAssetListReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ASSET_LIST_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOAAssetListReq request. */
|
||||
message ProtoOAAssetListRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ASSET_LIST_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOAAsset asset = 3; // The list of assets.
|
||||
}
|
||||
|
||||
/** Request for a list of symbols available for a trading account. Symbol entries are returned with the limited set of fields. */
|
||||
message ProtoOASymbolsListReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SYMBOLS_LIST_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
optional bool includeArchivedSymbols = 3 [default = false]; // Whether to include old archived symbols into response.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOASymbolsListReq request. */
|
||||
message ProtoOASymbolsListRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SYMBOLS_LIST_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOALightSymbol symbol = 3; // The list of symbols.
|
||||
repeated ProtoOAArchivedSymbol archivedSymbol = 4; // The list of archived symbols.
|
||||
}
|
||||
|
||||
/** Request for getting a full symbol entity. */
|
||||
message ProtoOASymbolByIdReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SYMBOL_BY_ID_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated int64 symbolId = 3; // Unique identifier of the symbol in cTrader platform.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOASymbolByIdReq request. */
|
||||
message ProtoOASymbolByIdRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SYMBOL_BY_ID_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOASymbol symbol = 3; // Symbol entity with the full set of fields.
|
||||
repeated ProtoOAArchivedSymbol archivedSymbol = 4; // Archived symbols.
|
||||
}
|
||||
|
||||
/** Request for getting a conversion chain between two assets that consists of several symbols. Use when no direct quote is available. */
|
||||
message ProtoOASymbolsForConversionReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SYMBOLS_FOR_CONVERSION_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 firstAssetId = 3; // The ID of the firs asset in the conversation chain. e.g.: for EUR/USD the firstAssetId is EUR ID and lastAssetId is USD ID.
|
||||
required int64 lastAssetId = 4; // The ID of the last asset in the conversation chain. e.g.: for EUR/USD the firstAssetId is EUR ID and lastAssetId is USD ID.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOASymbolsForConversionReq request. */
|
||||
message ProtoOASymbolsForConversionRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SYMBOLS_FOR_CONVERSION_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOALightSymbol symbol = 3; // Conversion chain of the symbols (e.g. EUR/USD, USD/JPY, GBP/JPY -> EUR/GBP).
|
||||
}
|
||||
|
||||
/** Event that is sent when the symbol is changed on the Server side. */
|
||||
message ProtoOASymbolChangedEvent {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SYMBOL_CHANGED_EVENT];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated int64 symbolId = 3; // Unique identifier of the Symbol in cTrader platform.
|
||||
}
|
||||
|
||||
/** Request for a list of asset classes available for the trader's account. */
|
||||
message ProtoOAAssetClassListReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ASSET_CLASS_LIST_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOAAssetListReq request. */
|
||||
message ProtoOAAssetClassListRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ASSET_CLASS_LIST_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOAAssetClass assetClass = 3; // List of the asset classes.
|
||||
}
|
||||
|
||||
/** Request for getting data of Trader's Account. */
|
||||
message ProtoOATraderReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_TRADER_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOATraderReq request. */
|
||||
message ProtoOATraderRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_TRADER_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required ProtoOATrader trader = 3; // The Trader account information.
|
||||
}
|
||||
|
||||
/** Event that is sent when a Trader is updated on Server side. */
|
||||
message ProtoOATraderUpdatedEvent {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_TRADER_UPDATE_EVENT];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required ProtoOATrader trader = 3; // The Trader account information.
|
||||
}
|
||||
|
||||
/** Request for getting Trader's current open positions and pending orders data. */
|
||||
message ProtoOAReconcileReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_RECONCILE_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
optional bool returnProtectionOrders = 3; // If TRUE, then current protection orders are returned separately, otherwise you can use position.stopLoss and position.takeProfit fields.
|
||||
}
|
||||
|
||||
/** The response to the ProtoOAReconcileReq request. */
|
||||
message ProtoOAReconcileRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_RECONCILE_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOAPosition position = 3; // The list of trader's account open positions.
|
||||
repeated ProtoOAOrder order = 4; // The list of trader's account pending orders.
|
||||
}
|
||||
|
||||
/** Event that is sent when errors occur during the order requests. */
|
||||
message ProtoOAOrderErrorEvent {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ORDER_ERROR_EVENT];
|
||||
|
||||
required int64 ctidTraderAccountId = 5; //Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required string errorCode = 2; // The name of the ProtoErrorCode or the other custom ErrorCodes (e.g. ProtoCHErrorCode).
|
||||
optional int64 orderId = 3; // The unique ID of the order.
|
||||
optional int64 positionId = 6; // The unique ID of the position.
|
||||
optional string description = 7; // The error description.
|
||||
}
|
||||
|
||||
/** Request for getting Trader's deals historical data (execution details). */
|
||||
message ProtoOADealListReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_DEAL_LIST_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
optional int64 fromTimestamp = 3; // The Unix time from which the search starts >=0 (1st Jan 1970).
|
||||
optional int64 toTimestamp = 4; // The Unix time where to stop searching <= 2147483646000 (19th Jan 2038).
|
||||
optional int32 maxRows = 5; // The maximum number of the deals to return.
|
||||
}
|
||||
|
||||
/** The response to the ProtoOADealListRes request. */
|
||||
message ProtoOADealListRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_DEAL_LIST_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOADeal deal = 3; // The list of the deals.
|
||||
required bool hasMore = 4; // If TRUE then the number of records by filter is larger than chunkSize, the response contains the number of records that is equal to chunkSize.
|
||||
}
|
||||
|
||||
/** Request for getting Trader's orders filtered by timestamp */
|
||||
message ProtoOAOrderListReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ORDER_LIST_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
optional int64 fromTimestamp = 3; // The Unix time from which the search starts >=0 (1st Jan 1970).
|
||||
optional int64 toTimestamp = 4; // The Unix time where to stop searching <= 2147483646000 (19th Jan 2038).
|
||||
}
|
||||
|
||||
/** The response to the ProtoOAOrderListReq request. */
|
||||
message ProtoOAOrderListRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ORDER_LIST_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOAOrder order = 3; // The list of the orders.
|
||||
required bool hasMore = 4; // If TRUE then the number of records by filter is larger than chunkSize, the response contains the number of records that is equal to chunkSize.
|
||||
}
|
||||
|
||||
/** Request for getting the margin estimate according to leverage profiles. Can be used before sending a new order request. This doesn't consider ACCORDING_TO_GSL margin calculation type, as this calculation is trivial: usedMargin = (VWAP price of the position - GSL price) * volume * Quote2Deposit. */
|
||||
message ProtoOAExpectedMarginReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_EXPECTED_MARGIN_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 symbolId = 3; // Unique identifier of the Symbol in cTrader platform.
|
||||
repeated int64 volume = 4; // Volume represented in 0.01 of a unit (e.g. 1000 in protocol means 10.00 units).
|
||||
}
|
||||
|
||||
/** The response to the ProtoOAExpectedMarginReq request. */
|
||||
message ProtoOAExpectedMarginRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_EXPECTED_MARGIN_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOAExpectedMargin margin = 3; // The buy and sell margin estimate.
|
||||
optional uint32 moneyDigits = 4; // Specifies the exponent of the monetary values. E.g. moneyDigits = 8 must be interpret as business value multiplied by 10^8, then real balance would be 10053099944 / 10^8 = 100.53099944. Affects margin.buyMargin, margin.sellMargin.
|
||||
}
|
||||
|
||||
/** Event that is sent when the margin allocated to a specific position is changed. */
|
||||
message ProtoOAMarginChangedEvent {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_MARGIN_CHANGED_EVENT];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required uint64 positionId = 3; // The unique ID of the position.
|
||||
required uint64 usedMargin = 4; // The new value of the margin used.
|
||||
optional uint32 moneyDigits = 5; // Specifies the exponent of the monetary values. E.g. moneyDigits = 8 must be interpret as business value multiplied by 10^8, then real balance would be 10053099944 / 10^8 = 100.53099944. Affects usedMargin.
|
||||
}
|
||||
|
||||
/** Request for getting Trader's historical data of deposits and withdrawals. */
|
||||
message ProtoOACashFlowHistoryListReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_CASH_FLOW_HISTORY_LIST_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 fromTimestamp = 3; // The Unix time from which the search starts >=0 (1st Jan 1970). Validation: toTimestamp - fromTimestamp <= 604800000 (1 week).
|
||||
required int64 toTimestamp = 4; // The Unix time where to stop searching <= 2147483646000 (19th Jan 2038).
|
||||
}
|
||||
|
||||
/** Response to the ProtoOACashFlowHistoryListReq request. */
|
||||
message ProtoOACashFlowHistoryListRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_CASH_FLOW_HISTORY_LIST_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOADepositWithdraw depositWithdraw = 3; // The list of deposit and withdrawal operations.
|
||||
}
|
||||
|
||||
/** Request for getting the list of granted trader's account for the access token. */
|
||||
message ProtoOAGetAccountListByAccessTokenReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_GET_ACCOUNTS_BY_ACCESS_TOKEN_REQ];
|
||||
|
||||
required string accessToken = 2; // The Access Token issued for providing access to the Trader's Account.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOAGetAccountListByAccessTokenReq request. */
|
||||
message ProtoOAGetAccountListByAccessTokenRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_GET_ACCOUNTS_BY_ACCESS_TOKEN_RES];
|
||||
|
||||
required string accessToken = 2; // The Access Token issued for providing access to the Trader's Account.
|
||||
optional ProtoOAClientPermissionScope permissionScope = 3; // SCOPE_VIEW, SCOPE_TRADE.
|
||||
repeated ProtoOACtidTraderAccount ctidTraderAccount = 4; // The list of the accounts.
|
||||
}
|
||||
|
||||
/** Request to refresh the access token using refresh token of granted trader's account. */
|
||||
message ProtoOARefreshTokenReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_REFRESH_TOKEN_REQ];
|
||||
|
||||
required string refreshToken = 2; // The Refresh Token issued for updating Access Token.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOARefreshTokenReq request. */
|
||||
message ProtoOARefreshTokenRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_REFRESH_TOKEN_RES];
|
||||
|
||||
required string accessToken = 2; // The Access Token issued for providing access to the Trader's Account.
|
||||
required string tokenType = 3; // bearer
|
||||
required int64 expiresIn = 4; // Access Token expiration in seconds.
|
||||
required string refreshToken = 5; // Your new Refresh Token.
|
||||
}
|
||||
|
||||
/** Request for subscribing on spot events of the specified symbol. After successful subscription you'll receive technical ProtoOASpotEvent with latest price, after which you'll start receiving updates on prices via consequent ProtoOASpotEvents. */
|
||||
message ProtoOASubscribeSpotsReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SUBSCRIBE_SPOTS_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated int64 symbolId = 3; // Unique identifier of the Symbol in cTrader platform.
|
||||
optional bool subscribeToSpotTimestamp = 4; // If TRUE you will also receive the timestamp in ProtoOASpotEvent.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOASubscribeSpotsReq request. Reflects that your request to subscribe for symbol has been added to queue. You'll receive technical ProtoOASpotEvent with current price shortly after this response. */
|
||||
message ProtoOASubscribeSpotsRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SUBSCRIBE_SPOTS_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
}
|
||||
|
||||
/** Request for unsubscribing from the spot events of the specified symbol. Request to stop receiving ProtoOASpotEvents related to particular symbols. Unsubscription is useful to minimize traffic, especially during high volatility events. */
|
||||
message ProtoOAUnsubscribeSpotsReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_UNSUBSCRIBE_SPOTS_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated int64 symbolId = 3; // Unique identifier of the Symbol in cTrader platform.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOASubscribeSpotsRes request. Reflects that your request to unsubscribe will has been added to queue and will be completed shortly. You may still occasionally receive ProtoOASpotEvents until request processing is complete. */
|
||||
message ProtoOAUnsubscribeSpotsRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_UNSUBSCRIBE_SPOTS_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
}
|
||||
|
||||
/** Event that is sent when a new spot event is generated on the server side. Requires subscription on the spot events, see ProtoOASubscribeSpotsReq. First event, received after subscription will contain latest spot prices even if market is closed. */
|
||||
message ProtoOASpotEvent {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SPOT_EVENT];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 symbolId = 3; // Unique identifier of the Symbol in cTrader platform.
|
||||
optional uint64 bid = 4; // Bid price. Specified in 1/100000 of unit of a price. (e.g. 123000 in protocol means 1.23, 53423782 means 534.23782)
|
||||
optional uint64 ask = 5; // Ask price. Specified in 1/100000 of unit of a price. (e.g. 123000 in protocol means 1.23, 53423782 means 534.23782)
|
||||
repeated ProtoOATrendbar trendbar = 6; // Returns live trend bar. Requires subscription on the trend bars.
|
||||
optional uint64 sessionClose = 7;// Last session close. Specified in 1/100000 of unit of a price. (e.g. 123000 in protocol means 1.23, 53423782 means 534.23782)
|
||||
optional int64 timestamp = 8; // The Unix time for spot.
|
||||
}
|
||||
|
||||
/** Request for subscribing for live trend bars. Requires subscription on the spot events, see ProtoOASubscribeSpotsReq. */
|
||||
message ProtoOASubscribeLiveTrendbarReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SUBSCRIBE_LIVE_TRENDBAR_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required ProtoOATrendbarPeriod period = 3; // Specifies period of trend bar series (e.g. M1, M10, etc.).
|
||||
required int64 symbolId = 4; // Unique identifier of the Symbol in cTrader platform.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOASubscribeLiveTrendbarReq request. */
|
||||
message ProtoOASubscribeLiveTrendbarRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SUBSCRIBE_LIVE_TRENDBAR_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
}
|
||||
|
||||
/** Request for unsubscribing from the live trend bars. */
|
||||
message ProtoOAUnsubscribeLiveTrendbarReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_UNSUBSCRIBE_LIVE_TRENDBAR_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required ProtoOATrendbarPeriod period = 3; // Specifies period of trend bar series (e.g. M1, M10, etc.).
|
||||
required int64 symbolId = 4; // Unique identifier of the Symbol in cTrader platform.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOASubscribeLiveTrendbarReq request. */
|
||||
message ProtoOAUnsubscribeLiveTrendbarRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_UNSUBSCRIBE_LIVE_TRENDBAR_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
}
|
||||
|
||||
/** Request for getting historical trend bars for the symbol. */
|
||||
message ProtoOAGetTrendbarsReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_GET_TRENDBARS_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
optional int64 fromTimestamp = 3; // The Unix time in milliseconds from which the search starts. Must be bigger or equal to zero (1st Jan 1970).
|
||||
optional int64 toTimestamp = 4; // The Unix time in milliseconds of finishing the search. Smaller or equal to 2147483646000 (19th Jan 2038).
|
||||
required ProtoOATrendbarPeriod period = 5; // Specifies period of trend bar series (e.g. M1, M10, etc.).
|
||||
required int64 symbolId = 6; // Unique identifier of the Symbol in cTrader platform.
|
||||
optional uint32 count = 7; // Limit number of trend bars in response back from toTimestamp.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOAGetTrendbarsReq request. */
|
||||
message ProtoOAGetTrendbarsRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_GET_TRENDBARS_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required ProtoOATrendbarPeriod period = 3; // Specifies period of trend bar series (e.g. M1, M10, etc.).
|
||||
optional int64 timestamp = 4 [deprecated = true]; // Simply don't use this field, as your original request already contains toTimestamp.
|
||||
repeated ProtoOATrendbar trendbar = 5; // The list of trend bars.
|
||||
optional int64 symbolId = 6; // Unique identifier of the Symbol in cTrader platform.
|
||||
optional bool hasMore = 7; // If TRUE then the number of records by filter is larger than chunkSize, the response contains the number of records that is equal to chunkSize.
|
||||
}
|
||||
|
||||
/** Request for getting historical tick data for the symbol. */
|
||||
message ProtoOAGetTickDataReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_GET_TICKDATA_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 symbolId = 3; // Unique identifier of the Symbol in cTrader platform.
|
||||
required ProtoOAQuoteType type = 4; // Bid/Ask (1/2).
|
||||
optional int64 fromTimestamp = 5; // The Unix time in milliseconds of starting the search. Must be bigger or equal to zero (1st Jan 1970).
|
||||
optional int64 toTimestamp = 6; // The Unix time in milliseconds of finishing the search. <= 2147483646000 (19th Jan 2038).
|
||||
}
|
||||
|
||||
/** Response to the ProtoOAGetTickDataReq request. */
|
||||
message ProtoOAGetTickDataRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_GET_TICKDATA_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOATickData tickData = 3; // The list of ticks is in chronological order (newest first). The first tick contains Unix time in milliseconds while all subsequent ticks have the time difference in milliseconds between the previous and the current one.
|
||||
required bool hasMore = 4; // If TRUE then the number of records by filter is larger than chunkSize, the response contains the number of records that is equal to chunkSize.
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| End quotes section |
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
/** Request for getting details of Trader's profile. Limited due to GDRP requirements. */
|
||||
message ProtoOAGetCtidProfileByTokenReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_GET_CTID_PROFILE_BY_TOKEN_REQ];
|
||||
|
||||
required string accessToken = 2; // The Access Token issued for providing access to the Trader's Account.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOAGetCtidProfileByTokenReq request. */
|
||||
message ProtoOAGetCtidProfileByTokenRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_GET_CTID_PROFILE_BY_TOKEN_RES];
|
||||
|
||||
required ProtoOACtidProfile profile = 2; // Trader's profile.
|
||||
}
|
||||
|
||||
/** Event that is sent when the structure of depth of market is changed. Requires subscription on the depth of markets for the symbol, see ProtoOASubscribeDepthQuotesReq. */
|
||||
message ProtoOADepthEvent {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_DEPTH_EVENT];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required uint64 symbolId = 3; // Unique identifier of the Symbol in cTrader platform.
|
||||
repeated ProtoOADepthQuote newQuotes = 4; // The list of changes in the depth of market quotes.
|
||||
repeated uint64 deletedQuotes = 5 [packed = true]; // The list of quotes to delete.
|
||||
}
|
||||
|
||||
/** Request for subscribing on depth of market of the specified symbol. */
|
||||
message ProtoOASubscribeDepthQuotesReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SUBSCRIBE_DEPTH_QUOTES_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated int64 symbolId = 3; // Unique identifier of the Symbol in cTrader platform.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOASubscribeDepthQuotesReq request. */
|
||||
message ProtoOASubscribeDepthQuotesRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SUBSCRIBE_DEPTH_QUOTES_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
}
|
||||
|
||||
/** Request for unsubscribing from the depth of market of the specified symbol. */
|
||||
message ProtoOAUnsubscribeDepthQuotesReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_UNSUBSCRIBE_DEPTH_QUOTES_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated int64 symbolId = 3; // Unique identifier of the Symbol in cTrader platform.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOAUnsubscribeDepthQuotesReq request. */
|
||||
message ProtoOAUnsubscribeDepthQuotesRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_UNSUBSCRIBE_DEPTH_QUOTES_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
}
|
||||
|
||||
/** Request for a list of symbol categories available for a trading account. */
|
||||
message ProtoOASymbolCategoryListReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SYMBOL_CATEGORY_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
}
|
||||
|
||||
/** Response to the ProtoSymbolCategoryListReq request. */
|
||||
message ProtoOASymbolCategoryListRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_SYMBOL_CATEGORY_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOASymbolCategory symbolCategory = 3; // The list of symbol categories.
|
||||
}
|
||||
|
||||
/** Request for logout of trading account session. */
|
||||
message ProtoOAAccountLogoutReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ACCOUNT_LOGOUT_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // The unique identifier of the trader's account in cTrader platform.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOAAccountLogoutReq request. Actual logout of trading account will be completed on ProtoOAAccountDisconnectEvent. */
|
||||
message ProtoOAAccountLogoutRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ACCOUNT_LOGOUT_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // The unique identifier of the trader's account in cTrader platform.
|
||||
}
|
||||
|
||||
/** Event that is sent when the established session for an account is dropped on the server side. A new session must be authorized for the account. */
|
||||
message ProtoOAAccountDisconnectEvent {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ACCOUNT_DISCONNECT_EVENT];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // The unique identifier of the trader's account in cTrader platform.
|
||||
}
|
||||
|
||||
/** Request for a list of existing margin call thresholds configured for a user. */
|
||||
message ProtoOAMarginCallListReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_MARGIN_CALL_LIST_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2;
|
||||
}
|
||||
|
||||
/** Response with a list of existing user Margin Calls, usually contains 3 items. */
|
||||
message ProtoOAMarginCallListRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_MARGIN_CALL_LIST_RES];
|
||||
|
||||
repeated ProtoOAMarginCall marginCall = 2;
|
||||
}
|
||||
|
||||
/** Request to modify marginLevelThreshold of specified marginCallType for ctidTraderAccountId. */
|
||||
message ProtoOAMarginCallUpdateReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_MARGIN_CALL_UPDATE_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2;
|
||||
required ProtoOAMarginCall marginCall = 3;
|
||||
}
|
||||
|
||||
/** If this response received, it means that margin call was successfully updated. */
|
||||
message ProtoOAMarginCallUpdateRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_MARGIN_CALL_UPDATE_RES];
|
||||
}
|
||||
|
||||
/** Event that is sent when a Margin Call threshold configuration is updated. */
|
||||
message ProtoOAMarginCallUpdateEvent {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_MARGIN_CALL_UPDATE_EVENT];
|
||||
|
||||
required int64 ctidTraderAccountId = 2;
|
||||
required ProtoOAMarginCall marginCall = 3;
|
||||
}
|
||||
|
||||
/** Event that is sent when account margin level reaches target marginLevelThreshold. Event is sent no more than once every 10 minutes to avoid spamming. */
|
||||
message ProtoOAMarginCallTriggerEvent {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_MARGIN_CALL_TRIGGER_EVENT];
|
||||
|
||||
required int64 ctidTraderAccountId = 2;
|
||||
required ProtoOAMarginCall marginCall = 3;
|
||||
}
|
||||
|
||||
/** Request for getting a dynamic leverage entity referenced in ProtoOASymbol.leverageId. */
|
||||
message ProtoOAGetDynamicLeverageByIDReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_GET_DYNAMIC_LEVERAGE_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 leverageId = 3;
|
||||
}
|
||||
|
||||
/** Response to the ProtoOAGetDynamicLeverageByIDReq request. */
|
||||
message ProtoOAGetDynamicLeverageByIDRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_GET_DYNAMIC_LEVERAGE_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required ProtoOADynamicLeverage leverage = 3;
|
||||
}
|
||||
|
||||
/** Request for retrieving the deals related to a position. */
|
||||
message ProtoOADealListByPositionIdReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_DEAL_LIST_BY_POSITION_ID_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 positionId = 3; // The unique ID of the position.
|
||||
optional int64 fromTimestamp = 4; // The Unix time in milliseconds of starting the search. Must be bigger or equal to zero (1st Jan 1970).
|
||||
optional int64 toTimestamp = 5; // The Unix time in milliseconds of finishing the search. <= 2147483646000 (19th Jan 2038).
|
||||
}
|
||||
|
||||
/** Response to the ProtoOADealListByPositionIdReq request. */
|
||||
message ProtoOADealListByPositionIdRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_DEAL_LIST_BY_POSITION_ID_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOADeal deal = 3; // The list of deals.
|
||||
required bool hasMore = 4; // If TRUE then the number of records by filter is larger than chunkSize, the response contains the number of records that is equal to chunkSize.
|
||||
}
|
||||
|
||||
/** Request for getting Order and its related Deals. */
|
||||
message ProtoOAOrderDetailsReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ORDER_DETAILS_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 orderId = 3; // The unique ID of the Order.
|
||||
}
|
||||
|
||||
/** Response to the ProtoOAOrderDetailsReq request. */
|
||||
message ProtoOAOrderDetailsRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ORDER_DETAILS_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required ProtoOAOrder order = 3; // Order details.
|
||||
repeated ProtoOADeal deal = 4; // All Deals created by filling the specified Order.
|
||||
}
|
||||
|
||||
/** Request for retrieving Orders related to a Position by using Position ID. Filtered by utcLastUpdateTimestamp. */
|
||||
message ProtoOAOrderListByPositionIdReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ORDER_LIST_BY_POSITION_ID_REQ];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 positionId = 3; // The unique ID of the Position.
|
||||
optional int64 fromTimestamp = 4; // The Unix time from which the search starts >=0 (1st Jan 1970). Search by utcLastUpdateTimestamp of the Order.
|
||||
optional int64 toTimestamp = 5; // The Unix time where to stop searching <= 2147483646000 (19th Jan 2038). Search by utcLastUpdateTimestamp of the Order.
|
||||
}
|
||||
|
||||
/** Response to ProtoOAOrderListByPositionIdReq request. */
|
||||
message ProtoOAOrderListByPositionIdRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_ORDER_LIST_BY_POSITION_ID_RES];
|
||||
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOAOrder order = 3; // Orders related to the specified Position, sorted by utcLastUpdateTimestamp in descending order (newest first).
|
||||
required bool hasMore = 4; // If TRUE then the number of records by filter is larger than chunkSize, the response contains the number of records that is equal to chunkSize.
|
||||
}
|
||||
|
||||
/** Request for getting sets of Deals that were offset by a specific Deal and that are offsetting the Deal. */
|
||||
message ProtoOADealOffsetListReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_DEAL_OFFSET_LIST_REQ];
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
required int64 dealId = 3; // The unique ID of the Deal.
|
||||
}
|
||||
|
||||
/** Response for ProtoOADealOffsetListReq. */
|
||||
message ProtoOADealOffsetListRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_DEAL_OFFSET_LIST_RES];
|
||||
required int64 ctidTraderAccountId = 2; // Unique identifier of the trader's account. Used to match responses to trader's accounts.
|
||||
repeated ProtoOADealOffset offsetBy = 3; // Deals which closed the specified deal.
|
||||
repeated ProtoOADealOffset offsetting = 4; // Deals which were closed by the specified deal.
|
||||
}
|
||||
|
||||
/** Request for getting trader's positions' unrealized PnLs. */
|
||||
message ProtoOAGetPositionUnrealizedPnLReq {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_GET_POSITION_UNREALIZED_PNL_REQ];
|
||||
required int64 ctidTraderAccountId = 2; // The unique identifier of the trader's account in cTrader platform.
|
||||
}
|
||||
|
||||
/** Response to ProtoOAGetPositionUnrealizedPnLReq request. */
|
||||
message ProtoOAGetPositionUnrealizedPnLRes {
|
||||
optional ProtoOAPayloadType payloadType = 1 [default = PROTO_OA_GET_POSITION_UNREALIZED_PNL_RES];
|
||||
required int64 ctidTraderAccountId = 2; // The unique identifier of the trader's account in cTrader platform.
|
||||
repeated ProtoOAPositionUnrealizedPnL positionUnrealizedPnL = 3; // Information about trader's positions' unrealized PnLs.
|
||||
required uint32 moneyDigits = 4; // Specifies the exponent of various monetary values. E.g., moneyDigits = 8 should be interpreted as the value multiplied by 10^8 with the 'real' value equal to 10053099944 / 10^8 = 100.53099944. Affects positionUnrealizedPnL.grossUnrealizedPnL, positionUnrealizedPnL.netUnrealizedPnL.
|
||||
}
|
||||
723
ctrader-openapi/proto/OpenApiModelMessages.proto
Normal file
723
ctrader-openapi/proto/OpenApiModelMessages.proto
Normal file
@@ -0,0 +1,723 @@
|
||||
syntax = "proto2";
|
||||
|
||||
option go_package = "/openapi";
|
||||
|
||||
option java_multiple_files = true;
|
||||
|
||||
option java_generate_equals_and_hash = true;
|
||||
|
||||
option java_package = "com.xtrader.protocol.openapi.v2.model";
|
||||
|
||||
option java_outer_classname = "ContainerOpenApiV2ModelMessages";
|
||||
|
||||
enum ProtoOAPayloadType {
|
||||
PROTO_OA_APPLICATION_AUTH_REQ = 2100;
|
||||
PROTO_OA_APPLICATION_AUTH_RES = 2101;
|
||||
PROTO_OA_ACCOUNT_AUTH_REQ = 2102;
|
||||
PROTO_OA_ACCOUNT_AUTH_RES = 2103;
|
||||
PROTO_OA_VERSION_REQ = 2104;
|
||||
PROTO_OA_VERSION_RES = 2105;
|
||||
PROTO_OA_NEW_ORDER_REQ = 2106;
|
||||
PROTO_OA_TRAILING_SL_CHANGED_EVENT = 2107;
|
||||
PROTO_OA_CANCEL_ORDER_REQ = 2108;
|
||||
PROTO_OA_AMEND_ORDER_REQ = 2109;
|
||||
PROTO_OA_AMEND_POSITION_SLTP_REQ = 2110;
|
||||
PROTO_OA_CLOSE_POSITION_REQ = 2111;
|
||||
PROTO_OA_ASSET_LIST_REQ = 2112;
|
||||
PROTO_OA_ASSET_LIST_RES = 2113;
|
||||
PROTO_OA_SYMBOLS_LIST_REQ = 2114;
|
||||
PROTO_OA_SYMBOLS_LIST_RES = 2115;
|
||||
PROTO_OA_SYMBOL_BY_ID_REQ = 2116;
|
||||
PROTO_OA_SYMBOL_BY_ID_RES = 2117;
|
||||
PROTO_OA_SYMBOLS_FOR_CONVERSION_REQ = 2118;
|
||||
PROTO_OA_SYMBOLS_FOR_CONVERSION_RES = 2119;
|
||||
PROTO_OA_SYMBOL_CHANGED_EVENT = 2120;
|
||||
PROTO_OA_TRADER_REQ = 2121;
|
||||
PROTO_OA_TRADER_RES = 2122;
|
||||
PROTO_OA_TRADER_UPDATE_EVENT = 2123;
|
||||
PROTO_OA_RECONCILE_REQ = 2124;
|
||||
PROTO_OA_RECONCILE_RES = 2125;
|
||||
PROTO_OA_EXECUTION_EVENT = 2126;
|
||||
PROTO_OA_SUBSCRIBE_SPOTS_REQ = 2127;
|
||||
PROTO_OA_SUBSCRIBE_SPOTS_RES = 2128;
|
||||
PROTO_OA_UNSUBSCRIBE_SPOTS_REQ = 2129;
|
||||
PROTO_OA_UNSUBSCRIBE_SPOTS_RES = 2130;
|
||||
PROTO_OA_SPOT_EVENT = 2131;
|
||||
PROTO_OA_ORDER_ERROR_EVENT = 2132;
|
||||
PROTO_OA_DEAL_LIST_REQ = 2133;
|
||||
PROTO_OA_DEAL_LIST_RES = 2134;
|
||||
PROTO_OA_SUBSCRIBE_LIVE_TRENDBAR_REQ = 2135;
|
||||
PROTO_OA_UNSUBSCRIBE_LIVE_TRENDBAR_REQ = 2136;
|
||||
PROTO_OA_GET_TRENDBARS_REQ = 2137;
|
||||
PROTO_OA_GET_TRENDBARS_RES = 2138;
|
||||
PROTO_OA_EXPECTED_MARGIN_REQ = 2139;
|
||||
PROTO_OA_EXPECTED_MARGIN_RES = 2140;
|
||||
PROTO_OA_MARGIN_CHANGED_EVENT = 2141;
|
||||
PROTO_OA_ERROR_RES = 2142;
|
||||
PROTO_OA_CASH_FLOW_HISTORY_LIST_REQ = 2143;
|
||||
PROTO_OA_CASH_FLOW_HISTORY_LIST_RES = 2144;
|
||||
PROTO_OA_GET_TICKDATA_REQ = 2145;
|
||||
PROTO_OA_GET_TICKDATA_RES = 2146;
|
||||
PROTO_OA_ACCOUNTS_TOKEN_INVALIDATED_EVENT = 2147;
|
||||
PROTO_OA_CLIENT_DISCONNECT_EVENT = 2148;
|
||||
PROTO_OA_GET_ACCOUNTS_BY_ACCESS_TOKEN_REQ = 2149;
|
||||
PROTO_OA_GET_ACCOUNTS_BY_ACCESS_TOKEN_RES = 2150;
|
||||
PROTO_OA_GET_CTID_PROFILE_BY_TOKEN_REQ = 2151;
|
||||
PROTO_OA_GET_CTID_PROFILE_BY_TOKEN_RES = 2152;
|
||||
PROTO_OA_ASSET_CLASS_LIST_REQ = 2153;
|
||||
PROTO_OA_ASSET_CLASS_LIST_RES = 2154;
|
||||
PROTO_OA_DEPTH_EVENT = 2155;
|
||||
PROTO_OA_SUBSCRIBE_DEPTH_QUOTES_REQ = 2156;
|
||||
PROTO_OA_SUBSCRIBE_DEPTH_QUOTES_RES = 2157;
|
||||
PROTO_OA_UNSUBSCRIBE_DEPTH_QUOTES_REQ = 2158;
|
||||
PROTO_OA_UNSUBSCRIBE_DEPTH_QUOTES_RES = 2159;
|
||||
PROTO_OA_SYMBOL_CATEGORY_REQ = 2160;
|
||||
PROTO_OA_SYMBOL_CATEGORY_RES = 2161;
|
||||
PROTO_OA_ACCOUNT_LOGOUT_REQ = 2162;
|
||||
PROTO_OA_ACCOUNT_LOGOUT_RES = 2163;
|
||||
PROTO_OA_ACCOUNT_DISCONNECT_EVENT = 2164;
|
||||
PROTO_OA_SUBSCRIBE_LIVE_TRENDBAR_RES = 2165;
|
||||
PROTO_OA_UNSUBSCRIBE_LIVE_TRENDBAR_RES = 2166;
|
||||
PROTO_OA_MARGIN_CALL_LIST_REQ = 2167;
|
||||
PROTO_OA_MARGIN_CALL_LIST_RES = 2168;
|
||||
PROTO_OA_MARGIN_CALL_UPDATE_REQ = 2169;
|
||||
PROTO_OA_MARGIN_CALL_UPDATE_RES = 2170;
|
||||
PROTO_OA_MARGIN_CALL_UPDATE_EVENT = 2171;
|
||||
PROTO_OA_MARGIN_CALL_TRIGGER_EVENT = 2172;
|
||||
PROTO_OA_REFRESH_TOKEN_REQ = 2173;
|
||||
PROTO_OA_REFRESH_TOKEN_RES = 2174;
|
||||
PROTO_OA_ORDER_LIST_REQ = 2175;
|
||||
PROTO_OA_ORDER_LIST_RES = 2176;
|
||||
PROTO_OA_GET_DYNAMIC_LEVERAGE_REQ = 2177;
|
||||
PROTO_OA_GET_DYNAMIC_LEVERAGE_RES = 2178;
|
||||
PROTO_OA_DEAL_LIST_BY_POSITION_ID_REQ = 2179;
|
||||
PROTO_OA_DEAL_LIST_BY_POSITION_ID_RES = 2180;
|
||||
PROTO_OA_ORDER_DETAILS_REQ = 2181;
|
||||
PROTO_OA_ORDER_DETAILS_RES = 2182;
|
||||
PROTO_OA_ORDER_LIST_BY_POSITION_ID_REQ = 2183;
|
||||
PROTO_OA_ORDER_LIST_BY_POSITION_ID_RES = 2184;
|
||||
PROTO_OA_DEAL_OFFSET_LIST_REQ = 2185;
|
||||
PROTO_OA_DEAL_OFFSET_LIST_RES = 2186;
|
||||
PROTO_OA_GET_POSITION_UNREALIZED_PNL_REQ = 2187;
|
||||
PROTO_OA_GET_POSITION_UNREALIZED_PNL_RES = 2188;
|
||||
}
|
||||
|
||||
/** Asset entity. */
|
||||
message ProtoOAAsset {
|
||||
required int64 assetId = 1; // The unique asset ID.
|
||||
required string name = 2; // The asset name.
|
||||
optional string displayName = 3; // User friendly name.
|
||||
optional int32 digits = 4; // Precision of the asset.
|
||||
}
|
||||
|
||||
/** Trading symbol entity. */
|
||||
message ProtoOASymbol {
|
||||
required int64 symbolId = 1; // The unique identifier of the symbol in specific server environment within cTrader platform. Different servers have different IDs.
|
||||
required int32 digits = 2; // Number of price digits to be displayed.
|
||||
required int32 pipPosition = 3; // Pip position on digits.
|
||||
optional bool enableShortSelling = 4; // If TRUE then the short selling with the symbol is enabled.
|
||||
optional bool guaranteedStopLoss = 5; // If TRUE then setting of guaranteedStopLoss is available for limited risk accounts.
|
||||
optional ProtoOADayOfWeek swapRollover3Days = 6 [default = MONDAY]; // Day of the week when SWAP charge amount will be tripled. Doesn't impact Rollover Commission.
|
||||
optional double swapLong = 7; // SWAP charge for long positions.
|
||||
optional double swapShort = 8; // SWAP charge for short positions.
|
||||
optional int64 maxVolume = 9; // Maximum allowed volume in cents for an order with a symbol.
|
||||
optional int64 minVolume = 10; // Minimum allowed volume in cents for an order with a symbol.
|
||||
optional int64 stepVolume = 11; // Step of the volume in cents for an order.
|
||||
optional uint64 maxExposure = 12; // Value of max exposure per symbol, per account. Blocks execution if breached.
|
||||
repeated ProtoOAInterval schedule = 13; // Symbol trading interval, specified in seconds starting from SUNDAY 00:00 in specified time zone.
|
||||
optional int64 commission = 14 [deprecated = true]; // Commission base amount. Total commission depends on commissionType. Use preciseTradingCommissionRate.
|
||||
optional ProtoOACommissionType commissionType = 15 [default = USD_PER_MILLION_USD]; // Commission type. See ProtoOACommissionType for details.
|
||||
optional uint32 slDistance = 16; // Minimum allowed distance between stop loss and current market price.
|
||||
optional uint32 tpDistance = 17; // Minimum allowed distance between take profit and current market price.
|
||||
optional uint32 gslDistance = 18; // Minimum allowed distance between guaranteed stop loss and current market price.
|
||||
optional int64 gslCharge = 19; // Guaranteed stop loss fee.
|
||||
optional ProtoOASymbolDistanceType distanceSetIn = 20 [default = SYMBOL_DISTANCE_IN_POINTS]; // Unit of distance measure for slDistance, tpDistance, gslDistance.
|
||||
optional int64 minCommission = 21 [deprecated = true]; // Minimum commission amount per trade. Use preciseMinCommission.
|
||||
optional ProtoOAMinCommissionType minCommissionType = 22 [default = CURRENCY]; // Minimum commission Type. See ProtoOAMinCommissionType for details.
|
||||
optional string minCommissionAsset = 23 [default = "USD"]; // Currency for minimum commission. (USD or quote currency).
|
||||
optional int64 rolloverCommission = 24; // Administrative Fee, charged instead of Swaps if the Account is marked as a "Shariah Compliant (Swap Free)". The Administrative Fee is charged daily as USD per current open volume of Position in lots. The Account charged in the Deposit currency.
|
||||
optional int32 skipRolloverDays = 25; // Initial period before the first rolloverCommission will be charged on the account.
|
||||
optional string scheduleTimeZone = 26; // Time zone for the symbol trading intervals.
|
||||
optional ProtoOATradingMode tradingMode = 27 [default = ENABLED]; // Rules for trading with the symbol. See ProtoOATradingMode for details.
|
||||
optional ProtoOADayOfWeek rolloverCommission3Days = 28 [default = MONDAY]; // Day of the week (in UTC) when Administrative Fee charge amount will be tripled. Applied only if RolloverChargePeriod = 0 or 1.
|
||||
optional ProtoOASwapCalculationType swapCalculationType = 29 [default = PIPS]; // Specifies type of SWAP computation as PIPS (0) or PERCENTAGE (1, annual, in percent).
|
||||
optional int64 lotSize = 30; // Lot size of the Symbol (in cents).
|
||||
optional int64 preciseTradingCommissionRate = 31; // Commission base amount. Total commission depends on commissionType: for non-percentage types it is multiplied by 10^8, for percentage of value commission type it is multiplied by 10^5.
|
||||
optional int64 preciseMinCommission = 32; // Minimum commission amount per trade multiplied by 10^8.
|
||||
repeated ProtoOAHoliday holiday = 33; // List of holidays for this symbol specified by broker.
|
||||
optional int32 pnlConversionFeeRate = 34; // Percentage (1 = 0.01%) of the realized Gross Profit, which will be paid by the Trader for any trade if the Quote Asset of the traded Symbol is not matched with the Deposit Asset.
|
||||
optional int64 leverageId = 35; // The unique identifier of dynamic leverage entity. https://help.ctrader.com/ctrader/trading/dynamic-leverage
|
||||
optional int32 swapPeriod = 36; // Period of charging swaps in hours. 24 means swaps will be charged 1 time per day, 12 - every 12 hours, 8 - every 8 hours, etc.
|
||||
optional int32 swapTime = 37; // Time in minutes from 00:00 (UTC) when intraday swaps are charged for the first time.
|
||||
optional int32 skipSWAPPeriods = 38; // Count of swapPeriods before the first SWAP charge.
|
||||
optional bool chargeSwapAtWeekends = 39; // If enabled, SWAP will be charged for all days of the week, including Saturday and Sunday.
|
||||
optional string measurementUnits = 40; // Specifies the units in which the base Asset of the Symbol is denominated.
|
||||
}
|
||||
|
||||
/** Lightweight symbol entity. */
|
||||
message ProtoOALightSymbol {
|
||||
required int64 symbolId = 1; // The unique identifier of the symbol in specific server environment within cTrader platform. Different brokers might have different IDs.
|
||||
optional string symbolName = 2; // Name of the symbol (e.g. EUR/USD).
|
||||
optional bool enabled = 3; // If TRUE then symbol is visible for traders.
|
||||
optional int64 baseAssetId = 4; // Base asset.
|
||||
optional int64 quoteAssetId = 5; // Quote asset.
|
||||
optional int64 symbolCategoryId = 6; // Id of the symbol category used for symbols grouping.
|
||||
optional string description = 7;
|
||||
optional double sortingNumber = 8; // The number used for sorting Symbols in the UI (lowest number should appear at the top).
|
||||
}
|
||||
|
||||
message ProtoOAArchivedSymbol {
|
||||
required int64 symbolId = 1; // The unique identifier of the symbol in specific server environment within cTrader platform. Different brokers might have different IDs.
|
||||
required string name = 2; // Name of the symbol (e.g. EUR/USD).
|
||||
required int64 utcLastUpdateTimestamp = 3; // The Unix time in milliseconds of the last update of the symbol.
|
||||
optional string description = 4; // Description of the symbol.
|
||||
}
|
||||
|
||||
/** Symbol category entity. */
|
||||
message ProtoOASymbolCategory {
|
||||
required int64 id = 1; // The unique identifier of the symbol category.
|
||||
required int64 assetClassId = 2; // Link to the asset class. One asset class can have many symbol categories.
|
||||
required string name = 3; // Category name.
|
||||
optional double sortingNumber = 4; // The number used for sorting Symbol Categories in the UI (lowest number should appear at the top).
|
||||
}
|
||||
|
||||
enum ProtoOADayOfWeek {
|
||||
NONE = 0;
|
||||
MONDAY = 1;
|
||||
TUESDAY = 2;
|
||||
WEDNESDAY = 3;
|
||||
THURSDAY = 4;
|
||||
FRIDAY = 5;
|
||||
SATURDAY = 6;
|
||||
SUNDAY = 7;
|
||||
}
|
||||
|
||||
/** Symbol trading session entity. */
|
||||
message ProtoOAInterval {
|
||||
required uint32 startSecond = 3; // Interval start, specified in seconds starting from SUNDAY 00:00 in specified time zone (inclusive to the interval).
|
||||
required uint32 endSecond = 4; // Interval end, specified in seconds starting from SUNDAY 00:00 in specified time zone (exclusive from the interval).
|
||||
}
|
||||
|
||||
/** Enum for specifying type of trading commission. */
|
||||
enum ProtoOACommissionType {
|
||||
USD_PER_MILLION_USD = 1; // USD per million USD volume - usually used for FX. Example: 50 USD for 1 mil USD of trading volume.
|
||||
USD_PER_LOT = 2; // USD per 1 lot - usually used for CFDs and futures for commodities, and indices. Example: 15 USD for 1 contract.
|
||||
PERCENTAGE_OF_VALUE = 3; // Percentage of trading volume - usually used for Equities. Example: 0.005% of notional trading volume. Multiplied by 100,000.
|
||||
QUOTE_CCY_PER_LOT = 4; // Quote ccy of Symbol per 1 lot - will be used for CFDs and futures for commodities, and indices. Example: 15 EUR for 1 contract of DAX.
|
||||
}
|
||||
|
||||
/** Enum for specifying stop loss and take profit distances. */
|
||||
enum ProtoOASymbolDistanceType {
|
||||
SYMBOL_DISTANCE_IN_POINTS = 1;
|
||||
SYMBOL_DISTANCE_IN_PERCENTAGE = 2;
|
||||
}
|
||||
|
||||
/** Enum for specifying type of minimum trading commission. */
|
||||
enum ProtoOAMinCommissionType {
|
||||
CURRENCY = 1;
|
||||
QUOTE_CURRENCY = 2;
|
||||
}
|
||||
|
||||
/** Enum for specifying symbol trading mode. */
|
||||
enum ProtoOATradingMode {
|
||||
ENABLED = 0;
|
||||
DISABLED_WITHOUT_PENDINGS_EXECUTION = 1;
|
||||
DISABLED_WITH_PENDINGS_EXECUTION = 2;
|
||||
CLOSE_ONLY_MODE = 3;
|
||||
}
|
||||
|
||||
/** Enum for specifying SWAP calculation type for symbol. */
|
||||
enum ProtoOASwapCalculationType {
|
||||
PIPS = 0; //Specifies type of SWAP computation as PIPS (0)
|
||||
PERCENTAGE = 1; //Specifies type of SWAP computation as PERCENTAGE (1, annual, in percent)
|
||||
POINTS = 2; // Specifies type of SWAP computation as POINTS (2)
|
||||
}
|
||||
|
||||
/** Enum for specifying access right for a trader. */
|
||||
enum ProtoOAAccessRights {
|
||||
FULL_ACCESS = 0; // Enable all trading.
|
||||
CLOSE_ONLY = 1; // Only closing trading request are enabled.
|
||||
NO_TRADING = 2; // View only access.
|
||||
NO_LOGIN = 3; // No access.
|
||||
}
|
||||
|
||||
/** Enum for specifying margin calculation type for an account. */
|
||||
enum ProtoOATotalMarginCalculationType {
|
||||
MAX = 0;
|
||||
SUM = 1;
|
||||
NET = 2;
|
||||
}
|
||||
|
||||
/** Enum for specifying type of an account. */
|
||||
enum ProtoOAAccountType {
|
||||
HEDGED = 0; // Allows multiple positions on a trading account for a symbol.
|
||||
NETTED = 1; // Only one position per symbol is allowed on a trading account.
|
||||
SPREAD_BETTING = 2; // Spread betting type account.
|
||||
}
|
||||
|
||||
/** Trading account entity. */
|
||||
message ProtoOATrader {
|
||||
required int64 ctidTraderAccountId = 1; // The unique Trader's Account ID used to match the responses to the Trader's Account.
|
||||
required int64 balance = 2; // Current account balance.
|
||||
optional int64 balanceVersion = 3; // Balance version used to identify the final balance. Increments each time when the trader's account balance is changed.
|
||||
optional int64 managerBonus = 4; // Amount of broker's bonus allocated to the account.
|
||||
optional int64 ibBonus = 5; // Amount of introducing broker bonus allocated to the account.
|
||||
optional int64 nonWithdrawableBonus = 6; // Broker's bonus that cannot be withdrew from the account as cash.
|
||||
optional ProtoOAAccessRights accessRights = 7 [default = FULL_ACCESS]; // Access rights that an owner has to the account in cTrader platform. See ProtoOAAccessRights for details.
|
||||
required int64 depositAssetId = 8; // Deposit currency of the account.
|
||||
optional bool swapFree = 9; // If TRUE then account is Shariah compliant.
|
||||
optional uint32 leverageInCents = 10; // Account leverage (e.g. If leverage = 1:50 then value = 5000).
|
||||
optional ProtoOATotalMarginCalculationType totalMarginCalculationType = 11; // Margin computation type for the account (MAX, SUM, NET).
|
||||
optional uint32 maxLeverage = 12; // Maximum allowed leverage for the account. Used as validation when a Trader can change leverage value.
|
||||
optional bool frenchRisk = 13 [deprecated = true]; // If TRUE then account is AMF compliant. Use isLimitedRisk and limitedRiskMarginCalculationStrategy.
|
||||
optional int64 traderLogin = 14; // ID of the account that is unique per server (Broker).
|
||||
optional ProtoOAAccountType accountType = 15 [default = HEDGED]; // Account type: HEDGED, NETTED, etc.
|
||||
optional string brokerName = 16; // Some whitelabel assigned to trader by broker at the moment of account creation.
|
||||
optional int64 registrationTimestamp = 17; // The Unix timestamp in milliseconds of the account registration. Should be used as minimal date in historical data requests.
|
||||
optional bool isLimitedRisk = 18; // If TRUE then account is compliant to use specific margin calculation strategy. Such accounts are require to have guaranteed stop loss on all positions.
|
||||
optional ProtoOALimitedRiskMarginCalculationStrategy limitedRiskMarginCalculationStrategy = 19 [default = ACCORDING_TO_LEVERAGE]; // Special strategy used in margin calculations for this account (if account isLimitedRisk).
|
||||
optional uint32 moneyDigits = 20; // Specifies the exponent of the monetary values. E.g. moneyDigits = 8 must be interpret as business value multiplied by 10^8, then real balance would be 10053099944 / 10^8 = 100.53099944. Affects balance, managerBonus, ibBonus, nonWithdrawableBonus.
|
||||
optional bool fairStopOut = 21; // If TRUE - Position is fully closed on Stop Out, if FALSE - smart (partial closing) Stop Out is applied, if unspecified - Stop Out format is determined by Broker.
|
||||
optional ProtoOAStopOutStrategy stopOutStrategy = 22 [default = MOST_MARGIN_USED_FIRST]; //The Stop Out strategy that is used for this Trader. The Trader can change the value in the cTrader UI if this option is not disabled by the Broker
|
||||
}
|
||||
|
||||
/** Position status ENUM. */
|
||||
enum ProtoOAPositionStatus {
|
||||
POSITION_STATUS_OPEN = 1;
|
||||
POSITION_STATUS_CLOSED = 2;
|
||||
POSITION_STATUS_CREATED = 3; // Empty position is created for pending order.
|
||||
POSITION_STATUS_ERROR = 4;
|
||||
}
|
||||
|
||||
/** Trader side ENUM. Used for order, position, deal. */
|
||||
enum ProtoOATradeSide {
|
||||
BUY = 1;
|
||||
SELL = 2;
|
||||
}
|
||||
|
||||
/** Order type ENUM. */
|
||||
enum ProtoOAOrderType {
|
||||
MARKET = 1;
|
||||
LIMIT = 2;
|
||||
STOP = 3;
|
||||
STOP_LOSS_TAKE_PROFIT = 4;
|
||||
MARKET_RANGE = 5;
|
||||
STOP_LIMIT = 6;
|
||||
}
|
||||
|
||||
/** Order's time in force ENUM. */
|
||||
enum ProtoOATimeInForce {
|
||||
GOOD_TILL_DATE = 1;
|
||||
GOOD_TILL_CANCEL = 2;
|
||||
IMMEDIATE_OR_CANCEL = 3;
|
||||
FILL_OR_KILL = 4;
|
||||
MARKET_ON_OPEN = 5;
|
||||
}
|
||||
|
||||
/** Order status ENUM. */
|
||||
enum ProtoOAOrderStatus {
|
||||
ORDER_STATUS_ACCEPTED = 1; // Order request validated and accepted for execution.
|
||||
ORDER_STATUS_FILLED = 2; // Order is fully filled.
|
||||
ORDER_STATUS_REJECTED = 3; // Order is rejected due to validation.
|
||||
ORDER_STATUS_EXPIRED = 4; // Order expired. Might be valid for orders with partially filled volume that were expired on LP.
|
||||
ORDER_STATUS_CANCELLED = 5; // Order is cancelled. Might be valid for orders with partially filled volume that were cancelled by LP.
|
||||
}
|
||||
|
||||
/** Stop Order and Stop Loss triggering method ENUM. */
|
||||
enum ProtoOAOrderTriggerMethod {
|
||||
TRADE = 1; // Stop Order: buy is triggered by ask, sell by bid; Stop Loss Order: for buy position is triggered by bid and for sell position by ask.
|
||||
OPPOSITE = 2; // Stop Order: buy is triggered by bid, sell by ask; Stop Loss Order: for buy position is triggered by ask and for sell position by bid.
|
||||
DOUBLE_TRADE = 3; // The same as TRADE, but trigger is checked after the second consecutive tick.
|
||||
DOUBLE_OPPOSITE = 4; // The same as OPPOSITE, but trigger is checked after the second consecutive tick.
|
||||
}
|
||||
|
||||
/** Trade position entity. */
|
||||
message ProtoOAPosition {
|
||||
required int64 positionId = 1; // The unique ID of the position. Note: trader might have two positions with the same id if positions are taken from accounts from different brokers.
|
||||
required ProtoOATradeData tradeData = 2; // Position details. See ProtoOATradeData for details.
|
||||
required ProtoOAPositionStatus positionStatus = 3; // Current status of the position.
|
||||
required int64 swap = 4; // Total amount of charged swap on open position.
|
||||
optional double price = 5; // VWAP price of the position based on all executions (orders) linked to the position.
|
||||
optional double stopLoss = 6; // Current stop loss price.
|
||||
optional double takeProfit = 7; // Current take profit price.
|
||||
optional int64 utcLastUpdateTimestamp = 8; // The Unix time in milliseconds of the last change of the position, including amend SL/TP of the position, execution of related order, cancel or related order, etc.
|
||||
optional int64 commission = 9; // Current unrealized commission related to the position.
|
||||
optional double marginRate = 10; // Rate for used margin computation. Represented as Base/Deposit.
|
||||
optional int64 mirroringCommission = 11; // Amount of unrealized commission related to following of strategy provider.
|
||||
optional bool guaranteedStopLoss = 12; // If TRUE then position's stop loss is guaranteedStopLoss.
|
||||
optional uint64 usedMargin = 13; // Amount of margin used for the position in deposit currency.
|
||||
optional ProtoOAOrderTriggerMethod stopLossTriggerMethod = 14 [default = TRADE]; // Stop trigger method for SL/TP of the position.
|
||||
optional uint32 moneyDigits = 15; // Specifies the exponent of the monetary values. E.g. moneyDigits = 8 must be interpret as business value multiplied by 10^8, then real balance would be 10053099944 / 10^8 = 100.53099944. Affects swap, commission, mirroringCommission, usedMargin.
|
||||
optional bool trailingStopLoss = 16; //If TRUE then the Trailing Stop Loss is applied.
|
||||
}
|
||||
|
||||
/** Position/order trading details entity. */
|
||||
message ProtoOATradeData {
|
||||
required int64 symbolId = 1; // The unique identifier of the symbol in specific server environment within cTrader platform. Different brokers might have different IDs.
|
||||
required int64 volume = 2; // Volume in cents (e.g. 1000 in protocol means 10.00 units).
|
||||
required ProtoOATradeSide tradeSide = 3; // Buy, Sell.
|
||||
optional int64 openTimestamp = 4; // The Unix time in milliseconds when position was opened or order was created.
|
||||
optional string label = 5; // Text label specified during order request.
|
||||
optional bool guaranteedStopLoss = 6; // If TRUE then position/order stop loss is guaranteedStopLoss.
|
||||
optional string comment = 7; // User-specified comment.
|
||||
optional string measurementUnits = 8; // Specifies the units in which the Symbol is denominated.
|
||||
optional uint64 closeTimestamp = 9; // The Unix time in milliseconds when a Position was closed
|
||||
}
|
||||
|
||||
/** Trade order entity. */
|
||||
message ProtoOAOrder {
|
||||
required int64 orderId = 1; // The unique ID of the order. Note: trader might have two orders with the same id if orders are taken from accounts from different brokers.
|
||||
required ProtoOATradeData tradeData = 2; // Detailed trader data.
|
||||
required ProtoOAOrderType orderType = 3; // Order type.
|
||||
required ProtoOAOrderStatus orderStatus = 4; // Order status.
|
||||
optional int64 expirationTimestamp = 6; // The Unix time in milliseconds of expiration if the order has time in force GTD.
|
||||
optional double executionPrice = 7; // Price at which an order was executed. For order with FILLED status.
|
||||
optional int64 executedVolume = 8; // Part of the volume that was filled in cents (e.g. 1000 in protocol means 10.00 units).
|
||||
optional int64 utcLastUpdateTimestamp = 9; // The Unix time in milliseconds of the last update of the order.
|
||||
optional double baseSlippagePrice = 10; // Used for Market Range order with combination of slippageInPoints to specify price range were order can be executed.
|
||||
optional int64 slippageInPoints = 11; // Used for Market Range and STOP_LIMIT orders to to specify price range were order can be executed.
|
||||
optional bool closingOrder = 12; // If TRUE then the order is closing part of whole position. Must have specified positionId.
|
||||
optional double limitPrice = 13; // Valid only for LIMIT orders.
|
||||
optional double stopPrice = 14; // Valid only for STOP and STOP_LIMIT orders.
|
||||
optional double stopLoss = 15; // Absolute stopLoss price.
|
||||
optional double takeProfit = 16; // Absolute takeProfit price.
|
||||
optional string clientOrderId = 17; // Optional ClientOrderId. Max Length = 50 chars.
|
||||
optional ProtoOATimeInForce timeInForce = 18 [default = IMMEDIATE_OR_CANCEL]; // Order's time in force. Depends on order type.
|
||||
optional int64 positionId = 19; // ID of the position linked to the order (e.g. closing order, order that increase volume of a specific position, etc.).
|
||||
optional int64 relativeStopLoss = 20; // Relative stopLoss that can be specified instead of absolute as one. Specified in 1/100000 of unit of a price. (e.g. 123000 in protocol means 1.23, 53423782 means 534.23782) For BUY stopLoss = entryPrice - relativeStopLoss, for SELL stopLoss = entryPrice + relativeStopLoss.
|
||||
optional int64 relativeTakeProfit = 21; // Relative takeProfit that can be specified instead of absolute one. Specified in 1/100000 of unit of a price. (e.g. 123000 in protocol means 1.23, 53423782 means 534.23782) ForBUY takeProfit = entryPrice + relativeTakeProfit, for SELL takeProfit = entryPrice - relativeTakeProfit.
|
||||
optional bool isStopOut = 22; // If TRUE then order was stopped out from server side.
|
||||
optional bool trailingStopLoss = 23; // If TRUE then order is trailingStopLoss. Valid for STOP_LOSS_TAKE_PROFIT order.
|
||||
optional ProtoOAOrderTriggerMethod stopTriggerMethod = 24 [default = TRADE]; // Trigger method for the order. Valid only for STOP and STOP_LIMIT orders.
|
||||
}
|
||||
|
||||
/** Execution event type ENUM. */
|
||||
enum ProtoOAExecutionType {
|
||||
ORDER_ACCEPTED = 2; // Order passed validation.
|
||||
ORDER_FILLED = 3; // Order filled.
|
||||
ORDER_REPLACED = 4; // Pending order is changed with a new one.
|
||||
ORDER_CANCELLED = 5; // Order cancelled.
|
||||
ORDER_EXPIRED = 6; // Order with GTD time in force is expired.
|
||||
ORDER_REJECTED = 7; // Order is rejected due to validations.
|
||||
ORDER_CANCEL_REJECTED = 8; // Cancel order request is rejected.
|
||||
SWAP = 9; // Type related to SWAP execution events.
|
||||
DEPOSIT_WITHDRAW = 10; // Type related to event of deposit or withdrawal cash flow operation.
|
||||
ORDER_PARTIAL_FILL = 11; // Order is partially filled.
|
||||
BONUS_DEPOSIT_WITHDRAW = 12; // Type related to event of bonus deposit or bonus withdrawal.
|
||||
}
|
||||
|
||||
/** Bonus deposit/withdrawal entity. */
|
||||
message ProtoOABonusDepositWithdraw {
|
||||
required ProtoOAChangeBonusType operationType = 1; // Type of the operation. Deposit/Withdrawal.
|
||||
required int64 bonusHistoryId = 2; // The unique ID of the bonus deposit/withdrawal operation.
|
||||
required int64 managerBonus = 3; // Total amount of broker's bonus after the operation.
|
||||
required int64 managerDelta = 4; // Amount of bonus deposited/withdrew by manager.
|
||||
required int64 ibBonus = 5; // Total amount of introducing broker's bonus after the operation.
|
||||
required int64 ibDelta = 6; // Amount of bonus deposited/withdrew by introducing broker.
|
||||
required int64 changeBonusTimestamp = 7; // The Unix time in milliseconds when the bonus operation was executed.
|
||||
optional string externalNote = 8; // Note added to operation. Visible to the trader.
|
||||
optional int64 introducingBrokerId = 9; // ID of introducing broker who deposited/withdrew bonus.
|
||||
optional uint32 moneyDigits = 10; // Specifies the exponent of the monetary values. E.g. moneyDigits = 8 must be interpret as business value multiplied by 10^8, then real balance would be 10053099944 / 10^8 = 100.53099944. Affects managerBonus, managerDelta, ibBonus, ibDelta.
|
||||
}
|
||||
|
||||
/** Bonus operation type ENUM. */
|
||||
enum ProtoOAChangeBonusType {
|
||||
BONUS_DEPOSIT = 0;
|
||||
BONUS_WITHDRAW = 1;
|
||||
}
|
||||
|
||||
/** Account deposit/withdrawal operation entity. */
|
||||
message ProtoOADepositWithdraw {
|
||||
required ProtoOAChangeBalanceType operationType = 1; // Type of the operation. Deposit/Withdrawal.
|
||||
required int64 balanceHistoryId = 2; // The unique ID of the deposit/withdrawal operation.
|
||||
required int64 balance = 3; // Account balance after the operation was executed.
|
||||
required int64 delta = 4; // Amount of deposit/withdrawal operation.
|
||||
required int64 changeBalanceTimestamp = 5; // The Unix time in milliseconds when deposit/withdrawal operation was executed.
|
||||
optional string externalNote = 6; // Note added to operation. Visible to the trader.
|
||||
optional int64 balanceVersion = 7; // Balance version used to identify the final balance. Increments each time when the trader's account balance is changed.
|
||||
optional int64 equity = 8; // Total account's equity after balance operation was executed.
|
||||
optional uint32 moneyDigits = 9; // Specifies the exponent of the monetary values. E.g. moneyDigits = 8 must be interpret as business value multiplied by 10^8, then real balance would be 10053099944 / 10^8 = 100.53099944. Affects balance, delta, equity.
|
||||
}
|
||||
|
||||
/** Balance operation entity. Covers all cash movement operations related to account, trading, IB operations, mirroring, etc. */
|
||||
enum ProtoOAChangeBalanceType {
|
||||
BALANCE_DEPOSIT = 0; // Cash deposit.
|
||||
BALANCE_WITHDRAW = 1; // Cash withdrawal.
|
||||
BALANCE_DEPOSIT_STRATEGY_COMMISSION_INNER = 3; // Received mirroring commission.
|
||||
BALANCE_WITHDRAW_STRATEGY_COMMISSION_INNER = 4; // Paid mirroring commission.
|
||||
BALANCE_DEPOSIT_IB_COMMISSIONS = 5; // For IB account. Commissions paid by trader.
|
||||
BALANCE_WITHDRAW_IB_SHARED_PERCENTAGE = 6; // For IB account. Withdrawal of commissions shared with broker.
|
||||
BALANCE_DEPOSIT_IB_SHARED_PERCENTAGE_FROM_SUB_IB = 7; // For IB account. Commissions paid by sub-ibs.
|
||||
BALANCE_DEPOSIT_IB_SHARED_PERCENTAGE_FROM_BROKER = 8; // For IB account. Commissions paid by broker.
|
||||
BALANCE_DEPOSIT_REBATE = 9; // Deposit rebate for trading volume for period.
|
||||
BALANCE_WITHDRAW_REBATE = 10; // Withdrawal of rebate.
|
||||
BALANCE_DEPOSIT_STRATEGY_COMMISSION_OUTER = 11; // Mirroring commission.
|
||||
BALANCE_WITHDRAW_STRATEGY_COMMISSION_OUTER = 12; // Mirroring commission.
|
||||
BALANCE_WITHDRAW_BONUS_COMPENSATION = 13; // For IB account. Share commission with the Broker.
|
||||
BALANCE_WITHDRAW_IB_SHARED_PERCENTAGE_TO_BROKER = 14; // IB commissions.
|
||||
BALANCE_DEPOSIT_DIVIDENDS = 15; // Deposit dividends payments.
|
||||
BALANCE_WITHDRAW_DIVIDENDS = 16; // Negative dividend charge for short position.
|
||||
BALANCE_WITHDRAW_GSL_CHARGE = 17; // Charge for guaranteedStopLoss.
|
||||
BALANCE_WITHDRAW_ROLLOVER = 18; // Charge of rollover fee for Shariah compliant accounts.
|
||||
BALANCE_DEPOSIT_NONWITHDRAWABLE_BONUS = 19; // Broker's operation to deposit bonus.
|
||||
BALANCE_WITHDRAW_NONWITHDRAWABLE_BONUS = 20; // Broker's operation to withdrawal bonus.
|
||||
BALANCE_DEPOSIT_SWAP = 21; // Deposits of negative SWAP.
|
||||
BALANCE_WITHDRAW_SWAP = 22; // SWAP charges.
|
||||
|
||||
BALANCE_DEPOSIT_MANAGEMENT_FEE = 27; // Mirroring commission.
|
||||
BALANCE_WITHDRAW_MANAGEMENT_FEE = 28; // Mirroring commission. Deprecated since 7.1 in favor of BALANCE_WITHDRAW_COPY_FEE (34).
|
||||
BALANCE_DEPOSIT_PERFORMANCE_FEE = 29; // Mirroring commission.
|
||||
BALANCE_WITHDRAW_FOR_SUBACCOUNT = 30; // Withdraw for subaccount creation (cTrader Copy).
|
||||
BALANCE_DEPOSIT_TO_SUBACCOUNT = 31; // Deposit to subaccount on creation (cTrader Copy).
|
||||
BALANCE_WITHDRAW_FROM_SUBACCOUNT = 32; // Manual user's withdraw from subaccount (cTrader Copy), to parent account.
|
||||
BALANCE_DEPOSIT_FROM_SUBACCOUNT = 33; // Manual user's deposit to subaccount (cTrader Copy), from parent account.
|
||||
BALANCE_WITHDRAW_COPY_FEE = 34; // Withdrawal fees to Strategy Provider.
|
||||
BALANCE_WITHDRAW_INACTIVITY_FEE = 35; // Withdraw of inactivity fee from the balance.
|
||||
BALANCE_DEPOSIT_TRANSFER = 36; // Deposit within the same server (from another account).
|
||||
BALANCE_WITHDRAW_TRANSFER = 37; // Withdraw within the same server (to another account).
|
||||
BALANCE_DEPOSIT_CONVERTED_BONUS = 38; // Bonus being converted from virtual bonus to real deposit.
|
||||
BALANCE_DEPOSIT_NEGATIVE_BALANCE_PROTECTION = 39; // Applies if negative balance protection is configured by broker, should make balance = 0.
|
||||
}
|
||||
|
||||
/** Execution entity. */
|
||||
message ProtoOADeal {
|
||||
required int64 dealId = 1; // The unique ID of the execution deal.
|
||||
required int64 orderId = 2; // Source order of the deal.
|
||||
required int64 positionId = 3; // Source position of the deal.
|
||||
required int64 volume = 4; // Volume sent for execution, in cents.
|
||||
required int64 filledVolume = 5; // Filled volume, in cents.
|
||||
required int64 symbolId = 6; // The unique identifier of the symbol in specific server environment within cTrader platform. Different servers have different IDs.
|
||||
required int64 createTimestamp = 7; // The Unix time in milliseconds when the deal was sent for execution.
|
||||
required int64 executionTimestamp = 8; // The Unix time in milliseconds when the deal was executed.
|
||||
optional int64 utcLastUpdateTimestamp = 9; // The Unix time in milliseconds when the deal was created, executed or rejected.
|
||||
optional double executionPrice = 10; // Execution price.
|
||||
required ProtoOATradeSide tradeSide = 11; // Buy/Sell.
|
||||
required ProtoOADealStatus dealStatus = 12; // Status of the deal.
|
||||
optional double marginRate = 13; // Rate for used margin computation. Represented as Base/Deposit.
|
||||
optional int64 commission = 14; // Amount of trading commission associated with the deal.
|
||||
optional double baseToUsdConversionRate = 15; // Base to USD conversion rate on the time of deal execution.
|
||||
optional ProtoOAClosePositionDetail closePositionDetail = 16; // Closing position detail. Valid only for closing deal.
|
||||
optional uint32 moneyDigits = 17; // Specifies the exponent of the monetary values. E.g. moneyDigits = 8 must be interpret as business value multiplied by 10^8, then real balance would be 10053099944 / 10^8 = 100.53099944. Affects commission.
|
||||
}
|
||||
|
||||
/** Deal details for ProtoOADealOffsetListReq. */
|
||||
message ProtoOADealOffset {
|
||||
required int64 dealId = 1; // The unique ID of the execution Deal.
|
||||
required int64 volume = 2; // Matched volume, in cents.
|
||||
optional int64 executionTimestamp = 3; // The Unix time in milliseconds when the offset Deal was executed.
|
||||
optional double executionPrice = 4; // Execution price of the offset Deal.
|
||||
}
|
||||
|
||||
/** Deal status ENUM. */
|
||||
enum ProtoOADealStatus {
|
||||
FILLED = 2; // Deal filled.
|
||||
PARTIALLY_FILLED = 3; // Deal is partially filled.
|
||||
REJECTED = 4; // Deal is correct but was rejected by liquidity provider (e.g. no liquidity).
|
||||
INTERNALLY_REJECTED = 5; // Deal rejected by server (e.g. no price quotes).
|
||||
ERROR = 6; // Deal is rejected by LP due to error (e.g. symbol is unknown).
|
||||
MISSED = 7; // Liquidity provider did not sent response on the deal during specified execution time period.
|
||||
}
|
||||
|
||||
/** Trading details for closing deal. */
|
||||
message ProtoOAClosePositionDetail {
|
||||
required double entryPrice = 1; // Position price at the moment of filling the closing order.
|
||||
required int64 grossProfit = 2; // Amount of realized gross profit after closing deal execution.
|
||||
required int64 swap = 3; // Amount of realized swap related to closed volume.
|
||||
required int64 commission = 4; // Amount of realized commission related to closed volume.
|
||||
required int64 balance = 5; // Account balance after closing deal execution.
|
||||
optional double quoteToDepositConversionRate = 6; // Quote/Deposit currency conversion rate on the time of closing deal execution.
|
||||
optional int64 closedVolume = 7; // Closed volume in cents.
|
||||
optional int64 balanceVersion = 8; // Balance version of the account related to closing deal operation.
|
||||
optional uint32 moneyDigits = 9; // Specifies the exponent of the monetary values. E.g. moneyDigits = 8 must be interpret as business value multiplied by 10^8, then real balance would be 10053099944 / 10^8 = 100.53099944. Affects grossProfit, swap, commission, balance, pnlConversionFee.
|
||||
optional int64 pnlConversionFee = 10; // Fee for conversion applied to the Deal in account's ccy when trader symbol's quote asset id <> ProtoOATrader.depositAssetId.
|
||||
}
|
||||
|
||||
/** Trendbar period ENUM. */
|
||||
enum ProtoOATrendbarPeriod {
|
||||
M1 = 1;
|
||||
M2 = 2;
|
||||
M3 = 3;
|
||||
M4 = 4;
|
||||
M5 = 5;
|
||||
M10 = 6;
|
||||
M15 = 7;
|
||||
M30 = 8;
|
||||
H1 = 9;
|
||||
H4 = 10;
|
||||
H12 = 11;
|
||||
D1 = 12;
|
||||
W1 = 13;
|
||||
MN1 = 14;
|
||||
}
|
||||
|
||||
/** Historical Trendbar entity. */
|
||||
message ProtoOATrendbar {
|
||||
required int64 volume = 3; // Bar volume in ticks.
|
||||
optional ProtoOATrendbarPeriod period = 4 [default = M1]; // Bar period.
|
||||
optional int64 low = 5; // Low price of the bar.
|
||||
optional uint64 deltaOpen = 6; // Delta between open and low price. open = low + deltaOpen.
|
||||
optional uint64 deltaClose = 7; // Delta between close and low price. close = low + deltaClose.
|
||||
optional uint64 deltaHigh = 8; // Delta between high and low price. high = low + deltaHigh.
|
||||
optional uint32 utcTimestampInMinutes = 9; // The Unix time in minutes of the bar, equal to the timestamp of the open tick.
|
||||
}
|
||||
|
||||
/** Expected margin computation entity. */
|
||||
message ProtoOAExpectedMargin {
|
||||
required int64 volume = 1; // Volume in cents used for computation of expected margin.
|
||||
required int64 buyMargin = 2; // Buy margin amount.
|
||||
required int64 sellMargin = 3; // Sell margin amount.
|
||||
}
|
||||
|
||||
/** Price quote type. */
|
||||
enum ProtoOAQuoteType {
|
||||
BID = 1;
|
||||
ASK = 2;
|
||||
}
|
||||
|
||||
/** Historical tick data type. */
|
||||
message ProtoOATickData {
|
||||
required int64 timestamp = 1; // The Unix time in milliseconds of the tick. See ProtoOAGetTickDataRes.tickData for details.
|
||||
required int64 tick = 2; // Tick price.
|
||||
}
|
||||
|
||||
/** Open API application permission in regards to token ENUM. */
|
||||
enum ProtoOAClientPermissionScope {
|
||||
SCOPE_VIEW = 0; // Allows to use only view commends. Trade is prohibited.
|
||||
SCOPE_TRADE = 1; // Allows to use all commands.
|
||||
}
|
||||
|
||||
/** Trader profile entity. Empty due to GDPR. */
|
||||
message ProtoOACtidProfile {
|
||||
required int64 userId = 1;
|
||||
}
|
||||
|
||||
/** Trader account entity. */
|
||||
message ProtoOACtidTraderAccount {
|
||||
required uint64 ctidTraderAccountId = 1; // Unique identifier of the trader's account. Used to match responses to trader's accounts.cTrader platform. Different brokers might have different ids
|
||||
optional bool isLive = 2; // If TRUE then the account is belong to Live environment and live host must be used to authorize it
|
||||
optional int64 traderLogin = 3; // TraderLogin for a specific account. Value is displayed on Client App UI
|
||||
optional int64 lastClosingDealTimestamp = 4; // The Unix time in milliseconds of the last ProtoOAClosePositionDetail happened to this account.
|
||||
optional int64 lastBalanceUpdateTimestamp = 5; // The Unix time in milliseconds of the last ProtoOADepositWithdraw happened to this account.
|
||||
optional string brokerTitleShort = 6; // The name of the broker to which the account belongs to. Shortened to be displayed in the UI.
|
||||
}
|
||||
|
||||
/** Asset class entity. */
|
||||
message ProtoOAAssetClass {
|
||||
optional int64 id = 1; // Unique asset ID.
|
||||
optional string name = 2; // Asset class name.
|
||||
optional double sortingNumber = 3; // The number used for sorting Asset Classes in the UI (lowest number should appear at the top).
|
||||
}
|
||||
|
||||
/** Depth of market entity. */
|
||||
message ProtoOADepthQuote {
|
||||
required uint64 id = 1; // Quote ID.
|
||||
required uint64 size = 3; // Quote size in cents.
|
||||
optional uint64 bid = 4; // Bid price for bid quotes.
|
||||
optional uint64 ask = 5; // Ask price for ask quotes.
|
||||
}
|
||||
|
||||
/** Margin call entity, specifies threshold for exact margin call type. Only 3 instances of margin calls are supported, identified by marginCallType. See ProtoOANotificationType for details. */
|
||||
message ProtoOAMarginCall {
|
||||
required ProtoOANotificationType marginCallType = 1; // Type of margin call. All margin calls are similar, only difference is in marginLevelThreshold.
|
||||
required double marginLevelThreshold = 2; // Margin level threshold for margin call.
|
||||
optional int64 utcLastUpdateTimestamp = 3; // The Unix time in milliseconds of the last update of the margin call.
|
||||
}
|
||||
|
||||
/** Type of notification, currently only 3 instances of marginCall are supported. */
|
||||
enum ProtoOANotificationType {
|
||||
MARGIN_LEVEL_THRESHOLD_1 = 61; // one of three margin calls, they are all similar.
|
||||
MARGIN_LEVEL_THRESHOLD_2 = 62; // one of three margin calls, they are all similar.
|
||||
MARGIN_LEVEL_THRESHOLD_3 = 63; // one of three margin calls, they are all similar.
|
||||
}
|
||||
|
||||
/** Error code ENUM. */
|
||||
enum ProtoOAErrorCode {
|
||||
// Authorization
|
||||
OA_AUTH_TOKEN_EXPIRED = 1; // When token used for account authorization is expired.
|
||||
ACCOUNT_NOT_AUTHORIZED = 2; // When account is not authorized.
|
||||
RET_NO_SUCH_LOGIN = 12; // When such account no longer exists.
|
||||
ALREADY_LOGGED_IN = 14; // When client tries to authorize after it was already authorized.
|
||||
RET_ACCOUNT_DISABLED = 64; // When account is disabled.
|
||||
CH_CLIENT_AUTH_FAILURE = 101; // Open API client is not activated or wrong client credentials.
|
||||
CH_CLIENT_NOT_AUTHENTICATED = 102; // When a command is sent for not authorized Open API client.
|
||||
CH_CLIENT_ALREADY_AUTHENTICATED = 103; // Client is trying to authenticate twice.
|
||||
CH_ACCESS_TOKEN_INVALID = 104; // Access token is invalid.
|
||||
CH_SERVER_NOT_REACHABLE = 105; // Trading service is not available.
|
||||
CH_CTID_TRADER_ACCOUNT_NOT_FOUND = 106; // Trading account is not found.
|
||||
CH_OA_CLIENT_NOT_FOUND = 107; // Could not find this client id.
|
||||
|
||||
// General
|
||||
REQUEST_FREQUENCY_EXCEEDED = 108; // Request frequency is reached.
|
||||
SERVER_IS_UNDER_MAINTENANCE = 109; // Server is under maintenance.
|
||||
CHANNEL_IS_BLOCKED = 110; // Operations are not allowed for this account.
|
||||
CONNECTIONS_LIMIT_EXCEEDED = 67; // Limit of connections is reached for this Open API client.
|
||||
WORSE_GSL_NOT_ALLOWED = 68; // Not allowed to increase risk for Positions with Guaranteed Stop Loss.
|
||||
SYMBOL_HAS_HOLIDAY = 69; // Trading disabled because symbol has holiday.
|
||||
|
||||
// Pricing
|
||||
NOT_SUBSCRIBED_TO_SPOTS = 112; // When trying to subscribe to depth, trendbars, etc. without spot subscription.
|
||||
ALREADY_SUBSCRIBED = 113; // When subscription is requested for an active.
|
||||
SYMBOL_NOT_FOUND = 114; // Symbol not found.
|
||||
UNKNOWN_SYMBOL = 115; // Note: to be merged with SYMBOL_NOT_FOUND.
|
||||
INCORRECT_BOUNDARIES = 35; // When requested period (from,to) is too large or invalid values are set to from/to.
|
||||
|
||||
// Trading
|
||||
NO_QUOTES = 117; // Trading cannot be done as not quotes are available. Applicable for Book B.
|
||||
NOT_ENOUGH_MONEY = 118; // Not enough funds to allocate margin.
|
||||
MAX_EXPOSURE_REACHED = 119; // Max exposure limit is reached for a {trader, symbol, side}.
|
||||
POSITION_NOT_FOUND = 120; // Position not found.
|
||||
ORDER_NOT_FOUND = 121; // Order not found.
|
||||
POSITION_NOT_OPEN = 122; // When trying to close a position that it is not open.
|
||||
POSITION_LOCKED = 123; // Position in the state that does not allow to perform an operation.
|
||||
TOO_MANY_POSITIONS = 124; // Trading account reached its limit for max number of open positions and orders.
|
||||
TRADING_BAD_VOLUME = 125; // Invalid volume.
|
||||
TRADING_BAD_STOPS = 126; // Invalid stop price.
|
||||
TRADING_BAD_PRICES = 127; // Invalid price (e.g. negative).
|
||||
TRADING_BAD_STAKE = 128; // Invalid stake volume (e.g. negative).
|
||||
PROTECTION_IS_TOO_CLOSE_TO_MARKET = 129; // Invalid protection prices.
|
||||
TRADING_BAD_EXPIRATION_DATE = 130; // Invalid expiration.
|
||||
PENDING_EXECUTION = 131; // Unable to apply changes as position has an order under execution.
|
||||
TRADING_DISABLED = 132; // Trading is blocked for the symbol.
|
||||
TRADING_NOT_ALLOWED = 133; // Trading account is in read only mode.
|
||||
UNABLE_TO_CANCEL_ORDER = 134; // Unable to cancel order.
|
||||
UNABLE_TO_AMEND_ORDER = 135; // Unable to amend order.
|
||||
SHORT_SELLING_NOT_ALLOWED = 136; // Short selling is not allowed.
|
||||
}
|
||||
|
||||
enum ProtoOALimitedRiskMarginCalculationStrategy {
|
||||
ACCORDING_TO_LEVERAGE = 0;
|
||||
ACCORDING_TO_GSL = 1;
|
||||
ACCORDING_TO_GSL_AND_LEVERAGE = 2;
|
||||
}
|
||||
|
||||
message ProtoOAHoliday {
|
||||
required int64 holidayId = 1; // Unique ID of holiday.
|
||||
required string name = 2; // Name of holiday.
|
||||
optional string description = 3; // Description of holiday.
|
||||
required string scheduleTimeZone = 4; // Timezone used for holiday.
|
||||
required int64 holidayDate = 5; // Amount of days from 1st Jan 1970, multiply it by 86400000 to get Unix time in milliseconds.
|
||||
required bool isRecurring = 6; // If TRUE, then the holiday happens each year.
|
||||
optional int32 startSecond = 7; // Amount of seconds from 00:00:00 of the holiday day when holiday actually starts.
|
||||
optional int32 endSecond = 8; // Amount of seconds from 00:00:00 of the holiday day when holiday actually finishes.
|
||||
}
|
||||
|
||||
message ProtoOADynamicLeverage {
|
||||
required int64 leverageId = 1; // Unique ID of dynamic leverage.
|
||||
repeated ProtoOADynamicLeverageTier tiers = 2; // Tiers sorted by volume. Last tier's leverage is applied also to volume above specified.
|
||||
}
|
||||
|
||||
message ProtoOADynamicLeverageTier {
|
||||
required int64 volume = 1; // Max USD volume (in cents) of the Open Position (per side) to apply specified leverage. Last tier's leverage is applied also to volume above specified.
|
||||
required int32 leverage = 2; // Applied leverage.
|
||||
}
|
||||
|
||||
message ProtoOAPositionUnrealizedPnL {
|
||||
required int64 positionId = 1; // The position ID.
|
||||
required int64 grossUnrealizedPnL = 2; // The gross unrealized PnL of the position denoted in the account deposit currency.
|
||||
required int64 netUnrealizedPnL = 3; // The net unrealized PnL of the position denoted in the account deposit currency. It does not include potential closing commission.
|
||||
}
|
||||
|
||||
enum ProtoOAStopOutStrategy {//The strategy for choosing which Position to close during a Stop Out
|
||||
MOST_MARGIN_USED_FIRST = 0; //A Stop Out strategy that closes a Position with the largest Used Margin
|
||||
MOST_LOSING_FIRST = 1; //A Stop Out strategy that closes a Position with the least PnL
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
pub mod config;
|
||||
pub mod error;
|
||||
pub mod proto;
|
||||
|
||||
pub use config::{CTraderConfig, CTraderEnvironment};
|
||||
pub use error::{CTraderError, Result};
|
||||
|
||||
120
ctrader-openapi/src/proto.rs
Normal file
120
ctrader-openapi/src/proto.rs
Normal file
@@ -0,0 +1,120 @@
|
||||
//! Generated cTrader Open API protobuf types and dispatch helpers.
|
||||
//!
|
||||
//! All types are generated by prost from the 4 vendored `.proto` files.
|
||||
//! The `PayloadType` constants and dispatch helpers below map the
|
||||
//! `payloadType` discriminator in `ProtoMessage` to concrete message types.
|
||||
|
||||
// Include prost-generated code. The proto files don't declare a `package`,
|
||||
// so prost emits everything into the root (unnamed) module.
|
||||
include!(concat!(env!("OUT_DIR"), "/_.rs"));
|
||||
|
||||
// ── Payload-type constants ──────────────────────────────────────────
|
||||
// Common
|
||||
pub const PT_HEARTBEAT_EVENT: u32 = 51;
|
||||
pub const PT_ERROR_RES: u32 = 50;
|
||||
|
||||
// Application / Account auth
|
||||
pub const PT_APP_AUTH_REQ: u32 = 2100;
|
||||
pub const PT_APP_AUTH_RES: u32 = 2101;
|
||||
pub const PT_ACCOUNT_AUTH_REQ: u32 = 2102;
|
||||
pub const PT_ACCOUNT_AUTH_RES: u32 = 2103;
|
||||
|
||||
// Version
|
||||
pub const PT_VERSION_REQ: u32 = 2104;
|
||||
pub const PT_VERSION_RES: u32 = 2105;
|
||||
|
||||
// Orders
|
||||
pub const PT_NEW_ORDER_REQ: u32 = 2106;
|
||||
pub const PT_CANCEL_ORDER_REQ: u32 = 2108;
|
||||
pub const PT_AMEND_ORDER_REQ: u32 = 2109;
|
||||
pub const PT_CLOSE_POSITION_REQ: u32 = 2111;
|
||||
|
||||
// Symbols
|
||||
pub const PT_SYMBOLS_LIST_REQ: u32 = 2114;
|
||||
pub const PT_SYMBOLS_LIST_RES: u32 = 2115;
|
||||
pub const PT_SYMBOL_BY_ID_REQ: u32 = 2116;
|
||||
pub const PT_SYMBOL_BY_ID_RES: u32 = 2117;
|
||||
|
||||
// Account
|
||||
pub const PT_TRADER_REQ: u32 = 2121;
|
||||
pub const PT_TRADER_RES: u32 = 2122;
|
||||
pub const PT_RECONCILE_REQ: u32 = 2124;
|
||||
pub const PT_RECONCILE_RES: u32 = 2125;
|
||||
|
||||
// Execution & errors
|
||||
pub const PT_EXECUTION_EVENT: u32 = 2126;
|
||||
pub const PT_ORDER_ERROR_EVENT: u32 = 2132;
|
||||
|
||||
// Spot subscriptions
|
||||
pub const PT_SUBSCRIBE_SPOTS_REQ: u32 = 2127;
|
||||
pub const PT_SUBSCRIBE_SPOTS_RES: u32 = 2128;
|
||||
pub const PT_UNSUBSCRIBE_SPOTS_REQ: u32 = 2129;
|
||||
pub const PT_UNSUBSCRIBE_SPOTS_RES: u32 = 2130;
|
||||
pub const PT_SPOT_EVENT: u32 = 2131;
|
||||
|
||||
// OA error
|
||||
pub const PT_OA_ERROR_RES: u32 = 2142;
|
||||
|
||||
// Accounts by token
|
||||
pub const PT_GET_ACCOUNTS_REQ: u32 = 2149;
|
||||
pub const PT_GET_ACCOUNTS_RES: u32 = 2150;
|
||||
|
||||
// Disconnect / invalidation events
|
||||
pub const PT_CLIENT_DISCONNECT_EVENT: u32 = 2148;
|
||||
pub const PT_ACCOUNTS_TOKEN_INVALIDATED: u32 = 2147;
|
||||
pub const PT_ACCOUNT_DISCONNECT_EVENT: u32 = 2164;
|
||||
|
||||
/// Categorize a `payloadType` for logging and dispatch.
|
||||
pub fn payload_type_name(pt: u32) -> &'static str {
|
||||
match pt {
|
||||
PT_HEARTBEAT_EVENT => "HeartbeatEvent",
|
||||
PT_ERROR_RES => "ErrorRes",
|
||||
PT_APP_AUTH_REQ => "ApplicationAuthReq",
|
||||
PT_APP_AUTH_RES => "ApplicationAuthRes",
|
||||
PT_ACCOUNT_AUTH_REQ => "AccountAuthReq",
|
||||
PT_ACCOUNT_AUTH_RES => "AccountAuthRes",
|
||||
PT_VERSION_REQ => "VersionReq",
|
||||
PT_VERSION_RES => "VersionRes",
|
||||
PT_NEW_ORDER_REQ => "NewOrderReq",
|
||||
PT_CANCEL_ORDER_REQ => "CancelOrderReq",
|
||||
PT_AMEND_ORDER_REQ => "AmendOrderReq",
|
||||
PT_CLOSE_POSITION_REQ => "ClosePositionReq",
|
||||
PT_SYMBOLS_LIST_REQ => "SymbolsListReq",
|
||||
PT_SYMBOLS_LIST_RES => "SymbolsListRes",
|
||||
PT_SYMBOL_BY_ID_REQ => "SymbolByIdReq",
|
||||
PT_SYMBOL_BY_ID_RES => "SymbolByIdRes",
|
||||
PT_TRADER_REQ => "TraderReq",
|
||||
PT_TRADER_RES => "TraderRes",
|
||||
PT_RECONCILE_REQ => "ReconcileReq",
|
||||
PT_RECONCILE_RES => "ReconcileRes",
|
||||
PT_EXECUTION_EVENT => "ExecutionEvent",
|
||||
PT_ORDER_ERROR_EVENT => "OrderErrorEvent",
|
||||
PT_SUBSCRIBE_SPOTS_REQ => "SubscribeSpotsReq",
|
||||
PT_SUBSCRIBE_SPOTS_RES => "SubscribeSpotsRes",
|
||||
PT_UNSUBSCRIBE_SPOTS_REQ => "UnsubscribeSpotsReq",
|
||||
PT_UNSUBSCRIBE_SPOTS_RES => "UnsubscribeSpotsRes",
|
||||
PT_SPOT_EVENT => "SpotEvent",
|
||||
PT_OA_ERROR_RES => "OAErrorRes",
|
||||
PT_GET_ACCOUNTS_REQ => "GetAccountsReq",
|
||||
PT_GET_ACCOUNTS_RES => "GetAccountsRes",
|
||||
PT_CLIENT_DISCONNECT_EVENT => "ClientDisconnectEvent",
|
||||
PT_ACCOUNTS_TOKEN_INVALIDATED => "AccountsTokenInvalidated",
|
||||
PT_ACCOUNT_DISCONNECT_EVENT => "AccountDisconnectEvent",
|
||||
_ => "Unknown",
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the payload type is a server-initiated event
|
||||
/// (i.e. not a direct response to a client request).
|
||||
pub const fn is_event(pt: u32) -> bool {
|
||||
matches!(
|
||||
pt,
|
||||
PT_HEARTBEAT_EVENT
|
||||
| PT_EXECUTION_EVENT
|
||||
| PT_SPOT_EVENT
|
||||
| PT_ORDER_ERROR_EVENT
|
||||
| PT_CLIENT_DISCONNECT_EVENT
|
||||
| PT_ACCOUNTS_TOKEN_INVALIDATED
|
||||
| PT_ACCOUNT_DISCONNECT_EVENT
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user