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); } } } }
public virtual List <StrategyParam> ParseParam(string sParamName, string sParamValue) { List <StrategyParam> oLstParams = new List <StrategyParam>(); // StrategyParam oParam = null; if (string.Empty != sParamName && string.Empty != sParamValue) { string[] arParamNames = sParamName.Split(';'); string[] arParamValues = sParamValue.Split(';'); if (arParamNames.Length > 0 && arParamNames.Length == arParamValues.Length) { for (int i = 0; i < arParamNames.Length; i++) { StrategyParam oParam = new StrategyParam(); oParam.ParamName = arParamNames[i]; oParam.ParamValue = arParamValues[i]; oLstParams.Add(oParam); } } } return(oLstParams); }