static string ProtoMessageToString(ProtoMessage msg) { if (!msg.HasPayload) { return("ERROR in ProtoMessage: Corrupted execution event, no payload found"); } var _str = "ProtoMessage{"; switch ((ProtoPayloadType)msg.PayloadType) { //case ProtoPayloadType.PROTO_MESSAGE: // FIXME - was this working? // var _msg = ProtoMessage.CreateBuilder().MergeFrom(msg.Payload).Build(); // _str += ProtoMessageToString(_msg); // break; case ProtoPayloadType.PING_REQ: var _ping_req = ProtoPingReq.CreateBuilder().MergeFrom(msg.Payload).Build(); _str += "PingRequest{timestamp:" + _ping_req.Timestamp.ToString() + "}"; break; case ProtoPayloadType.PING_RES: var _ping_res = ProtoPingRes.CreateBuilder().MergeFrom(msg.Payload).Build(); _str += "PingResponse{timestamp:" + _ping_res.Timestamp + "}"; break; case ProtoPayloadType.HEARTBEAT_EVENT: var _hb = ProtoHeartbeatEvent.CreateBuilder().MergeFrom(msg.Payload).Build(); _str += "Heartbeat"; break; case ProtoPayloadType.ERROR_RES: var _err = ProtoErrorRes.CreateBuilder().MergeFrom(msg.Payload).Build(); _str += "ErrorResponse{errorCode:" + _err.ErrorCode + (_err.HasDescription ? ", description:" + _err.Description : "") + "}"; break; default: _str += OpenApiMessageToString(msg); break; } _str += (msg.HasClientMsgId ? ", clientMsgId:" + msg.ClientMsgId : "") //+ (msg.HasPayloadString ? ", payloadString:" + msg.PayloadString : "") // FIXME - was this working? + "}"; return(_str); }
public ProtoPingReq GetPingRequest(byte[] msg = null) { return(ProtoPingReq.CreateBuilder().MergeFrom(GetPayload(msg)).Build()); }
static string OpenApiMessageToString(ProtoMessage msg) { switch ((ProtoOAPayloadType)msg.PayloadType) { case ProtoOAPayloadType.OA_PING_REQ: var _ping_req = ProtoPingReq.CreateBuilder().MergeFrom(msg.Payload).Build(); return("PingRequest{timestamp:" + _ping_req.Timestamp.ToString() + "}"); break; case ProtoOAPayloadType.OA_PING_RES: var _ping_res = ProtoPingRes.CreateBuilder().MergeFrom(msg.Payload).Build(); return("PingResponse{timestamp:" + _ping_res.Timestamp + "}"); break; case ProtoOAPayloadType.OA_AUTH_REQ: var _auth_req = ProtoOAAuthReq.CreateBuilder().MergeFrom(msg.Payload).Build(); return("AuthRequest{clientId:" + _auth_req.ClientId + ", clientSecret:" + _auth_req.ClientSecret + "}"); case ProtoOAPayloadType.OA_AUTH_RES: return("AuthResponse"); case ProtoOAPayloadType.OA_GET_SUBSCRIBED_ACCOUNTS_REQ: return("GetSubscribedAccountsRequest"); case ProtoOAPayloadType.OA_GET_SUBSCRIBED_ACCOUNTS_RES: var _subscr_res = ProtoOAGetSubscribedAccountsRes.CreateBuilder().MergeFrom(msg.Payload).Build(); var _subscr_res_str = "GetSubscribedAccountsResponse{"; var _subscr_count = _subscr_res.AccountIdCount; foreach (var accountId in _subscr_res.AccountIdList) { _subscr_res_str += "accountId:" + accountId.ToString() + (--_subscr_count == 0 ? "" : ", "); } return(_subscr_res_str + "}"); case ProtoOAPayloadType.OA_SUBSCRIBE_FOR_TRADING_EVENTS_REQ: var _subscr_req = ProtoOASubscribeForTradingEventsReq.CreateBuilder().MergeFrom(msg.Payload).Build(); return("SubscrbeTradingEventsRequest{accountId:" + _subscr_req.AccountId.ToString() + ", accessToken:" + _subscr_req.AccessToken + "}"); case ProtoOAPayloadType.OA_SUBSCRIBE_FOR_TRADING_EVENTS_RES: return("SubscrbeTradingEventsResponse"); case ProtoOAPayloadType.OA_UNSUBSCRIBE_FROM_TRADING_EVENTS_REQ: var _unsubscr_req = ProtoOAUnsubscribeFromTradingEventsReq.CreateBuilder().MergeFrom(msg.Payload).Build(); return("UnsubscrbeTradingEventsRequest{accountId:" + _unsubscr_req.AccountId + "}"); case ProtoOAPayloadType.OA_UNSUBSCRIBE_FROM_TRADING_EVENTS_RES: return("UnsubscrbeTradingEventsResponse"); case ProtoOAPayloadType.OA_EXECUTION_EVENT: return(OpenApiExecEventsToString(msg)); case ProtoOAPayloadType.OA_CANCEL_ORDER_REQ: return("CancelOrderRequest{}"); case ProtoOAPayloadType.OA_CREATE_ORDER_REQ: return("CreateOrderRequest{}"); case ProtoOAPayloadType.OA_CLOSE_POSITION_REQ: return("ClosePositionRequest{}"); case ProtoOAPayloadType.OA_AMEND_ORDER_REQ: return("AmendOrderRequest{}"); case ProtoOAPayloadType.OA_AMEND_POSITION_SL_TP_REQ: return("AmendPositionRequest{}"); case ProtoOAPayloadType.OA_SUBSCRIBE_FOR_SPOTS_REQ: return("SubscribeForSpotsRequest{}"); case ProtoOAPayloadType.OA_SUBSCRIBE_FOR_SPOTS_RES: return("SubscribeForSpotsResponse{}"); case ProtoOAPayloadType.OA_UNSUBSCRIBE_FROM_SPOTS_REQ: return("UnsubscribeFromSpotsRequest{}"); case ProtoOAPayloadType.OA_UNSUBSCRIBE_FROM_SPOTS_RES: return("UnsubscribeFromSpotsResponse{}"); case ProtoOAPayloadType.OA_GET_SPOT_SUBSCRIPTION_REQ: return("GetSpotSubscriptionRequest{}"); case ProtoOAPayloadType.OA_GET_SPOT_SUBSCRIPTION_RES: return("GetSpotSubscriptionResponse{}"); case ProtoOAPayloadType.OA_GET_ALL_SPOT_SUBSCRIPTIONS_REQ: return("GetAllSpotSubscriptionsRequest{}"); case ProtoOAPayloadType.OA_GET_ALL_SPOT_SUBSCRIPTIONS_RES: String _all_str = "GetAllSpotSubscriptionsResponse{"; ProtoOAGetAllSpotSubscriptionsRes _all_res = ProtoOAGetAllSpotSubscriptionsRes.CreateBuilder().MergeFrom(msg.Payload).Build(); _all_str += "subscriptions=["; foreach (ProtoOASpotSubscription subscription in _all_res.SpotSubscriptionsList) { _all_str += "{AccountId=" + subscription.AccountId + ", SubscriptionId=" + subscription.SubscriptionId + ", SymbolNamesList=["; foreach (String symbolName in subscription.SymbolNamesList) { _all_str += symbolName + ", "; } _all_str += "]}, "; } _all_str += "]}"; return(_all_str); case ProtoOAPayloadType.OA_SPOT_EVENT: var _spot_event = ProtoOASpotEvent.CreateBuilder().MergeFrom(msg.Payload).Build(); return("SpotEvent{subscriptionId:" + _spot_event.SubscriptionId + ", symbolName:" + _spot_event.SymbolName + ", bidPrice:" + (_spot_event.HasBidPrice ? _spot_event.BidPrice.ToString() : " ") + ", askPrice:" + (_spot_event.HasAskPrice ? _spot_event.AskPrice.ToString() : " ") + "}"); default: return("unknown"); } }
public ProtoMessage CreatePingRequest(ulong timestamp, string clientMsgId = null) { return(CreateMessage((uint)ProtoPayloadType.PING_REQ, ProtoPingReq.CreateBuilder().SetTimestamp(timestamp).Build().ToByteString(), clientMsgId)); }