protected override void ParseStrategyContext(System.Xml.XmlNode oXmlNode, ref List <StrategyContext> oLstContext)
        {
            if (0 == oXmlNode.Name.CompareTo("strategy_case"))
            {
                string sStatus = oXmlNode.Attributes["status"].Value;
                if (sStatus != null)
                {
                    if (0 == sStatus.CompareTo("0"))//未加载
                    {
                        StrategyContext oStragtegySer = new StrategyContext();
                        oStragtegySer.Uid = oXmlNode.Attributes["id"].Value;
                        XmlNodeList xmlNodeLst = oXmlNode.ChildNodes;
                        foreach (XmlNode oChildNode in xmlNodeLst)
                        {
                            //if (0 == oChildNode.Name.CompareTo("id"))
                            //{
                            //    oStragtegySer.Uid = oChildNode.FirstChild.Value;
                            //}
                            if (0 == oChildNode.Name.CompareTo("name"))
                            {
                                oStragtegySer.StrategyName = oChildNode.FirstChild.Value;
                            }
                            else if (0 == oChildNode.Name.CompareTo("params"))
                            {
                                XmlNodeList oParamLst = oChildNode.ChildNodes;
                                foreach (XmlNode oParamNode in oParamLst)
                                {
                                    StrategyParam oParam = new StrategyParam();
                                    oParam.ParamName = oParamNode.Attributes["name"].Value;
                                    if (string.Empty == oParam.ParamName)
                                    {
                                        continue;
                                    }
                                    oParam.ParamValue = oParamNode.Attributes["value"].Value;
                                    oStragtegySer.Params.Add(oParam);
                                }
                            }
                            else if (0 == oChildNode.Name.CompareTo("contract_postion"))
                            {
                                XmlNodeList oPostionList = oChildNode.ChildNodes;
                                foreach (XmlNode oPostionNode in oPostionList)
                                {
                                    ContractPostion oPostion = new ContractPostion();
                                    oPostion.ContractCode = oPostionNode.Attributes["code"].Value;
                                    oPostion.ContractName = oPostionNode.Attributes["name"].Value;
                                    oPostion.Postion      = Int32.Parse(oPostionNode.Attributes["postion"].Value);
                                    oPostion.Direction    = Int32.Parse(oPostionNode.Attributes["dir"].Value);
                                    oPostion.OpenPrice    = double.Parse(oPostionNode.Attributes["open_price"].Value);
                                    oPostion.OpenTime     = oPostionNode.Attributes["open_time"].Value;

                                    oStragtegySer.Postions.Add(oPostion);
                                }
                            }
                        }

                        oLstContext.Add(oStragtegySer);
                    }
                }
            }
        }
Example #2
0
        //300481;濮阳惠成;100;0.000000;0;20160428 000000$600740;山西焦化;1400;0.000000;0;20160428 000000$
        public virtual List <ContractPostion> ParsePostion(string sPostions)
        {
            List <ContractPostion> oLstPostion = new List <ContractPostion>();

            if (string.Empty != sPostions)
            {
                string[] strPos = sPostions.Split('$');

                for (int i = 0; i < strPos.Length; i++)
                {
                    if (string.Empty == strPos[i])
                    {
                        continue;
                    }

                    string[] tempPos = strPos[i].Split(';');

                    if (tempPos.Length >= 6)
                    {
                        ContractPostion cPos = new ContractPostion();

                        cPos.ContractCode = tempPos[0];
                        cPos.ContractName = tempPos[1];
                        cPos.Postion      = int.Parse(tempPos[2]);
                        cPos.OpenPrice    = double.Parse(tempPos[3]);
                        cPos.Direction    = int.Parse(tempPos[4]);
                        cPos.OpenTime     = tempPos[5];
                        if (tempPos.Length > 6)
                        {
                            cPos.HighPrice = double.Parse(tempPos[6]);
                        }


                        oLstPostion.Add(cPos);
                    }
                }
            }


            return(oLstPostion);
        }