예제 #1
0
        long tl_newUnknownRequest(MessageTypes t, string msg)
        {
            v("message: " + t.ToString() + " data: " + msg);
            switch (t)
            {
            case MessageTypes.DOMREQUEST:
            {
                string client = string.Empty;
                int    depth  = 0;
                if (Book.ParseDOMRequest(msg, ref depth, ref client))
                {
                    debug("depth set to: " + depth + " by client: " + client);
                    tickdepth = depth;
                }
                break;
            }

            case MessageTypes.DAYHIGH:
            {
                decimal price = 0;
                highs.TryGetValue(msg, out price);
                return(WMUtil.pack(price));
            }

            case MessageTypes.DAYLOW:
            {
                decimal price = 0;
                lows.TryGetValue(msg, out price);
                return(WMUtil.pack(price));
            }
            }
            return((long)MessageTypes.UNKNOWN_MESSAGE);
        }
예제 #2
0
        public void Packing()
        {
            decimal normal   = 37.56m;
            long    packed   = WMUtil.pack(normal);
            decimal unpacked = WMUtil.unpack(packed);

            Assert.That(normal == unpacked, normal.ToString() + " -> " + unpacked.ToString());
        }
예제 #3
0
        long IQFeedHelper_newUnknownRequest(MessageTypes t, string msg)
        {
            switch (t)
            {
            case MessageTypes.DAYHIGH:
            {
                // get index for request
                int idx = _highs.getindex(msg);
                // ignore if no index
                if (idx == GenericTracker.UNKNOWN)
                {
                    return(0);
                }
                decimal v = _highs[idx];
                // ensure we have a high
                if (v == decimal.MinValue)
                {
                    return(0);
                }
                return(WMUtil.pack(v));
            }

            case MessageTypes.DAYLOW:
            {
                // get index for request
                int idx = _highs.getindex(msg);
                // ignore if no index
                if (idx == GenericTracker.UNKNOWN)
                {
                    return(0);
                }
                decimal v = _highs[idx];
                // ensure we have a high
                if (v == decimal.MaxValue)
                {
                    return(0);
                }
                return(WMUtil.pack(v));
            }

            case MessageTypes.BARREQUEST:
            {
                BarRequest br = BarImpl.ParseBarRequest(msg);
                RequestBars(br);
                return((long)MessageTypes.OK);
            }
            }
            return((long)MessageTypes.FEATURE_NOT_IMPLEMENTED);
        }