Example #1
0
        public override void UpdateFiveMinsLine(Define.TTdxDllShareData data)
        {
            if (data.count > dealtMinsData)
            {
                Define.TTDX_MIN minsData = new Define.TTDX_MIN();
                int             pos      = (data.count - 1) * Marshal.SizeOf(minsData);
                minsData = (Define.TTDX_MIN)Utility.BytesToStuct(data.buf, minsData.GetType(), pos);
                currentMinsNode.volumn += minsData.Volume;

                if (data.count % 5 == 0)
                {
                    float lastClose = currentMinsNode.close;
                    WriteToFiveMinsLine(currentMinsNode);
                    currentMinsNode       = new StockNode();
                    currentMinsNode.time  = DateTime.Now.ToString("yyyyMMddhhmm");
                    currentMinsNode.open  = lastClose;
                    currentMinsNode.high  = lastClose;
                    currentMinsNode.low   = lastClose;
                    currentMinsNode.close = lastClose;

                    currentMinsNode.high  = Math.Max(currentMinsNode.high, minsData.Close);
                    currentMinsNode.low   = Math.Min(currentMinsNode.low, minsData.Close);
                    currentMinsNode.close = minsData.Close;
                }
                ++dealtMinsData;
            }
        }
        public override void UpdateFiveMinsLine(Define.TTdxDllShareData data)
        {
            if (data.count > dealtMinsData)
            {
                Define.TTDX_MIN minsData = new Define.TTDX_MIN();
                int pos = (data.count - 1) * Marshal.SizeOf(minsData);
                minsData = (Define.TTDX_MIN)Utility.BytesToStuct(data.buf, minsData.GetType(), pos);
                currentMinsNode.high = Math.Max(currentMinsNode.high, minsData.Close);
                currentMinsNode.low = Math.Min(currentMinsNode.low, minsData.Close);
                currentMinsNode.close = minsData.Close;

                if (data.count % 5 == 0)
                {
                    float lastClose = currentMinsNode.close;
                    fiveMinsLine.Add(currentMinsNode);
                    currentMinsNode = new StockNode();
                    currentMinsNode.time = DateTime.Now.ToString("yyyyMMddhhmm");
                    currentMinsNode.open = lastClose;
                    currentMinsNode.high = lastClose;
                    currentMinsNode.low = lastClose;
                    currentMinsNode.close = lastClose;
                }
                ++dealtMinsData;
            }
        }
Example #3
0
        public override void InitMinsData(Define.TTdxDllShareData data)
        {
            Define.TTDX_MIN minsData  = new Define.TTDX_MIN();
            float           lastClose = CurrentDayNode.open;
            int             count     = data.count - data.count % 5;

            int pos = 0;

            for (; dealtMinsData < count;)
            {
                StockNode node = new StockNode();
                node.open   = lastClose;
                node.high   = lastClose;
                node.low    = lastClose;
                node.volumn = 0;
                if (dealtMinsData < 120)
                {
                    node.time = string.Format(DateTime.Now.ToString("yyyyMMdd") + "{0:D2}{1:D2}", (dealtMinsData + 30) / 60 + 9, (dealtMinsData + 30) % 60);
                }
                else
                {
                    node.time = string.Format(DateTime.Now.ToString("yyyyMMdd") + "{0:D2}{1:D2}", (dealtMinsData - 120) / 60 + 13, dealtMinsData % 60);
                }

                for (int i = 0; i < 5 && dealtMinsData < count; ++i)
                {
                    minsData = (Define.TTDX_MIN)Utility.BytesToStuct(data.buf, minsData.GetType(), pos);
                    if (4 == i)
                    {
                        node.close = minsData.Close;
                        lastClose  = node.close;
                    }
                    node.high    = Math.Max(node.high, minsData.Close);
                    node.low     = Math.Min(node.low, minsData.Close);
                    node.volumn += minsData.Volume;

                    ++dealtMinsData;
                    pos += Marshal.SizeOf(minsData);
                }
                WriteToFiveMinsLine(node);
            }

            currentMinsNode.open   = lastClose;
            currentMinsNode.high   = lastClose;
            currentMinsNode.low    = lastClose;
            currentMinsNode.close  = lastClose;
            currentMinsNode.volumn = 0;
            if (dealtMinsData < 120)
            {
                currentMinsNode.time = string.Format(DateTime.Now.ToString("yyyyMMdd") + "{0:D2}{1:D2}", (dealtMinsData + 30) / 60 + 9, (dealtMinsData + 30) % 60);
            }
            else
            {
                currentMinsNode.time = string.Format(DateTime.Now.ToString("yyyyMMdd") + "{0:D2}{1:D2}", (dealtMinsData - 120) / 60 + 13, dealtMinsData % 60);
            }
            for (int i = 0; i < data.count % 5; ++i)
            {
                minsData = (Define.TTDX_MIN)Utility.BytesToStuct(data.buf, minsData.GetType(), pos);
                if ((data.count % 5) - 1 == i)
                {
                    currentMinsNode.close = minsData.Close;
                }
                currentMinsNode.high    = Math.Max(currentMinsNode.high, minsData.Close);
                currentMinsNode.low     = Math.Min(currentMinsNode.low, minsData.Close);
                currentMinsNode.volumn += minsData.Volume;

                ++dealtMinsData;
                pos += Marshal.SizeOf(minsData);
            }
            fiveMinsInit = true;
        }
        public override void InitMinsData(Define.TTdxDllShareData data)
        {
            Define.TTDX_MIN minsData = new Define.TTDX_MIN();
            float lastClose = CurrentDayNode.open;
            int count = data.count - data.count % 5;

            int pos = 0;
            for (; dealtMinsData < count;)
            {
                StockNode node = new StockNode();
                node.open = lastClose;
                node.high = lastClose;
                node.low = lastClose;
                node.volumn = 0;
                if(dealtMinsData < 120){
                    node.time = string.Format(DateTime.Now.ToString("yyyyMMdd") + "{0:D2}{1:D2}", (dealtMinsData  + 30) / 60 + 9, (dealtMinsData + 30) % 60);
                }
                else
                {
                    node.time = string.Format(DateTime.Now.ToString("yyyyMMdd") + "{0:D2}{1:D2}", (dealtMinsData - 120) / 60 + 13, dealtMinsData % 60);
                }

                for (int i = 0; i < 5 && dealtMinsData < count; ++i)
                {
                    minsData = (Define.TTDX_MIN)Utility.BytesToStuct(data.buf, minsData.GetType(), pos);
                    if (4 == i)
                    {
                        node.close = minsData.Close;
                        lastClose = node.close;
                    }
                    node.high = Math.Max(node.high, minsData.Close);
                    node.low = Math.Min(node.low, minsData.Close);
                    node.volumn += minsData.Volume;

                    ++dealtMinsData;
                    pos += Marshal.SizeOf(minsData);
                }
                fiveMinsLine.Add(node);
            }
            
            currentMinsNode.open = lastClose;
            currentMinsNode.high = lastClose;
            currentMinsNode.low = lastClose;
            currentMinsNode.close = lastClose;
            currentMinsNode.volumn = 0;
            if (dealtMinsData < 120)
            {
                currentMinsNode.time = string.Format(DateTime.Now.ToString("yyyyMMdd") + "{0:D2}{1:D2}", (dealtMinsData + 30) / 60 + 9, (dealtMinsData + 30) % 60);
            }
            else
            {
                currentMinsNode.time = string.Format(DateTime.Now.ToString("yyyyMMdd") + "{0:D2}{1:D2}", (dealtMinsData - 120) / 60 + 13, dealtMinsData % 60);
            }
            for (int i = 0; i < data.count % 5; ++i)
            {
                minsData = (Define.TTDX_MIN)Utility.BytesToStuct(data.buf, minsData.GetType(), pos);
                if ((data.count % 5) - 1 == i)
                {
                    currentMinsNode.close = minsData.Close;
                }
                currentMinsNode.high = Math.Max(currentMinsNode.high, minsData.Close);
                currentMinsNode.low = Math.Min(currentMinsNode.low, minsData.Close);
                currentMinsNode.volumn += minsData.Volume;

                ++dealtMinsData;
                pos += Marshal.SizeOf(minsData);
            }
            fiveMinsInit = true;
        }