Exemplo n.º 1
0
        public void subscribeInstrument(OkexFutureInstrumentType instrument, OkexFutureContractType contract)
        {
            if (!m_subscribedContracts.ContainsKey(instrument))
            {
                List <OkexFutureContractType> contractsList = new List <OkexFutureContractType>();
                m_subscribedContracts.TryAdd(instrument, contractsList);
            }

            if (m_subscribedContracts[instrument].Contains(contract))
            {
                return;
            }

            m_subscribedContracts[instrument].Add(contract);

            int id = genTargetID(instrument, contract);
            MarketDataUpdater mdu = new MarketDataUpdater(instrument, contract);

            m_dataUpdaters.TryAdd(id, mdu);
            mdu.start();
        }
Exemplo n.º 2
0
        public void unsubscribeInstrument(OkexFutureInstrumentType instrument, OkexFutureContractType contract)
        {
            if (!m_subscribedContracts.ContainsKey(instrument))
            {
                return;
            }

            if (!m_subscribedContracts[instrument].Contains(contract))
            {
                return;
            }

            m_subscribedContracts[instrument].Remove(contract);
            int id = genTargetID(instrument, contract);

            if (m_dataUpdaters.ContainsKey(id))
            {
                MarketDataUpdater mdu = m_dataUpdaters[id];
                mdu.stop();
                m_dataUpdaters.TryRemove(id, out mdu);
            }
        }