示例#1
0
        private void Run(object o)
        {
            string itemCode = (string)o;

            string lastPrice = "";

            LimitedList <double> ll3 = new LimitedList <double>(3);
            LimitedList <double> ll5 = new LimitedList <double>(5);
            LimitedList <double> ll7 = new LimitedList <double>(7);

            int rnd = ItemCodeSet.GetItemRoundNum(itemCode);

            while (true)
            {
                if (!SiseStorage.Instance.Prices.ContainsKey(itemCode))
                {
                    System.Threading.Thread.Sleep(1000);
                    continue;
                }

                var priceQueue = SiseStorage.Instance.Prices[itemCode];

                if (priceQueue.Count == 0)
                {
                    System.Threading.Thread.Sleep(100);
                    continue;
                }
                CurrentPrice price;
                var          isDequeue = priceQueue.TryDequeue(out price);
                if (isDequeue)
                {
                    if (lastPrice == price.price)
                    {
                        continue;
                    }
                    lastPrice = price.price;

                    double d = Math.Round(Convert.ToDouble(lastPrice), rnd);
                    ll3.Insert(d);
                    ll5.Insert(d);
                    ll7.Insert(d);
                    price.price3 = ll3.Count == 3 ? Math.Round(ll3.Average(), rnd) : 0;
                    price.price5 = ll3.Count == 5 ? Math.Round(ll5.Average(), rnd) : 0;
                    price.price7 = ll3.Count == 7 ? Math.Round(ll7.Average(), rnd) : 0;

                    SiseEvents.Instance.OnSiseHandler(itemCode, price);

                    PPStorage.Instance.Add(itemCode, price.DTime, (Single)Math.Round(Convert.ToSingle(price.price), rnd));

                    if (isSiseBinding)
                    {
                        BindSise(itemCode, price);
                    }
                }
            }
        }
示例#2
0
文件: MainForm.cs 项目: aum-inv/AUM
        private void RunKr(object o)
        {
            string itemCode = (string)o;

            string lastPrice = "";

            LimitedList <double> ll3 = new LimitedList <double>(3);
            LimitedList <double> ll5 = new LimitedList <double>(5);
            LimitedList <double> ll7 = new LimitedList <double>(7);

            int rnd = ItemCodeSet.GetItemRoundNum(itemCode);

            while (isRunKr)
            {
                try
                {
                    if (!SiseStorage.Instance.PricesKr.ContainsKey(itemCode))
                    {
                        System.Threading.Thread.Sleep(1000);
                        continue;
                    }

                    var priceQueue = SiseStorage.Instance.PricesKr[itemCode];

                    if (priceQueue.Count == 0)
                    {
                        System.Threading.Thread.Sleep(100);
                        continue;
                    }
                    CurrentPrice price;
                    var          isDequeue = priceQueue.TryDequeue(out price);
                    if (isDequeue)
                    {
                        if (lastPrice == price.price)
                        {
                            continue;
                        }
                        lastPrice = price.price;
                        double d = Math.Round(Convert.ToDouble(lastPrice), rnd);

                        if (!ll3.Contains(d))
                        {
                            ll3.Insert(d);
                        }
                        if (!ll5.Contains(d))
                        {
                            ll5.Insert(d);
                        }
                        if (!ll7.Contains(d))
                        {
                            ll7.Insert(d);
                        }

                        price.price3 = Math.Round(ll3.Average(), rnd);
                        price.price5 = Math.Round(ll5.Average(), rnd);
                        price.price7 = Math.Round(ll7.Average(), rnd);

                        SiseEvents.Instance.OnSiseHandler(itemCode, price);

                        if (isSiseBinding)
                        {
                            BindSise(itemCode, price);
                        }
                    }
                }
                catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); }
            }
        }
示例#3
0
        public static int GetItemCodeRoundNum(string code)
        {
            int num = ItemCodeSet.GetItemRoundNum(code);

            return(num);
        }
示例#4
0
        private void Chart_MouseMove(object sender, MouseEventArgs e)
        {
            //if (chart.Annotations.Count == 0)
            //{
            //    createXYLineAnnotation();
            //    createYXLineAnnotation();
            //}

            HitTestResult result = chart.HitTest(e.X, e.Y);

            if (result.ChartArea == null)
            {
                return;
            }

            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea = result.ChartArea;
            int minX = 0, minY = 0, maxX = 0, maxY = 0;

            minX = (int)chartArea.Position.X;
            maxX = (int)chartArea.Position.X + (int)(chartArea.Position.Width * chart.Width / 100);
            minY = (int)chartArea.Position.Y;
            maxY = (int)chartArea.Position.Y + (int)(chartArea.Position.Height * chart.Height / 100);

            if (e.Location.X < minX)
            {
                return;
            }
            if (e.Location.X > maxX - 50)
            {
                return;
            }
            //if (e.Location.Y < minY) return;
            //if (e.Location.Y > maxY - 20) return;

            var yv = chartArea.AxisY2.PixelPositionToValue(e.Y);

            if (Double.IsInfinity(yv) || Double.IsNaN(yv))
            {
                return;
            }

            if (result.ChartArea.Name == "ca1")
            {
                yLines[0].AnchorY = yv;
            }
            else if (result.ChartArea.Name == "ca2")
            {
                yLines[1].AnchorY = yv;
            }
            else if (result.ChartArea.Name == "ca3")
            {
                yLines[2].AnchorY = yv;
            }
            else if (result.ChartArea.Name == "ca4")
            {
                yLines[3].AnchorY = yv;
            }
            else if (result.ChartArea.Name == "ca5")
            {
                yLines[4].AnchorY = yv;
            }
            else if (result.ChartArea.Name == "ca6")
            {
                yLines[5].AnchorY = yv;
            }
            else
            {
                yLines[0].AnchorY = yv;
            }

            yLineLabel.Visible  = true;
            yLineLabel.Location = new Point(minX, e.Location.Y);
            yLineLabel.Text     = Math.Round(yv, ItemCodeSet.GetItemRoundNum(ItemCode)).ToString();


            var xv = chartArea.AxisX.PixelPositionToValue(e.X);

            if (Double.IsInfinity(xv) || Double.IsNaN(xv))
            {
                return;
            }

            xLineLabel.Location = new Point(e.Location.X - 10, maxY - 20);
            if (result.PointIndex > -1)
            {
                var dtime = DateTime.FromOADate(result.Series.Points[result.PointIndex].XValue);
                xLineLabel.Text    = dtime.ToString(chartArea.AxisX.LabelStyle.Format);
                xLineLabel.Visible = true;
            }
            else
            {
                xLineLabel.Visible = false;
            }

            foreach (var xLine in xLines)
            {
                xLine.AnchorX = xv;
            }
        }