Exemple #1
0
        protected void RequestUnsubscribeForSymbol(string symbol, params ProtoOATrendbarPeriod[] periods)
        {
            var _msg = outgoingMsgFactory.CreateUnsubscribeFromSymbolSpotsRequest(symbol, clientMsgId);

#if TRACE_SUBSCRIPTIONS
            if (isDebugIsOn)
            {
                Console.WriteLine("Send UnsubscribeFromSymbolSpotsRequest(): {0}", OpenApiMessagesPresentation.ToString(_msg));
            }
#endif
            writeQueueSync.Enqueue(_msg.ToByteArray());

            var subscribed = GetSubscribed(symbol);
            foreach (var period in periods)
            {
                subscribed.Remove(period);
            }

            if (subscribed.Count > 0 || periods.Length > 0)
            {
                RequestSubscribeForSymbol(symbol, subscribed.ToArray()).FireAndForget();
            }
            else
            {
                var s = GetSymbol(symbol);
                s.Bid = double.NaN;
                s.Ask = double.NaN;
            }

            //throw new NotImplementedException();
            //var _msg = outgoingMsgFactory.CreateUnsubscribeAccountFromSpotsRequest(AccountId, AccessToken, symbol, clientMsgId);
            //if (isDebugIsOn) Console.WriteLine("SendSubscribeForSpotsRequest() Message to be sent:\n{0}", OpenApiMessagesPresentation.ToString(_msg));
            //writeQueueSync.Enqueue(_msg.ToByteArray());
        }