/// <summary> /// 启动策略执行线程 /// </summary> public void RUN() { ThreadProc _thread = new ThreadProc(_threadProc); excutedThread = new Thread(new ThreadStart(_thread)); //获取订阅列表 List <managedsecurityindex> subscribelist = new List <managedsecurityindex>(); if (Type == "OPEN") { //开仓 open_args args = InitArgs(open_para.WeightList, LiStockOrder, CT, open_para.OP, open_para.INDEX, HD); m_strategy_open.init(args); subscribelist = m_strategy_open.getsubscribelist().ToList(); } else if (Type == "CLOSE") { //平仓 //预付费率和期货开仓点 close_args args = InitArgs(close_para.WeightList, LiStockOrder, CT, close_para.INDEX, HD, (double)close_para.SD, (double)close_para.SA, (double)close_para.COE, close_para.SP, (double)close_para.SD, (double)close_para.PE, close_para.Charge); m_strategy_close.init(args); subscribelist = m_strategy_close.getsubscribelist().ToList(); } RunningTime = DateTime.Now; //获取订阅列表 bool change = false; foreach (var item in subscribelist) { _subscribe.Add(item.cSecurity_code); change = true; } bSubscribeChange = change; excutedThread.Start(); Thread.Sleep(100); }
/// <summary> /// 初始化开仓参数列表 /// </summary> /// <param name="WeightList">权重列表</param> /// <param name="LiStockOrder">持仓列表</param> /// <param name="CT">期货</param> /// <param name="OP">开仓点位</param> /// <param name="INDEX">开仓指数</param> /// <param name="HD">手数</param> /// <returns>开仓参数实例</returns> open_args InitArgs(Dictionary <String, double> WeightList, Dictionary <string, int> LiStockOrder, String CT, double OP, string INDEX, int HD) { open_args args = new open_args(); List <managedIndexWeights> weight = new List <managedIndexWeights>(); List <managedstockposition> position = new List <managedstockposition>(); string weightString = String.Empty; string positionString = String.Empty; int weightNum = 0; int positionNum = 0; foreach (var item in WeightList) { string code = item.Key.Substring(1); string type = item.Key.Substring(0, 1); double weightvalue = item.Value; weightString += (code + ";" + type + ";" + weightvalue.ToString() + "|"); weightNum++; } weightString += "*"; foreach (var item in LiStockOrder) { string code = item.Key.Substring(1); string type = item.Key.Substring(0, 1); int tradeVolume = item.Value; positionString += (code + ";" + type + ";" + tradeVolume.ToString() + "|"); positionNum++; } positionString += "*"; args.bTradingAllowed = false; args.contractCode = CT; args.dPositiveOpenDelta = OP; args.indexCode = INDEX; args.nHands = HD; args.WEIGHTLIST = weightString; args.POSITIONLIST = positionString; args.WEIGHTNUM = weightNum; args.POSITIONNUM = positionNum; return(args); }
public void open_Process(int seqid, TProtocol iprot, TProtocol oprot) { open_args args = new open_args(); args.Read(iprot); iprot.ReadMessageEnd(); open_result result = new open_result(); try { result.Success = iface_.open(args.Path); } catch (ThriftIOException ouch) { result.Ouch = ouch; } oprot.WriteMessageBegin(new TMessage("open", TMessageType.Reply, seqid)); result.Write(oprot); oprot.WriteMessageEnd(); oprot.Transport.Flush(); }
public void send_open(Pathname path) { oprot_.WriteMessageBegin(new TMessage("open", TMessageType.Call, seqid_)); open_args args = new open_args(); args.Path = path; args.Write(oprot_); oprot_.WriteMessageEnd(); oprot_.Transport.Flush(); }
/// <summary> /// 初始化开仓参数列表 /// </summary> /// <param name="WeightList">权重列表</param> /// <param name="LiStockOrder">持仓列表</param> /// <param name="CT">期货</param> /// <param name="OP">开仓点位</param> /// <param name="INDEX">开仓指数</param> /// <param name="HD">手数</param> /// <returns>开仓参数实例</returns> open_args InitArgs(Dictionary<String, double> WeightList, Dictionary<string, int> LiStockOrder, String CT, double OP, string INDEX, int HD) { open_args args = new open_args(); List<managedIndexWeights> weight = new List<managedIndexWeights>(); List<managedstockposition> position = new List<managedstockposition>(); string weightString = String.Empty; string positionString = String.Empty; int weightNum = 0; int positionNum = 0; foreach (var item in WeightList) { string code = item.Key.Substring(1); string type = item.Key.Substring(0, 1); double weightvalue = item.Value; weightString += (code + ";" + type + ";" + weightvalue.ToString() + "|"); weightNum++; } weightString += "*"; foreach (var item in LiStockOrder) { string code = item.Key.Substring(1); string type = item.Key.Substring(0, 1); int tradeVolume = item.Value; positionString += (code + ";" + type + ";" + tradeVolume.ToString() + "|"); positionNum++; } positionString += "*"; args.bTradingAllowed = false; args.contractCode = CT; args.dPositiveOpenDelta = OP; args.indexCode = INDEX; args.nHands = HD; args.WEIGHTLIST = weightString; args.POSITIONLIST = positionString; args.WEIGHTNUM = weightNum; args.POSITIONNUM = positionNum; return args; }