Beispiel #1
0
        public void Receive(ITickBar tickBar)
        {
            string code = tickBar.Code;

            if (!dicTickData.ContainsKey(code))
            {
                TickData_Present newTickData = new TickData_Present(10000);
                newTickData.Code = code;
                //List<ITickBar> tickBarList = new List<ITickBar>();
                ((TickBar)tickBar).Mount = tickBar.TotalMount;
                ((TickBar)tickBar).Add   = tickBar.Hold;
                newTickData.Recieve(tickBar);
                dicTickData.Add(code, newTickData);
                if (OnTickDataReceived != null)
                {
                    OnTickDataReceived(this, newTickData, tickBar);
                }
                return;
            }

            TickData_Present tickData = dicTickData[code];
            ITickBar         lastTick = tickData;

            ((TickBar)tickBar).Mount = tickBar.TotalMount - lastTick.TotalMount;
            ((TickBar)tickBar).Add   = tickBar.Hold - lastTick.Hold;
            tickData.Recieve(tickBar);
            if (OnTickDataReceived != null)
            {
                OnTickDataReceived(this, tickData, tickBar);
            }
        }
Beispiel #2
0
 public SingleTickBarWriter(string path, TickData_Present tickBars, int startIndex, int endIndex)
 {
     this.path       = path;
     this.tickBars   = tickBars;
     this.startIndex = startIndex;
     this.endIndex   = endIndex;
 }
Beispiel #3
0
        private void Push2Queue(string code, int startIndex, int endIndex)
        {
            if (endIndex < startIndex)
            {
                return;
            }
            string           tickpath = GetTickBarPath(path, code, date);
            TickData_Present tickBars = dicTickData[code];

            writerQueue.PushWriter(new SingleTickBarWriter(tickpath, tickBars, startIndex, endIndex));
        }
Beispiel #4
0
        private void WriteTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            List <string> codes        = dicTickData.Keys.ToList <string>();
            List <int[]>  startEndList = new List <int[]>();

            for (int i = 0; i < codes.Count; i++)
            {
                string           code     = codes[i];
                TickData_Present tickData = dicTickData[code];
                int startIndex            = GetCurrentWriteBeginIndex(code);
                int endIndex = tickData.Length - 1;
                SetLastWriteEndIndex(code, endIndex);
                Push2Queue(code, startIndex, endIndex);
            }
            writerQueue.Flush();
        }