Example #1
0
 private void ConnectToMcControl_EventRealMCData(RealMarketMCData threeKlineInfo)
 {
     if (m_canBroadCastData)
     {
         this.m_redisConn.Publish <RealMarketMCData>(Entity.CHANNEL, threeKlineInfo);
     }
 }
Example #2
0
        private void RefreashChartData(RealMarketMCData data)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new Action <RealMarketMCData>(RefreashChartData), data);
                return;
            }

            if (data == null)
            {
                return;
            }
            if (data.ThreeBarAgoInfo == null)
            {
                return;
            }
            if (data.TwoBarAgoInfo == null)
            {
                return;
            }
            if (data.NowBarInfo == null)
            {
                return;
            }

            //清空
            this.chart_MarketData.Series["Series_K"].Points.Clear();
            this.chart_MarketData.Series["Series_MA"].Points.Clear();
            this.chart_KD.Series["Series_80"].Points.Clear();
            this.chart_KD.Series["Series_20"].Points.Clear();
            this.chart_KD.Series["Series_K"].Points.Clear();
            this.chart_KD.Series["Series_D"].Points.Clear();

            double[] bar1Info = data.NowBarInfo;

            double[] bar1AgoOHLC = new double[] { bar1Info[0], bar1Info[1], bar1Info[2], bar1Info[3] };
            double   bar1Avg     = bar1Info[4];
            double   bar1K       = bar1Info[5];
            double   bar1D       = bar1Info[6];

            this.chart_MarketData.Series["Series_K"].Points.Add(bar1AgoOHLC);

            this.chart_MarketData.Series["Series_MA"].Points.Add(bar1Avg);

            //表2
            this.chart_KD.Series["Series_80"].Points.Add(80);
            this.chart_KD.Series["Series_80"].Points.Add(80);
            this.chart_KD.Series["Series_80"].Points.Add(80);
            this.chart_KD.Series["Series_20"].Points.Add(20);
            this.chart_KD.Series["Series_20"].Points.Add(20);
            this.chart_KD.Series["Series_20"].Points.Add(20);

            this.chart_KD.Series["Series_K"].Points.Add(bar1K);
            this.chart_KD.Series["Series_D"].Points.Add(bar1D);
        }
Example #3
0
        /// <summary>
        /// 测试发布数据
        /// </summary>
        private void TestPublishData()
        {
            Random random1    = new Random();
            int    randomData = random1.Next(0, 1001);

            //for (int i = 0; i < 10; i++)
            {
                RealMarketMCData data = new RealMarketMCData();
                data.NowBarInfo = new double[] { randomData, randomData, randomData, randomData, randomData, 30, 20 };

                Tester.m_redisConn.Publish <RealMarketMCData>(Entity.CHANNEL, data);
                //System.Threading.Thread.Sleep(1000);
            }
        }
Example #4
0
        public void Sub()
        {
            m_redisConn.Subscribe(Entity.CHANNEL, (channel, message) =>
            {
                RealMarketMCData data = RedisHelper.Deserialize <RealMarketMCData>(message);

                if (data == null)
                {
                    return;
                }

                RefreashChartData(data);
            });

            m_redisConn.Subscribe(Entity.CHANNELTRADE, (channel, message) =>
            {
                string tradeInfo = RedisHelper.Deserialize <string>(message);
                Debug.WriteLine(tradeInfo);
            });
        }
Example #5
0
        //线程获取行情,并广播出去;
        private void LoginWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            while (true)
            {
                if (m_MCDataServer != null)
                {
                    string mcData = m_MCDataServer.GetNextMCEditOutInfo();
                    if (mcData != null && mcData != "")
                    {
                        //依次-->:
                        //前一根的:开,高,低,收,AVg,K,D 后一根的 ,当前的,三项
                        //   1180518.00 | 150000.00 | 110140.00 |  110140.00 | 11233 | 88 | 79
                        // | 1180518.00 | 150000.00 | 110140.00 |  110140.00 | 11233 | 88 | 79
                        // | 1180518.00 | 150000.00 | 110140.00 |  110140.00 | 11233 | 88 | 79
                        string[] arrayList = mcData.Split('|');
                        InsertTextInfo(mcData);

                        double[] threeAgo = new double[] { Convert.ToDouble(arrayList[0].Trim()), Convert.ToDouble(arrayList[1].Trim()), Convert.ToDouble(arrayList[2].Trim()), Convert.ToDouble(arrayList[3].Trim()), Convert.ToDouble(arrayList[4].Trim()), Convert.ToDouble(arrayList[5].Trim()), Convert.ToDouble(arrayList[6].Trim()) };
                        double[] twoAgo   = new double[] { Convert.ToDouble(arrayList[7].Trim()), Convert.ToDouble(arrayList[8].Trim()), Convert.ToDouble(arrayList[9].Trim()), Convert.ToDouble(arrayList[10].Trim()), Convert.ToDouble(arrayList[11].Trim()), Convert.ToDouble(arrayList[12].Trim()), Convert.ToDouble(arrayList[13].Trim()) };
                        double[] oneAgo   = new double[] { Convert.ToDouble(arrayList[14].Trim()), Convert.ToDouble(arrayList[15].Trim()), Convert.ToDouble(arrayList[16].Trim()), Convert.ToDouble(arrayList[17].Trim()), Convert.ToDouble(arrayList[18].Trim()), Convert.ToDouble(arrayList[19].Trim()), Convert.ToDouble(arrayList[20].Trim()) };

                        RealMarketMCData threeKlineInfo = new RealMarketMCData()
                        {
                            ThreeBarAgoInfo = threeAgo,
                            TwoBarAgoInfo   = twoAgo,
                            NowBarInfo      = oneAgo
                        };

                        if (EventRealMCData != null)
                        {
                            EventRealMCData(threeKlineInfo);
                        }
                    }
                }
            }
        }