Ejemplo n.º 1
0
        public async Task <ProtoOATrader> GetTrader(long accountId, bool isLive)
        {
            VerifyConnection();

            var client = GetClient(isLive);

            using var cancelationTokenSource = new CancellationTokenSource();

            ProtoOATrader result = null;

            using var disposable = client.OfType <ProtoOATraderRes>().Where(response => response.CtidTraderAccountId == accountId)
                                   .Subscribe(response =>
            {
                result = response.Trader;

                cancelationTokenSource.Cancel();
            });

            var requestMessage = new ProtoOATraderReq
            {
                CtidTraderAccountId = accountId
            };

            await SendMessage(requestMessage, ProtoOAPayloadType.ProtoOaTraderReq, client, cancelationTokenSource, () => result is not null);

            return(result);
        }
        public ProtoMessage CreateTraderRequest(long accountID, string clientMsgId = null)
        {
            var _msg = ProtoOATraderReq.CreateBuilder();

            _msg.SetCtidTraderAccountId(accountID);
            return(CreateMessage((uint)_msg.PayloadType, _msg.Build().ToByteString(), clientMsgId));
        }
        public static ProtoMessage Trader_Req(long ctidTraderAccountId)
        {
            ProtoOATraderReq message = new ProtoOATraderReq
            {
                payloadType         = ProtoOAPayloadType.ProtoOaTraderReq,
                ctidTraderAccountId = ctidTraderAccountId
            };

            Log.Info("ProtoOATraderReq:: " +
                     $"ctidTraderAccountId: {ctidTraderAccountId}");

            InnerMemoryStream.SetLength(0);
            Serializer.Serialize(InnerMemoryStream, message);

            return(Encode((uint)message.payloadType, InnerMemoryStream.ToArray()));
        }