コード例 #1
0
        public override void Receive(object msg)
        {
            Console.WriteLine(" SignalListHandler  Receive ~~~~~~~~~~~ " + msg);
            string[] msgs     = (string[])msg;
            Protocol protocol = AppUtil.ParseProtocol(msgs[1]);

            int paramAmount = int.Parse(msgs[2]);

            if (paramAmount > 0)
            {
                AppContext.SignalDatas.Clear();
                try
                {
                    for (int i = 3; i < msgs.Length; i++)
                    {
                        string signalInfo = msgs[i];
                        if (!string.IsNullOrEmpty(signalInfo))
                        {
                            string[] info   = signalInfo.Split(',');
                            Signal   signal = new Signal();
                            signal.Interval      = AppUtil.StringToInterval(info[0]);
                            signal.Symbol        = AppUtil.ParseSymbol(info[1]);
                            signal.ActPrice      = double.Parse(info[2]);
                            signal.Arrow         = AppUtil.StringToInt(info[3]);
                            signal.ActTime       = DateTime.Parse(info[4]);
                            signal.StopLossPrice = double.Parse(info[5]);
                            if (NULL != info[6])
                            {
                                signal.StopLossTime     = DateTime.Parse(info[6]);
                                signal.StopLoss         = signal.Arrow;
                                signal.StopLossBidPrice = double.Parse(info[13]);
                            }
                            signal.GainTipPrice = double.Parse(info[7]);
                            if (NULL != info[8])
                            {
                                signal.GainTipTime = DateTime.Parse(info[8]);
                                signal.GainTip     = signal.Arrow;
                            }
                            signal.StopGainPrice = double.Parse(info[9]);
                            if (NULL != info[10])
                            {
                                signal.StopGainTime = DateTime.Parse(info[10]);
                                signal.StopGain     = signal.Arrow;
                            }
                            signal.Profit      = int.Parse(info[11]);
                            signal.ProfitPrice = double.Parse(info[13]);
                            if (signal.ProfitPrice != 0 && NULL != info[12])
                            {
                                signal.ProfitTime = DateTime.Parse(info[12]);
                            }
                            AppContext.SignalDatas.Add(signal);
                        }
                    }
                }
                catch (Exception e)
                {
                    LogUtil.Error("  M0004  " + e.StackTrace);
                }
            }
            signals = new Signal[AppContext.SignalDatas.Count];
            AppContext.SignalDatas.CopyTo(signals);
            MethodInvoker mi = new MethodInvoker(InitPriceList);

            priceListView.Invoke(mi);
            mi = new MethodInvoker(InitSignalList);
            signalListView.Invoke(mi);
            mi = new MethodInvoker(InitStatList);
            statListView.Invoke(mi);
            mi = new MethodInvoker(RefreshStatBtn);
            AppContext.TradeExpertControl.Invoke(mi);
        }
コード例 #2
0
        public bool LoadSigFile(string fileName, int startingRow, int rowsLimit, out List <Signal> datas, bool isDecrypt, bool isLocal)
        {
            datas = new List <Signal>();

            int i = 0;

            using (System.IO.TextReader tr = new System.IO.StreamReader(fileName))
            {
                try
                {
                    for (i = 0; i < startingRow + rowsLimit || rowsLimit == 0; i++)
                    {
                        string lineStr = tr.ReadLine();
                        if (lineStr == null)
                        {
                            break;
                        }

                        if (i >= startingRow)
                        {// Parse.
                         //if (isDecrypt)
                         //{
                         //    if (!isLocal)
                         //        lineStr = crypta.decrypt(lineStr);
                         //    else
                         //        lineStr = crypta.localDecrypt(lineStr);
                         //}

                            try
                            {
                                string[] lineSplit = Regex.Split(lineStr, ",");
                                Signal   signal    = new Signal();
                                signal.ActTime      = DateTime.Parse(lineSplit[0]);
                                signal.Arrow        = int.Parse(lineSplit[1]);
                                signal.ActPrice     = double.Parse(lineSplit[2]);
                                signal.GainTip      = int.Parse(lineSplit[3]);
                                signal.GainTipPrice = double.Parse(lineSplit[4]);
                                if (lineSplit[5] != NULL)
                                {
                                    signal.GainTipTime = DateTime.Parse(lineSplit[5]);
                                }
                                signal.StopGain      = int.Parse(lineSplit[6]);
                                signal.StopGainPrice = double.Parse(lineSplit[7]);
                                if (lineSplit[8] != NULL)
                                {
                                    signal.StopGainTime = DateTime.Parse(lineSplit[8]);
                                }
                                signal.StopLoss      = int.Parse(lineSplit[9]);
                                signal.StopLossPrice = double.Parse(lineSplit[10]);
                                if (lineSplit[11] != NULL)
                                {
                                    signal.StopLossTime     = DateTime.Parse(lineSplit[11]);
                                    signal.StopLossBidPrice = double.Parse(lineSplit[13]);
                                }
                                signal.Profit      = int.Parse(lineSplit[12]);
                                signal.ProfitPrice = double.Parse(lineSplit[13]);
                                if (lineSplit[14] != NULL)
                                {
                                    signal.ProfitTime = DateTime.Parse(lineSplit[14]);
                                }
                                LogUtil.Info(" Sig File Loading :::: " + signal);
                                datas.Add(signal);
                            }
                            catch (Exception e)
                            {
                                LogUtil.Info(" His File Loading :::: " + e.StackTrace);
                            }
                        }
                    }
                    Console.WriteLine("ccccccccccccccccccccccccccc  ");
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.ToString());
                    datas.Clear();
                    return(false);
                }
            }
            return(true);
        }
コード例 #3
0
 public override void Send(object msg)
 {
     Console.WriteLine(" InitCompleteHandler  Send ~~~~~~~~~~~ ");
     LogUtil.Info(" InitCompleteHandler  Send ~~~~~~~~~~~ ");
     Client.Send(msg);
 }
コード例 #4
0
        public bool LoadCdlFile(string fileName, int startingRow, int rowsLimit, out List <BarData> datas, bool isDecrypt, bool isLocal)
        {
            datas = new List <BarData>();

            int i = 0;

            using (System.IO.TextReader tr = new System.IO.StreamReader(fileName))
            {
                try
                {
                    for (i = 0; i < startingRow + rowsLimit || rowsLimit == 0; i++)
                    {
                        string lineStr = tr.ReadLine();
                        if (lineStr == null)
                        {
                            break;
                        }

                        if (i >= startingRow)
                        {// Parse.
                         //if (isDecrypt)
                         //{
                         //    if( !isLocal)
                         //        lineStr = crypta.decrypt(lineStr);
                         //    else
                         //        lineStr = crypta.localDecrypt(lineStr);
                         //}

                            try
                            {
                                string[] lineSplit = Regex.Split(lineStr, ",");
                                BarData  barData   = new BarData();
                                string   date      = lineSplit[0].Trim();
                                string   time      = lineSplit[1].Trim();
                                barData.DateTime = new DateTime(int.Parse(date.Substring(0, 4)), int.Parse(date.Substring(4, 2)), int.Parse(date.Substring(6, 2)),
                                                                int.Parse(time.Substring(0, 2)), int.Parse(time.Substring(2, 2)), int.Parse(time.Substring(4, 2))); //DateTime.Parse(lineSplit[0]);//  BarDataHelper.ParseCSVDateTime(lineSplit[0], lineSplit[1]);
                                barData.Open        = double.Parse(lineSplit[2], new System.Globalization.NumberFormatInfo());
                                barData.High        = double.Parse(lineSplit[3], new System.Globalization.NumberFormatInfo());
                                barData.Low         = double.Parse(lineSplit[4], new System.Globalization.NumberFormatInfo());
                                barData.Close       = double.Parse(lineSplit[5], new System.Globalization.NumberFormatInfo());
                                barData.ExLow       = barData.Low;
                                barData.ExHigh      = barData.ExHigh;
                                barData.IsCompleted = true;
                                LogUtil.Info(" His File Loading :::: " + barData);
                                datas.Add(barData);
                            }catch (Exception e) {
                                LogUtil.Info(" His File Loading :::: " + e.StackTrace);
                            }
                        }
                    }
                    Console.WriteLine("ccccccccccccccccccccccccccc  ");
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.ToString());
                    datas.Clear();
                    return(false);
                }
            }

            return(true);
        }
コード例 #5
0
 public override void Send(object msg)
 {
     Console.WriteLine(" ServerCheckHandler  Send ~~~~~~~~~~~ ");
     LogUtil.Info(" ServerCheckHandler  Send ~~~~~~~~~~~ ");
     Client.Send(msg);
 }