Exemplo n.º 1
0
        /// <summary>
        /// 载入股票部分
        /// </summary>
        /// <param name="rootXml"></param>
        private void LoadStock(XmlElement rootXml)
        {
            foreach (XmlNode node in rootXml)
            {
                #region 股票

                XmlElement exElem = node as XmlElement;
                if (exElem == null)
                {
                    continue;
                }

                //解析交易所ID,默认时间
                string           exchangeId   = exElem.GetAttribute(IdAttr).Trim();
                List <TimeSlice> lstTimeSlice = ParseTimeSlice(exElem.GetAttribute(TradingTimeTag).Trim());

                //维护股票的默认时间段
                _dictDefaultStockTradingFrame.Add(exchangeId, lstTimeSlice);

                TradingFrameSeries lstTradeFrames = new TradingFrameSeries();

                //然后读取所有的交易所
                foreach (XmlNode subNode in exElem.ChildNodes)
                {
                    XmlElement subElem = subNode as XmlElement;

                    DateTime         beginDay         = ParseDate(subElem.GetAttribute(BeginDayTag).Trim());
                    List <TimeSlice> tradingFrameExch = ParseTimeSlice(subElem.GetAttribute(TradingTimeTag).Trim());

                    var i = 0;
                    for (; i < lstTradeFrames.Count; ++i)
                    {
                        if (beginDay < lstTradeFrames[i].BeginDay)
                        {
                            lstTradeFrames.Insert(i, new TradingFrame(beginDay, tradingFrameExch));
                            break;
                        }
                    }

                    if (i == lstTradeFrames.Count)
                    {
                        lstTradeFrames.Add(new TradingFrame(beginDay, tradingFrameExch));
                    }

                    //lstTradeFrames.Add(new TradingFrame(beginDay, tradingFrameExch));
                }
                //交易所的
                _dictStockTradingFrame.Add(exchangeId, lstTradeFrames);
                #endregion
            }
        }
Exemplo n.º 2
0
        private void LoadFutureOption(XmlElement rootXml)
        {
            foreach (XmlNode node in rootXml)
            {
                #region 期货期权

                XmlElement exElem = node as XmlElement;
                if (exElem == null)
                {
                    continue;
                }

                //解析4个交易所

                //解析交易所ID,默认时间
                string           exchangeId   = exElem.GetAttribute(IdAttr).Trim();
                List <TimeSlice> lstTimeSlice = ParseTimeSlice(exElem.GetAttribute(TradingTimeTag).Trim());

                //维护股票的默认时间段
                _dictDefaultFutureOptionTradingFrame.Add(exchangeId, lstTimeSlice);
                //然后每个交易所下面的品种都要整理出来
                if (exElem.ChildNodes.Count > 0)
                {
                    XmlNode productsNode = exElem.ChildNodes[0];

                    //然后读取所有的交易所
                    foreach (XmlNode prodNode in productsNode.ChildNodes)
                    {
                        //这里是一个品种的节点
                        XmlElement prodElem = prodNode as XmlElement;

                        string             productId      = prodElem.GetAttribute(IdAttr).Trim();
                        TradingFrameSeries lstTradeFrames = new TradingFrameSeries();

                        foreach (XmlNode frameNode in prodNode.ChildNodes)
                        {
                            XmlElement frameElem = frameNode as XmlElement;
                            if (frameElem != null && frameElem.Name == "TradingFrame")
                            {
                                DateTime         beginDay         = ParseDate(frameElem.GetAttribute(BeginDayTag).Trim());
                                List <TimeSlice> tradingFrameExch = ParseTimeSlice(frameElem.GetAttribute(TradingTimeTag).Trim());

                                var i = 0;
                                for (; i < lstTradeFrames.Count; ++i)
                                {
                                    if (beginDay < lstTradeFrames[i].BeginDay)
                                    {
                                        lstTradeFrames.Insert(i, new TradingFrame(beginDay, tradingFrameExch));
                                        break;
                                    }
                                }

                                if (i == lstTradeFrames.Count)
                                {
                                    lstTradeFrames.Add(new TradingFrame(beginDay, tradingFrameExch));
                                }

                                //lstTradeFrames.Add(new TradingFrame(beginDay, tradingFrameExch));
                            }
                            else if (frameElem != null && frameElem.Name == "LimitValue")
                            {
                                double limit = 0.0;
                                double.TryParse(frameElem.GetAttribute(UpLimit).Trim(), out limit);
                                _limitDictionary.Add(productId.ToLower(), limit);
                            }
                        }
                        _dictFutureOptionTradingFrame.Add(productId, lstTradeFrames);
                    }
                }

                #endregion
            }
        }