Exemplo n.º 1
0
        private void readTrackFile(TradeMaster master)
        {
            if (trackFileList != null && trackFileList.Count > 0)
            {

                string trackFileName = "Track_" + master.Now.Year + "_" + master.Now.Month + "_" + master.NowDay + ".txt";

                ConfigFile trackFile = trackFileList[trackFileList.Count - 1];

                List<string> contextList = new List<string>();

                if (trackFile != null)
                {

                    tradeCodeLastDay = trackFile.readConfig("TradeCode");

                    textBox_tradeCodeLastDay.Text = tradeCodeLastDay;

                    if (tradeCode != null && tradeCodeLastDay != null && !tradeCodeLastDay.Trim().Equals(""))
                    {
                        if (!tradeCode.Trim().Equals(tradeCodeLastDay))//交易月份不同
                        {
                            return;
                        }
                        else//交易月份相同
                        {
                            master.Stage = TradeMaster.Stage_Last_Day;
                        }
                    }

                    if (!trackFileName.Trim().Equals(trackFile.getFileName().Trim()))//不是今天的檔案
                    {


                        if (!trackFile.isEndTrade())
                        {

                            List<string> trackLines = new List<string>();

                            String tmpStr = "";

                            while (trackFile.hasNext())
                            {//把上一個交易日的軌跡檔寫進今天的軌跡檔內

                                tmpStr = trackFile.getLine().Trim();

                                if (null != tmpStr)
                                {

                                    trackLines.Add(tmpStr);

                                    if (tmpStr.Equals("EndTrade"))
                                    {
                                        trackLines.Clear();
                                    }
                                }
                            }

                            for (int i = 0; i < trackLines.Count; i++)
                            {
                                master.trackMsg(trackLines[i]);
                            }
                        }
                    }


                    contextList = trackFile.readMultiLineConfig("NewTrade", "EndTrade");

                    if (contextList != null && contextList.Count >= 1)
                    {
                        master.IsStartOrderLastDay = true;

                        contextList.Clear();
                    }



                    contextList = trackFile.readMultiLineConfig("OrderPrice", "EndTrade");

                    if (contextList != null && contextList.Count >= 1)
                    {
                        for (int i = 0; i < contextList.Count; i++)
                        {
                            //orderPriceList.Add(Convert.ToDouble(contexList[i]));
                            if (i == 0)
                            {
                                master.OrderPrice = Convert.ToInt16(contextList[0]);
                            }

                            master.OrderNewPriceList.Add(Convert.ToInt16(contextList[i]));

                            master.OrderNewPrice = Convert.ToInt16(contextList[i]);

                        }

                        contextList.Clear();
                    }

                    contextList = trackFile.readMultiLineConfig("BuyOrSell", "EndTrade");

                    if (contextList != null && contextList.Count >= 1)
                    {
                        master.OrderDircetion = contextList[contextList.Count - 1];


                        master.NowTradeType = contextList[contextList.Count - 1];


                        contextList.Clear();
                    }

                    contextList = trackFile.readMultiLineConfig("MaxPrice", "EndTrade");

                    if (contextList != null && contextList.Count >= 1)
                    {
                        master.MaxTradePointLastDay = Convert.ToInt16(contextList[contextList.Count - 1]);

                        contextList.Clear();
                    }

                    contextList = trackFile.readMultiLineConfig("MinPrice", "EndTrade");

                    if (contextList != null && contextList.Count >= 1)
                    {
                        master.MinTradePointLastDay = Convert.ToInt16(contextList[contextList.Count - 1]);

                        contextList.Clear();
                    }


                    contextList = trackFile.readMultiLineConfig("PrevStopPrice", "EndTrade");

                    if (contextList != null && contextList.Count >= 1)
                    {
                        master.PrevStopPrice = Convert.ToInt16(contextList[contextList.Count - 1]);

                        contextList.Clear();
                    }

                    contextList = trackFile.readMultiLineConfig("StopPrice", "EndTrade");

                    if (contextList != null && contextList.Count >= 1)
                    {
                        master.StopPrice = Convert.ToInt16(contextList[contextList.Count - 1]);

                        contextList.Clear();
                    }

                    contextList = trackFile.readMultiLineConfig("ContinueLoseTimes", "EndTrade");

                    if (contextList != null && contextList.Count >= 1)
                    {
                        master.ContinueLoseTimes = Convert.ToInt16(contextList[contextList.Count - 1]);

                        contextList.Clear();
                    }


                    trackFile.close();
                    trackFile = null;
                }
            }
        }