예제 #1
0
        /*
         *  fire signal when the extremas and check to see if we are diverging/ converging
         */
        private void convergence()
        {
            Convergence zlistConv = LocalExtrema.releventWrap(zslist);
            Convergence mktConv   = LocalExtrema.releventWrap(spreads);


            /*
             * if (zlistConv.IsHi)
             * {
             *   if (log.IsDebugEnabled) log.Debug("zlisdt HI");
             * }
             * if (zlistConv.IsLow)
             * {
             *  if (log.IsDebugEnabled) log.Debug("zlisdt Low");
             * }
             * if (mktConv.IsHi)
             * {
             *  if (log.IsDebugEnabled) log.Debug("mktConv HI");
             * }
             * if (mktConv.IsLow)
             * {
             *  if (log.IsDebugEnabled) log.Debug("mktConv Low");
             * }
             */

            if (zlistConv.IsHi && mktConv.IsLow)
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug(
                        new System.Text.StringBuilder("Buy convergence: mkt: ")
                        .AppendFormat("{0} ~ {1}", spreads[spreads.Count - 1].bid, spreads[spreads.Count - 1].ask)
                        );
                }
                OnTradeEvt(new TradeEventArgs("Buy"));
            }
            else if (zlistConv.IsLow && mktConv.IsHi)
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug(
                        new System.Text.StringBuilder("Sell convergence: mkt: ")
                        .AppendFormat("{0} ~ {1}", spreads[spreads.Count - 1].bid, spreads[spreads.Count - 1].ask)
                        );
                }
                OnTradeEvt(new TradeEventArgs("Sell"));
            }

            /*
             * else if (zlistConv.IsLow && mktConv.IsLow)
             * {
             * action = "same low";
             * }
             * else if (zlistConv.IsHi && mktConv.IsHi)
             * {
             * action = "same hi";
             * }
             */
        }
예제 #2
0
        public static List <double> extremas(List <Quote> spreads)
        {
            List <double> mids = new List <double>();

            foreach (Quote q in spreads)
            {
                mids.Add((q.bid + q.ask) * 0.5);
            }

            return(LocalExtrema.extremas(mids));
        }
예제 #3
0
        public static Convergence releventWrap(List <double> zlist)
        {
            List <double> ext = LocalExtrema.extremas(zlist);

            return(LocalExtrema.relevant(ext));
        }
예제 #4
0
        public static Convergence releventWrap(List <Quote> spreads)
        {
            List <double> ext = LocalExtrema.extremas(spreads);

            return(LocalExtrema.relevant(ext));
        }