public bool AddStrategy(Strategy s)
        {
            Logger.Log("srep adding");

            int instIndex = Rand.Random.Next(marketWatch.InstrumentCount);

            //we need to initialize s first because this can change its hashcode
            s.Initialize(marketWatch.GetInstrument(instIndex));

            Logger.Log("srep init done");

            //we need to use clientNodeHelper and check if other repositories in other servers
            //have this strategy
            if (helper == null || helper.CheckStrategyExistence(s.GetHashCode()) == false)
            {
                Logger.Log("srep check ok");

                strategies.Add(s);
                strategyCount++;
                strategyCodes.Add(s.GetHashCode());

                Logger.Log("srep added");

                if (OnNewStrategy != null)
                {
                    OnNewStrategy(s);
                }

                Logger.Log("srep finished");

                return(true);
            }

            return(false);
        }
示例#2
0
        public void Register(ClientContext context)
        {
            IMarketWatch mw = context.MarketWatch;

            mw.MarketMeterProcess += new MarketUpdateEventHandler(updateMarketInfo);

            for (int i = 0; i < mw.InstrumentCount; i++)
            {
                Instrument inst = mw.GetInstrument(i);

                foreach (int tf in GeneralConfig.ValidTimeFrames)
                {
                    currentVolatility.Add(inst.ToString() + tf.ToString(), 0);
                    currentTrend.Add(inst.ToString() + tf.ToString(), 0);
                }
            }
        }