Ejemplo n.º 1
0
        public ProtoMessage CreateAuthorizationRequest(string clientId, string clientSecret, string clientMsgId = null)
        {
            var _msg = ProtoOAAuthReq.CreateBuilder();

            _msg.SetClientId(clientId);
            _msg.SetClientSecret(clientSecret);
            return(CreateMessage((uint)_msg.PayloadType, _msg.Build().ToByteString(), clientMsgId));
        }
Ejemplo n.º 2
0
 public ProtoOAAuthReq GetAuthorizationRequest(byte[] msg = null)
 {
     return(ProtoOAAuthReq.CreateBuilder().MergeFrom(GetPayload(msg)).Build());
 }
Ejemplo n.º 3
0
        static string OpenApiMessageToString(ProtoMessage msg)
        {
            switch ((ProtoOAPayloadType)msg.PayloadType)
            {
            case ProtoOAPayloadType.OA_AUTH_REQ:
                var _auth_req = ProtoOAAuthReq.CreateBuilder().MergeFrom(msg.Payload).Build();
#if LOG_SENSITIVE_INFO
                return("AuthRequest{clientId:" + _auth_req.ClientId + ", clientSecret:" + _auth_req.ClientSecret + "}");
#else
                return("AuthRequest{clientId: *****, clientSecret: *****}");
#endif
            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();
#if LOG_SENSITIVE_INFO
                return("SubscrbeTradingEventsRequest{accountId:" + _subscr_req.AccountId.ToString() + ", accessToken:" + _subscr_req.AccessToken + "}");
#else
                return("SubscrbeTradingEventsRequest{accountId: *****, accessToken: *****}");
#endif
            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() : "       ") + " " + (new DateTime(1970, 1, 1) + TimeSpan.FromMilliseconds(_spot_event.Timestamp)) + "}");

            default:
                return("unknown");
            }
        }