public async Task SubscribeToLiveTrendbar(long accountId, bool isLive, long symbolId, ProtoOATrendbarPeriod period) { VerifyConnection(); var client = GetClient(isLive); using var cancelationTokenSource = new CancellationTokenSource(); ProtoOASubscribeLiveTrendbarRes receivedResponse = null; using var disposable = client.OfType <ProtoOASubscribeLiveTrendbarRes>().Where(response => response.CtidTraderAccountId == accountId) .Subscribe(response => { receivedResponse = response; cancelationTokenSource.Cancel(); }); var requestMessage = new ProtoOASubscribeLiveTrendbarReq { CtidTraderAccountId = accountId, Period = period, SymbolId = symbolId }; await SendMessage(requestMessage, ProtoOAPayloadType.ProtoOaSubscribeLiveTrendbarReq, client, cancelationTokenSource, () => receivedResponse is not null); }
private async static void SubscribeToSymbolTrendBar(string[] commandSplit) { Console.WriteLine("Subscribing to symbol trend bar event..."); var subscribeLiveTrendbarReq = new ProtoOASubscribeLiveTrendbarReq() { Period = (ProtoOATrendbarPeriod)Enum.Parse(typeof(ProtoOATrendbarPeriod), commandSplit[2], true), CtidTraderAccountId = long.Parse(commandSplit[3]), SymbolId = long.Parse(commandSplit[4]), }; await _client.SendMessage(subscribeLiveTrendbarReq, ProtoOAPayloadType.ProtoOaSubscribeLiveTrendbarReq); }
public static ProtoMessage Subscribe_Live_Trendbar_Req(long ctidTraderAccountId, ProtoOATrendbarPeriod period, long symbolId) { ProtoOASubscribeLiveTrendbarReq message = new ProtoOASubscribeLiveTrendbarReq { payloadType = ProtoOAPayloadType.ProtoOaSubscribeLiveTrendbarReq, ctidTraderAccountId = ctidTraderAccountId, Period = period, symbolId = symbolId }; Log.Info("ProtoOASubscribeLiveTrendbarReq:: " + $"ctidTraderAccountId: {ctidTraderAccountId}; " + $"Period: {period}; " + $"symbolId: {symbolId}"); InnerMemoryStream.SetLength(0); Serializer.Serialize(InnerMemoryStream, message); return(Encode((uint)message.payloadType, InnerMemoryStream.ToArray())); }