示例#1
0
        private void LoadTick()
        {
            Dictionary <string, string> DictionaryParam = new Dictionary <string, string>();
            Tick   tic = new Tick();
            int    timech;
            string str = "";

            while (run)
            {
                if (dealQueue.Count > 0)
                {
                    for (int j = 0; j < dealQueue.Count; j++)
                    {
                        timech = 0;
                        dealQueue.TryDequeue(out str);
                        DictionaryParam.Clear();
                        if (str != null)
                        {
                            if (str.IndexOf("NUM") == 0)
                            {
                                string[] Arr = str.Split(';');
                                for (int i = 0; i < Arr.Length; i++)
                                {
                                    string[] KeyValue = Arr[i].Split('=');
                                    DictionaryParam.Add(KeyValue[0], KeyValue[1]);
                                }
                                tic.priceTick    = Convert.ToDouble(DictionaryParam["PRICE"]);
                                tic.dateTimeTick = Convert.ToDateTime(DictionaryParam["DATA"]);
                                tic.volumeTick   = Convert.ToInt32(DictionaryParam["QTY"]);
                                tic.paperCode    = DictionaryParam["SECCODE"];
                                tic.buy          = Convert.ToByte(DictionaryParam["FLAGS"]);
                                DateTime t = DateTime.Now;
                                switch (TF.frame)
                                {
                                case TfRange.SEC:
                                    timech = (tic.dateTimeTick.Second / TF.digit) * TF.digit;
                                    t      = new DateTime(tic.dateTimeTick.Year, tic.dateTimeTick.Month, tic.dateTimeTick.Day,
                                                          tic.dateTimeTick.Hour, tic.dateTimeTick.Minute, timech);
                                    break;

                                case TfRange.MIN:
                                    timech = (tic.dateTimeTick.Minute / TF.digit) * TF.digit;
                                    t      = new DateTime(tic.dateTimeTick.Year, tic.dateTimeTick.Month, tic.dateTimeTick.Day, tic.dateTimeTick.Hour, timech, 0);
                                    break;

                                case TfRange.HOUR:
                                    timech = (tic.dateTimeTick.Hour / TF.digit) * TF.digit;
                                    t      = new DateTime(tic.dateTimeTick.Year, tic.dateTimeTick.Month, tic.dateTimeTick.Day, timech, 0, 0);
                                    break;

                                case TfRange.DAY:
                                    timech = (tic.dateTimeTick.Day / TF.digit) * TF.digit;
                                    t      = new DateTime(tic.dateTimeTick.Year, tic.dateTimeTick.Month, timech, 0, 0, 0);
                                    break;
                                }
                                tic.dateTimeTick = t;
                                //Connector_Event_GetTick(tic);
                            }
                        }
                    }
                }
                Thread.Sleep(1);
            }
        }
示例#2
0
 // Событие получения сделки (в виде тика)
 private void EGetTick(Tick tick)
 {
     Event_GetTick.Invoke(tick);
 }
示例#3
0
        public void AddRealTick(DataSeries ds, Tick tk)
        {
            Load = false;
            //int i = 0;
            if (Bars.Count != ds.Bars.Count)
            {
                // var bar = ds.Bars.Last();
                {
                    Bars.Add(tk.dateTimeTick, new BarDraw());
                    xOf = wiCl * (Bars.Count - 1);

                    yTo = Convert.ToInt32((tk.priceTick - startPrice) / deltaTick) * hiCl;
                    if (tk.volumeTick > maxVol)
                    {
                        xTo = xOf + wiCl - 1;
                    }
                    else if (tk.volumeTick > minVol)
                    {
                        xTo = xOf + ((tk.volumeTick * 100 / minVol) * (wiCl / 2 - 1)) / 100;
                    }
                    else
                    {
                        xTo = xOf + ((tk.volumeTick * 100 / minVol) * (wiCl / 3 - 1)) / 100;
                    }
                    if (xTo == xOf)
                    {
                        xTo++;
                    }
                    Bars.Last().Value.Price.Add(tk.priceTick, new int[4] {
                        xOf, xTo, yTo, tk.volumeTick
                    });
                }
            }
            else
            {
                var bar = Bars.Last();
                if (bar.Value.Price.ContainsKey(tk.priceTick))
                {
                    xOf = bar.Value.Price[tk.priceTick][0];
                    int vol = Convert.ToInt32(ds.Bars.Last().Value.Price[tk.priceTick].Volume);
                    if (vol > maxVol)
                    {
                        xTo = xOf + wiCl - 1;
                    }
                    else if (vol > minVol)
                    {
                        xTo = xOf + ((vol * 100 / minVol) * (wiCl / 2 - 1)) / 100;
                    }
                    else
                    {
                        xTo = xOf + ((vol * 100 / minVol) * (wiCl / 3 - 1)) / 100;
                    }
                    if (xTo == xOf)
                    {
                        xTo++;
                    }
                    bar.Value.Price[tk.priceTick][1] = xTo;
                    bar.Value.Price[tk.priceTick][3] = vol;
                    yTo = bar.Value.Price[tk.priceTick][2];
                }
                else
                {
                    xOf = wiCl * (ds.Bars.Count - 1);
                    yTo = Convert.ToInt32((tk.priceTick - startPrice) / deltaTick) * hiCl;
                    if (tk.volumeTick > maxVol)
                    {
                        xTo = xOf + wiCl - 1;
                    }
                    else if (tk.volumeTick > minVol)
                    {
                        xTo = xOf + ((tk.volumeTick * 100 / minVol) * (wiCl / 2 - 1)) / 100;
                    }
                    else
                    {
                        xTo = xOf + ((tk.volumeTick * 100 / minVol) * (wiCl / 3 - 1)) / 100;
                    }
                    if (xTo == xOf)
                    {
                        xTo++;
                    }
                    Bars.Last().Value.Price.Add(tk.priceTick, new int[4] {
                        xOf, xTo, yTo, tk.volumeTick
                    });
                }
            }
            lastPrice  = tk.priceTick;
            lastPriceY = yTo + hiCl / 2;
            lastPriceX = xOf + wiCl;
            Load       = true;
        }