public SecurityDefinitionViewItem(FIXSecurityDefinition securityDefinition, byte providerId) : base(new string[5]) { this.securityDefinition = securityDefinition; this.SubItems[0].Text = SecurityDefinitionHelper.GetSymbol(securityDefinition, providerId); this.SubItems[1].Text = ((object)APITypeConverter.InstrumentType.Convert(securityDefinition.SecurityType)).ToString(); this.SubItems[2].Text = securityDefinition.SecurityExchange; this.SubItems[3].Text = securityDefinition.Currency; DateTime?nullable; if (((FIXGroup)securityDefinition).ContainsField(541)) { nullable = new DateTime?(securityDefinition.MaturityDate); } else if (((FIXGroup)securityDefinition).ContainsField(200)) { try { nullable = new DateTime?(new DateTime(int.Parse(securityDefinition.MaturityMonthYear.Substring(0, 4), (IFormatProvider)CultureInfo.InvariantCulture), int.Parse(securityDefinition.MaturityMonthYear.Substring(4, 2), (IFormatProvider)CultureInfo.InvariantCulture), 1)); } catch { nullable = new DateTime?(); } } else { nullable = new DateTime?(); } this.SubItems[4].Text = !nullable.HasValue ? "" : nullable.Value.ToShortDateString(); }
new public void onMessage(QuickFix.FIX43.SecurityDefinition definition, SessionID sessionID) { FIXSecurityDefinition definition1 = new FIXSecurityDefinition(); this.ConvertMessage((QuickFix.Message)definition, (FIXMessage)definition1); this.EmitSecurityDefinition(definition1); }
private static string GetSymbol_OEC(FIXSecurityDefinition definition) { string str = definition.Symbol; if (definition.SecurityType == "FUT" || definition.SecurityType == "OPT") { if (((FIXGroup)definition).ContainsField(541)) { str = str + " " + definition.MaturityDate.ToString("MMMyy", (IFormatProvider)CultureInfo.InvariantCulture); } if (definition.SecurityType == "OPT") { if (((FIXGroup)definition).ContainsField(202)) { str = str + (object)" " + (string)(object)definition.StrikePrice; } if (((FIXGroup)definition).ContainsField(201)) { switch (definition.PutOrCall) { case 0: str = str + " P"; break; case 1: str = str + " C"; break; } } } } return(str); }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (this) { if (!this.IsConnected) { this.EmitError(1, "The current instrument provider not connected."); return; } string[] markets = supportMarkets.Split(','); //是否包含交易市场 if (request.ContainsField(0xcf) && markets.Contains(request.SecurityExchange)) { List <GMSDK.Instrument> gskInsts = _md.GetInstruments(request.SecurityExchange, this.securityTypeFilter, 0); foreach (GMSDK.Instrument gskInst in gskInsts) { FIXSecurityDefinition definition = new FIXSecurityDefinition(request.SecurityReqID, request.SecurityReqID, 4); string[] ss = gskInst.symbol.Split('.'); definition.SecurityExchange = ss[0]; //市场 definition.SecurityID = ss[1]; //代码 definition.SecurityIDSource = "8"; // 8=Exchange Symbol definition.Symbol = gskInst.symbol; switch (gskInst.sec_type) { case 1: definition.SecurityType = "CS"; //股票 break; case 2: definition.SecurityType = "MF"; //基金(Mutual Fund,共同基金) break; case 3: definition.SecurityType = "IDX"; //指数 break; case 4: definition.SecurityType = "FUT"; //期货 break; } //definition.SecuritySubType = symbol.StockType.ToString(); definition.SecurityDesc = gskInst.sec_name; if (definition.SecurityType == "FUT") { definition.ContractMultiplier = gskInst.multiplier; //合约乘数 definition.PctAtRisk = gskInst.margin_ratio; //保证金比例 definition.TickSize = gskInst.price_tick; //价格最小变动单位 } definition.TotNoRelatedSym = gskInsts.Count; if (this.SecurityDefinition != null) { this.SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } } } }
public SecurityDefinitionViewItem(string symbol, FIXSecurityDefinition securityDefinition) { eX4XcIhHpDXt70u2x3N.k8isAcYzkUOGF(); // ISSUE: explicit constructor call base.\u002Ector(new string[5]); this.spCHSgVpLT = securityDefinition; this.SubItems[0].Text = symbol; this.SubItems[1].Text = securityDefinition.SecurityType; this.SubItems[2].Text = securityDefinition.SecurityID; this.SubItems[3].Text = securityDefinition.SecurityExchange; this.SubItems[4].Text = securityDefinition.Currency; }
private static string GetSymbol_TTFIX(FIXSecurityDefinition definition) { List <string> list = new List <string>(); list.Add(definition.Symbol); if (definition.SecurityType == "FUT" || definition.SecurityType == "OPT") { if (((FIXGroup)definition).ContainsField(200)) { int year = int.Parse(definition.MaturityMonthYear.Substring(0, 4), (IFormatProvider)CultureInfo.InvariantCulture); int month = int.Parse(definition.MaturityMonthYear.Substring(4, 2), (IFormatProvider)CultureInfo.InvariantCulture); list.Add(new DateTime(year, month, 1).ToString("MMMyy", (IFormatProvider)CultureInfo.InvariantCulture)); } else if (((FIXGroup)definition).ContainsField(541)) { list.Add(definition.MaturityDate.ToString("MMMyy", (IFormatProvider)CultureInfo.InvariantCulture)); } if (definition.SecurityType == "OPT") { if (((FIXGroup)definition).ContainsField(202)) { list.Add(definition.StrikePrice.ToString((IFormatProvider)CultureInfo.InvariantCulture)); } if (((FIXGroup)definition).ContainsField(201)) { if (definition.PutOrCall == 0) { list.Add("P"); } else { list.Add("C"); } } } } if (definition.SecurityType == "MLEG") { for (int index = 0; index < definition.NoUnderlyings; ++index) { FIXUnderlyingsGroup underlyingsGroup = definition.GetUnderlyingsGroup(index); if (((FIXGroup)underlyingsGroup).ContainsField(313)) { int year = int.Parse(underlyingsGroup.UnderlyingMaturityMonthYear.Substring(0, 4), (IFormatProvider)CultureInfo.InvariantCulture); int month = int.Parse(underlyingsGroup.UnderlyingMaturityMonthYear.Substring(4, 2), (IFormatProvider)CultureInfo.InvariantCulture); list.Add(new DateTime(year, month, 1).ToString("MMMyy", CultureInfo.InvariantCulture)); } } } return(string.Join(" ", (IEnumerable <string>)list)); }
private static string GetSymbol_IB(FIXSecurityDefinition definition) { switch (definition.SecurityType) { case "FOR": if (!string.IsNullOrEmpty(definition.Currency)) { return(string.Format("{0}/{1}", definition.Symbol, definition.Currency)); } else { return(definition.Symbol); } case "FUT": case "OPT": case "FOP": List <string> list = new List <string>(); list.Add(definition.Symbol); if (((FIXGroup)definition).ContainsField(541)) { list.Add(definition.MaturityDate.ToString("MMMyy", (IFormatProvider)CultureInfo.InvariantCulture)); } if (((FIXGroup)definition).ContainsField(202)) { list.Add(definition.StrikePrice.ToString((IFormatProvider)CultureInfo.InvariantCulture).Replace('.', '\'')); } if (((FIXGroup)definition).ContainsField(201)) { switch (definition.PutOrCall) { case 0: list.Add("P"); break; case 1: list.Add("C"); break; } } return(string.Join(" ", list)); default: return(definition.Symbol); } }
public static string GetSymbol(FIXSecurityDefinition definition, byte providerId) { switch (providerId) { case FreeQuant.Providers.ProviderId.IB: // 4 return(SecurityDefinitionHelper.GetSymbol_IB(definition)); case FreeQuant.Providers.ProviderId.TTFIX: return(SecurityDefinitionHelper.GetSymbol_TTFIX(definition)); case FreeQuant.Providers.ProviderId.OpenECry: // 22: return(SecurityDefinitionHelper.GetSymbol_OEC(definition)); default: return(definition.Symbol); } }
private void NIfMaIjWQ1([In] FIXSecurityDefinition obj0) { if (obj0.SecurityResponseType == 100) { this.jdxMcrTVkr.Minimum = 0; this.jdxMcrTVkr.Maximum = obj0.TotNoRelatedSym; this.jdxMcrTVkr.Value = obj0.BodyLength; Application.DoEvents(); } else { ++this.xohMqXQHT2; this.jdxMcrTVkr.Maximum = obj0.TotNoRelatedSym; this.jdxMcrTVkr.Value = this.xohMqXQHT2; if (this.xohMqXQHT2 == obj0.TotNoRelatedSym) { this.jA3M607Con(true); } this.Av6MXcQF5Z.Items.Add((ListViewItem) new SecurityDefinitionViewItem(this.DsUMrBufkW(obj0), obj0)); } }
private void provider_SecurityDefinition(object sender, SecurityDefinitionEventArgs args) { if (!this.doWork) { return; } FIXSecurityDefinition securityDefinition = args.SecurityDefinition; if (!(securityDefinition.SecurityReqID == this.request.SecurityReqID)) { return; } this.securityDefinitions.Add(securityDefinition); this.UpdateProgress(this.securityDefinitions.Count, securityDefinition.TotNoRelatedSym); Thread.Sleep(0); if (this.securityDefinitions.Count != securityDefinition.TotNoRelatedSym) { return; } this.doWork = false; }
public int Compare(object x, object y) { FIXSecurityDefinition securityDefinition1 = ((SecurityDefinitionViewItem)x).SecurityDefinition; FIXSecurityDefinition securityDefinition2 = ((SecurityDefinitionViewItem)y).SecurityDefinition; int num; switch (this.column) { case 0: num = securityDefinition1.Symbol.CompareTo(securityDefinition2.Symbol); break; case 1: num = securityDefinition1.SecurityType.CompareTo(securityDefinition2.SecurityType); break; case 2: num = securityDefinition1.SecurityExchange.CompareTo(securityDefinition2.SecurityExchange); break; case 3: num = securityDefinition1.Currency.CompareTo(securityDefinition2.Currency); break; case 4: num = securityDefinition1.MaturityDate.CompareTo(securityDefinition2.MaturityDate); break; default: throw new ArgumentException(string.Format("Unknown column number", (object)this.column)); } if (this.descending) { num = -num; } return(num); }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (this) { if (!_bTdConnected) { EmitError(-1, -1, "交易没有连接,无法获取合约列表"); tdlog.Error("交易没有连接,无法获取合约列表"); return; } string symbol = request.ContainsField(EFIXField.Symbol) ? request.Symbol : null; string securityType = request.ContainsField(EFIXField.SecurityType) ? request.SecurityType : null; string securityExchange = request.ContainsField(EFIXField.SecurityExchange) ? request.SecurityExchange : null; #region 过滤 List <CThostFtdcInstrumentField> list = new List <CThostFtdcInstrumentField>(); foreach (CThostFtdcInstrumentField inst in _dictInstruments.Values) { int flag = 0; if (null == symbol) { ++flag; } else if (inst.InstrumentID.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (inst.ExchangeID.ToUpper().StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (securityType == GetSecurityType(inst)) { ++flag; } } if (3 == flag) { list.Add(inst); } } #endregion list.Sort(SortCThostFtdcInstrumentField); //如果查出的数据为0,应当想法立即返回 if (0 == list.Count) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = 1//有个除0错误的问题 }; if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } foreach (CThostFtdcInstrumentField inst in list) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count }; { string securityType2 = GetSecurityType(inst); definition.AddField(EFIXField.SecurityType, securityType2); } { double x = inst.PriceTick; if (x > 0.00001) { int i = 0; for (; x - (int)x != 0; ++i) { x = x * 10; } definition.AddField(EFIXField.PriceDisplay, string.Format("F{0}", i)); definition.AddField(EFIXField.TickSize, inst.PriceTick); } } #if CTP definition.AddField(EFIXField.Symbol, inst.InstrumentID); #elif CTPZQ definition.AddField(EFIXField.Symbol, GetYahooSymbol(inst.InstrumentID, inst.ExchangeID)); #endif definition.AddField(EFIXField.SecurityExchange, inst.ExchangeID); definition.AddField(EFIXField.Currency, "CNY");//Currency.CNY definition.AddField(EFIXField.SecurityDesc, inst.InstrumentName); definition.AddField(EFIXField.Factor, (double)inst.VolumeMultiple); if (inst.ProductClass == TThostFtdcProductClassType.Futures || inst.ProductClass == TThostFtdcProductClassType.Options) { try { definition.AddField(EFIXField.MaturityDate, DateTime.ParseExact(inst.ExpireDate, "yyyyMMdd", CultureInfo.InvariantCulture)); } catch (Exception ex) { tdlog.Warn("合约:{0},字段内容:{1},{2}", inst.InstrumentID, inst.ExpireDate, ex.Message); } //if (inst.ProductClass == TThostFtdcProductClassType.Options) //{ // // 支持中金所,大商所,郑商所 // var match = Regex.Match(inst.InstrumentID, @"(\d+)(-?)([CP])(-?)(\d+)"); // if (match.Success) // { // definition.AddField(EFIXField.PutOrCall, match.Groups[3].Value == "C" ? FIXPutOrCall.Call : FIXPutOrCall.Put); // definition.AddField(EFIXField.StrikePrice, double.Parse(match.Groups[5].Value)); // } //} } // 中金所仿真平台下,居然全设的是股票 var match = Regex.Match(inst.InstrumentID, @"(\d+)(-?)([CP])(-?)(\d+)"); if (match.Success) { definition.AddField(EFIXField.PutOrCall, match.Groups[3].Value == "C" ? FIXPutOrCall.Call : FIXPutOrCall.Put); definition.AddField(EFIXField.StrikePrice, double.Parse(match.Groups[5].Value)); } FIXSecurityAltIDGroup group = new FIXSecurityAltIDGroup(); group.SecurityAltID = inst.InstrumentID; group.SecurityAltExchange = inst.ExchangeID; group.SecurityAltIDSource = this.Name; definition.AddGroup(group); //还得补全内容 if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } } }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (this) { if (!_bTdConnected) { EmitError(-1, -1, "交易没有连接,无法获取合约列表"); tdlog.Error("交易没有连接,无法获取合约列表"); return; } string symbol = request.ContainsField(EFIXField.Symbol) ? request.Symbol : null; string securityType = request.ContainsField(EFIXField.SecurityType) ? request.SecurityType : null; string securityExchange = request.ContainsField(EFIXField.SecurityExchange) ? request.SecurityExchange : null; #region 过滤 List <DFITCExchangeInstrumentRtnField> list = new List <DFITCExchangeInstrumentRtnField>(); foreach (DFITCExchangeInstrumentRtnField inst in _dictInstruments.Values) { int flag = 0; if (null == symbol) { ++flag; } else if (inst.InstrumentID.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (inst.ExchangeID.ToUpper().StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (FIXSecurityType.Future == securityType) { if (DFITCInstrumentTypeType.COMM_TYPE == inst.instrumentType) { ++flag; } } //else if (FIXSecurityType.MultiLegInstrument == securityType)//理解上是否有问题 //{ // if (TThostFtdcProductClassType.Combination == inst.ProductClass) // { // ++flag; // } //} else if (FIXSecurityType.FutureOption == securityType) { if (DFITCInstrumentTypeType.OPT_TYPE == inst.instrumentType) { ++flag; } } } if (3 == flag) { list.Add(inst); } } #endregion #region 过滤1 List <DFITCAbiInstrumentRtnField> list1 = new List <DFITCAbiInstrumentRtnField>(); foreach (DFITCAbiInstrumentRtnField inst in _dictAbiInstruments.Values) { int flag = 0; if (null == symbol) { ++flag; } else if (inst.InstrumentID.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (inst.ExchangeID.ToUpper().StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (FIXSecurityType.MultiLegInstrument == securityType) { ++flag; } } if (3 == flag) { list1.Add(inst); } } #endregion list.Sort(SortDFITCExchangeInstrumentRtnField); list1.Sort(SortDFITCAbiInstrumentRtnField); //如果查出的数据为0,应当想法立即返回 if (0 == list.Count && 0 == list1.Count) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = 1//有个除0错误的问题 }; if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } #region 期货 期权 foreach (DFITCExchangeInstrumentRtnField inst in list) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count + list1.Count, }; { string securityType2; switch (inst.instrumentType) { case DFITCInstrumentTypeType.COMM_TYPE: securityType2 = FIXSecurityType.Future; break; case DFITCInstrumentTypeType.OPT_TYPE: securityType2 = FIXSecurityType.FutureOption; var match = Regex.Match(inst.InstrumentID, @"(\d+)(-?)([CP])(-?)(\d+)"); if (match.Success) { definition.AddField(EFIXField.PutOrCall, match.Groups[3].Value == "C" ? FIXPutOrCall.Call : FIXPutOrCall.Put); definition.AddField(EFIXField.StrikePrice, double.Parse(match.Groups[5].Value)); } break; default: securityType2 = FIXSecurityType.NoSecurityType; break; } definition.AddField(EFIXField.SecurityType, securityType2); } { double x = inst.minPriceFluctuation; int i = 0; for (; x - (int)x != 0; ++i) { x = x * 10; } definition.AddField(EFIXField.PriceDisplay, string.Format("F{0}", i)); } definition.AddField(EFIXField.Symbol, inst.InstrumentID); definition.AddField(EFIXField.SecurityExchange, inst.ExchangeID); definition.AddField(EFIXField.Currency, "CNY");//Currency.CNY definition.AddField(EFIXField.TickSize, inst.minPriceFluctuation); definition.AddField(EFIXField.SecurityDesc, inst.VarietyName); definition.AddField(EFIXField.Factor, inst.contractMultiplier); try { definition.AddField(EFIXField.MaturityDate, DateTime.ParseExact(inst.instrumentMaturity, "yyyy.MM.dd", CultureInfo.InvariantCulture)); } catch (Exception ex) { tdlog.Warn("合约:{0},字段内容:{1},{2}", inst.InstrumentID, inst.instrumentMaturity, ex.Message); } FIXSecurityAltIDGroup group = new FIXSecurityAltIDGroup(); group.SecurityAltID = inst.InstrumentID; group.SecurityAltExchange = inst.ExchangeID; group.SecurityAltIDSource = this.Name; definition.AddGroup(group); //还得补全内容 if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } #endregion #region 组合 foreach (DFITCAbiInstrumentRtnField inst in list1) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count + list1.Count, }; string securityType2 = FIXSecurityType.MultiLegInstrument; definition.AddField(EFIXField.SecurityType, securityType2); definition.AddField(EFIXField.Symbol, inst.InstrumentID); // definition.AddField(EFIXField.SecurityExchange, inst.ExchangeID); definition.AddField(EFIXField.Currency, "CNY"); //Currency.CNY definition.AddField(EFIXField.SecurityDesc, inst.instrumentName); if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } #endregion } }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (_dictDepthMarketData) { string symbol = request.ContainsField(EFIXField.Symbol) ? request.Symbol : null; string securityType = request.ContainsField(EFIXField.SecurityType) ? request.SecurityType : null; string securityExchange = request.ContainsField(EFIXField.SecurityExchange) ? request.SecurityExchange : null; #region 过滤 List<StructRcvReportEx> list = new List<StructRcvReportEx>(); foreach (StructRcvReport inst in _dictDepthMarketData.Values) { StructRcvReportEx ex = new StructRcvReportEx(inst); int flag = 0; if (null == symbol) { ++flag; } else if (ex.newSymbol.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (ex.yahooExchange.StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (securityType == ex.securityType) { ++flag; } } if (3 == flag) { list.Add(ex); } } #endregion list.Sort(SortCThostFtdcInstrumentField); //如果查出的数据为0,应当想法立即返回 if (0 == list.Count) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = 1//有个除0错误的问题 }; if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } foreach (StructRcvReportEx inst in list) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count }; { definition.AddField(EFIXField.SecurityType, inst.securityType); } { //double x = inst.PriceTick; //if (x > 0.0001) //{ // int i = 0; // for (; x - (int)x != 0; ++i) // { // x = x * 10; // } // definition.AddField(EFIXField.PriceDisplay, string.Format("F{0}", i)); // definition.AddField(EFIXField.TickSize, inst.PriceTick); //} } definition.AddField(EFIXField.Symbol, GetYahooSymbol(inst.newSymbol, inst.yahooExchange)); definition.AddField(EFIXField.SecurityExchange, inst.yahooExchange); definition.AddField(EFIXField.Currency, "CNY");//Currency.CNY definition.AddField(EFIXField.SecurityDesc, inst.RcvReport.StockName); FIXSecurityAltIDGroup group = new FIXSecurityAltIDGroup(); group.SecurityAltID = inst.RcvReport.StockCode; group.SecurityAltExchange = inst.RcvReport.MarketType; group.SecurityAltIDSource = this.Name; definition.AddGroup(group); //还得补全内容 if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } } }
public void Init(FIXSecurityDefinition definition) { this.definition = definition; }
public SecurityDefinitionTypeDescriptor(FIXSecurityDefinition definition) { this.definition = definition; }
public SecurityDefinitionEventArgs(FIXSecurityDefinition definition) : base() { this.SecurityDefinition = definition; }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (this) { string symbol = request.ContainsField(EFIXField.Symbol) ? request.Symbol : null; string securityType = request.ContainsField(EFIXField.SecurityType) ? request.SecurityType : null; string securityExchange = request.ContainsField(EFIXField.SecurityExchange) ? request.SecurityExchange : null; #region 过滤 List<StockInfoEx> list = new List<StockInfoEx>(); foreach (StockInfoEx inst in _dictInstruments.Values) { int flag = 0; if (null == symbol) { ++flag; } else if (inst.stockinfo.szCode.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (inst.market.ToUpper().StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (FIXSecurityType.Future == securityType) { ++flag; } } if (3 == flag) { list.Add(inst); } } #endregion list.Sort(SortStockInfoEx); //如果查出的数据为0,应当想法立即返回 if (0 == list.Count) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = 1//有个除0错误的问题 }; if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } foreach (StockInfoEx inst in list) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count }; definition.AddField(EFIXField.SecurityType, FIXSecurityType.Future); definition.AddField(EFIXField.Symbol, inst.stockinfo.szCode); definition.AddField(EFIXField.SecurityExchange, inst.market); definition.AddField(EFIXField.Currency, "CNY");//Currency.CNY definition.AddField(EFIXField.SecurityDesc, inst.stockinfo.szName); //还得补全内容 if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } } }
private bool AddInstrument(FIXSecurityDefinition securityDefinition) { string symbol = SecurityDefinitionHelper.GetSymbol(securityDefinition, ((IProvider)this.provider).Id); if (InstrumentManager.Instruments.Contains(symbol)) { return(false); } Instrument instrument = new Instrument(symbol, securityDefinition.SecurityType); foreach (FIXField fixField in ((FIXGroup)securityDefinition).Fields) { switch ((int)fixField.Tag) { case 320: case 322: case 323: case 393: case 55: case 167: goto case 320; default: ((FIXGroup)instrument).AddField(fixField); goto case 320; } } for (int index = 0; index < securityDefinition.NoSecurityAltID; ++index) { ((FIXInstrument)instrument).AddGroup(securityDefinition.GetSecurityAltIDGroup(index)); } switch (((IProvider)this.provider).Id) { case (byte)4: if (((FIXInstrument)instrument).Symbol != securityDefinition.Symbol) { instrument.AddSymbol(securityDefinition.Symbol, securityDefinition.SecurityExchange, ((IProvider)this.provider).Name); } ((FIXGroup)instrument).RemoveField(48); break; case (byte)10: instrument.AddSymbol(string.Format("{0}|{1}|1.0", (object)securityDefinition.Symbol, securityDefinition.SecurityID), securityDefinition.SecurityExchange, ((IProvider)this.provider).Name); ((FIXGroup)instrument).RemoveField(48); instrument.AddSymbol(securityDefinition.Symbol, securityDefinition.SecurityExchange, "TT API"); break; case (byte)21: instrument.AddSymbol(securityDefinition.SecurityID, securityDefinition.SecurityExchange, ((IProvider)this.provider).Name); break; case (byte)22: if (((FIXInstrument)instrument).Symbol != securityDefinition.Symbol) { instrument.AddSymbol(securityDefinition.SecurityID, securityDefinition.SecurityExchange, ((IProvider)this.provider).Name); ((FIXGroup)instrument).RemoveField(48); break; } else { break; } } if ((((FIXInstrument)instrument).SecurityType == "FUT" || ((FIXInstrument)instrument).SecurityType == "OPT" || ((FIXInstrument)instrument).SecurityType == "MLEG") && (!((FIXGroup)instrument).ContainsField(541) && ((FIXGroup)instrument).ContainsField(200))) { int year = int.Parse(securityDefinition.MaturityMonthYear.Substring(0, 4), (IFormatProvider)CultureInfo.InvariantCulture); int month = int.Parse(securityDefinition.MaturityMonthYear.Substring(4, 2), (IFormatProvider)CultureInfo.InvariantCulture); ((FIXInstrument)instrument).MaturityDate = new DateTime(year, month, 1); } instrument.Save(); return(true); }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (this) { if (!_bTdConnected) { this.EmitError(-1, -1, "交易没有连接,无法获取合约列表"); return; } string symbol = request.ContainsField(EFIXField.Symbol) ? request.Symbol : null; string securityType = request.ContainsField(EFIXField.SecurityType) ? request.SecurityType : null; string securityExchange = request.ContainsField(EFIXField.SecurityExchange) ? request.SecurityExchange : null; #region 过滤 List <CThostFtdcInstrumentField> list = new List <CThostFtdcInstrumentField>(); foreach (CThostFtdcInstrumentField inst in _dictInstruments.Values) { int flag = 0; if (null == symbol) { ++flag; } else if (inst.InstrumentID.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (inst.ExchangeID.ToUpper().StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (FIXSecurityType.Future == securityType) { if (TThostFtdcProductClassType.Futures == inst.ProductClass) { ++flag; } } else if (FIXSecurityType.MultiLegInstrument == securityType)//理解上是否有问题 { if (TThostFtdcProductClassType.Combination == inst.ProductClass) { ++flag; } } else if (FIXSecurityType.Option == securityType) { if (TThostFtdcProductClassType.Options == inst.ProductClass) { ++flag; } } } if (3 == flag) { list.Add(inst); } } #endregion list.Sort(SortCThostFtdcInstrumentField); //如果查出的数据为0,应当想法立即返回 if (0 == list.Count) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = 1//有个除0错误的问题 }; if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } foreach (CThostFtdcInstrumentField inst in list) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count }; { string securityType2; switch (inst.ProductClass) { case TThostFtdcProductClassType.Futures: securityType2 = FIXSecurityType.Future; break; case TThostFtdcProductClassType.Combination: securityType2 = FIXSecurityType.MultiLegInstrument; //此处是否理解上有不同 break; case TThostFtdcProductClassType.Options: securityType2 = FIXSecurityType.Option; break; default: securityType2 = FIXSecurityType.NoSecurityType; break; } definition.AddField(EFIXField.SecurityType, securityType2); } { double x = inst.PriceTick; int i = 0; for (; x - (int)x != 0; ++i) { x = x * 10; } definition.AddField(EFIXField.PriceDisplay, string.Format("F{0}", i)); } definition.AddField(EFIXField.Symbol, inst.InstrumentID); definition.AddField(EFIXField.SecurityExchange, inst.ExchangeID); definition.AddField(EFIXField.Currency, "CNY");//Currency.CNY definition.AddField(EFIXField.TickSize, inst.PriceTick); definition.AddField(EFIXField.SecurityDesc, inst.InstrumentName); definition.AddField(EFIXField.MaturityDate, DateTime.ParseExact(inst.ExpireDate, "yyyyMMdd", null)); definition.AddField(EFIXField.Factor, (double)inst.VolumeMultiple); //还得补全内容 if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } } }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (this) { if (!this.IsConnected) { this.EmitError(1, 1, "Instrument provider not connected."); return; } string[] markets = marketFilters.Split(','); //是否包含交易市场 if (request.ContainsField(0xcf) && markets.Contains(request.SecurityExchange)) { DZHSymbolReader reader = new DZHSymbolReader(dzhDataPath); string[] securityTypes = securityTypeFilters.Split(','); List <DZHSymbol> symbolList = reader.GetSymbols(request.SecurityExchange); reader.Dispose();//显式释放资源 if (symbolList != null) { List <DZHSymbol> symbols = new List <DZHSymbol>(); foreach (DZHSymbol symbol in symbolList) { if (securityTypes.Contains(symbol.SecurityType.ToString())) { symbols.Add(symbol); } } foreach (DZHSymbol symbol in symbols) { FIXSecurityDefinition definition = new FIXSecurityDefinition(request.SecurityReqID, request.SecurityReqID, 4); definition.SecurityExchange = symbol.Market; definition.SecurityID = symbol.Code; definition.SecurityIDSource = "8";// 8=Exchange Symbol definition.Symbol = symbol.ToString(); switch (symbol.SecurityType) { case DZHSymbol.SecurityTypes.Index: definition.SecurityType = "IDX"; break; case DZHSymbol.SecurityTypes.Stock: definition.SecurityType = "CS"; break; default: definition.SecurityType = symbol.SecurityType.ToString().Substring(0, 3); break; } definition.SecuritySubType = symbol.StockType.ToString(); definition.SecurityDesc = symbol.Name; definition.TotNoRelatedSym = symbols.Count; if (this.SecurityDefinition != null) { this.SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } } } } }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (this) { if (!_bTdConnected) { EmitError(-1, -1, "交易没有连接,无法获取合约列表"); tdlog.Error("交易没有连接,无法获取合约列表"); return; } string symbol = request.ContainsField(EFIXField.Symbol) ? request.Symbol : null; string securityType = request.ContainsField(EFIXField.SecurityType) ? request.SecurityType : null; string securityExchange = request.ContainsField(EFIXField.SecurityExchange) ? request.SecurityExchange : null; #region 过滤 List <CZQThostFtdcInstrumentField> list = new List <CZQThostFtdcInstrumentField>(); foreach (CZQThostFtdcInstrumentField inst in _dictInstruments.Values) { int flag = 0; if (null == symbol) { ++flag; } else if (inst.InstrumentID.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (inst.ExchangeID.ToUpper().StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (securityType == GetSecurityType(inst)) { ++flag; } } if (3 == flag) { list.Add(inst); } } #endregion list.Sort(SortCZQThostFtdcInstrumentField); //如果查出的数据为0,应当想法立即返回 if (0 == list.Count) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = 1//有个除0错误的问题 }; if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } foreach (CZQThostFtdcInstrumentField inst in list) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count }; { string securityType2 = GetSecurityType(inst); definition.AddField(EFIXField.SecurityType, securityType2); } { double x = inst.PriceTick; if (x > 0.0001) { int i = 0; for (; x - (int)x != 0; ++i) { x = x * 10; } definition.AddField(EFIXField.PriceDisplay, string.Format("F{0}", i)); definition.AddField(EFIXField.TickSize, inst.PriceTick); } } definition.AddField(EFIXField.Symbol, GetYahooSymbol(inst.InstrumentID, inst.ExchangeID)); definition.AddField(EFIXField.SecurityExchange, inst.ExchangeID); definition.AddField(EFIXField.Currency, "CNY");//Currency.CNY definition.AddField(EFIXField.SecurityDesc, inst.InstrumentName); definition.AddField(EFIXField.Factor, (double)inst.VolumeMultiple); //还得补全内容 if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } } }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (this) { string symbol = request.ContainsField(EFIXField.Symbol) ? request.Symbol : null; string securityType = request.ContainsField(EFIXField.SecurityType) ? request.SecurityType : null; string securityExchange = request.ContainsField(EFIXField.SecurityExchange) ? request.SecurityExchange : null; #region 过滤 List <StockInfoEx> list = new List <StockInfoEx>(); foreach (StockInfoEx inst in _dictInstruments.Values) { int flag = 0; if (null == symbol) { ++flag; } else if (inst.stockinfo.szCode.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (inst.market.ToUpper().StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (FIXSecurityType.Future == securityType) { ++flag; } } if (3 == flag) { list.Add(inst); } } #endregion list.Sort(SortStockInfoEx); //如果查出的数据为0,应当想法立即返回 if (0 == list.Count) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = 1//有个除0错误的问题 }; if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } foreach (StockInfoEx inst in list) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count }; definition.AddField(EFIXField.SecurityType, FIXSecurityType.Future); definition.AddField(EFIXField.Symbol, inst.stockinfo.szCode); definition.AddField(EFIXField.SecurityExchange, inst.market); definition.AddField(EFIXField.Currency, "CNY");//Currency.CNY definition.AddField(EFIXField.SecurityDesc, inst.stockinfo.szName); //还得补全内容 if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } } }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (this) { if (!_bTdConnected) { EmitError(-1, -1, "交易没有连接,无法获取合约列表"); tdlog.Error("交易没有连接,无法获取合约列表"); return; } string symbol = request.ContainsField(EFIXField.Symbol) ? request.Symbol : null; string securityType = request.ContainsField(EFIXField.SecurityType) ? request.SecurityType : null; string securityExchange = request.ContainsField(EFIXField.SecurityExchange) ? request.SecurityExchange : null; #region 过滤 List<DFITCExchangeInstrumentRtnField> list = new List<DFITCExchangeInstrumentRtnField>(); foreach (DFITCExchangeInstrumentRtnField inst in _dictInstruments.Values) { int flag = 0; if (null == symbol) { ++flag; } else if (inst.InstrumentID.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (inst.ExchangeID.ToUpper().StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (FIXSecurityType.Future == securityType) { if (DFITCInstrumentTypeType.COMM_TYPE == inst.instrumentType) { ++flag; } } //else if (FIXSecurityType.MultiLegInstrument == securityType)//理解上是否有问题 //{ // if (TThostFtdcProductClassType.Combination == inst.ProductClass) // { // ++flag; // } //} else if (FIXSecurityType.FutureOption == securityType) { if (DFITCInstrumentTypeType.OPT_TYPE == inst.instrumentType) { ++flag; } } } if (3 == flag) { list.Add(inst); } } #endregion #region 过滤1 List<DFITCAbiInstrumentRtnField> list1 = new List<DFITCAbiInstrumentRtnField>(); foreach (DFITCAbiInstrumentRtnField inst in _dictAbiInstruments.Values) { int flag = 0; if (null == symbol) { ++flag; } else if (inst.InstrumentID.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (inst.ExchangeID.ToUpper().StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (FIXSecurityType.MultiLegInstrument == securityType) { ++flag; } } if (3 == flag) { list1.Add(inst); } } #endregion list.Sort(SortDFITCExchangeInstrumentRtnField); list1.Sort(SortDFITCAbiInstrumentRtnField); //如果查出的数据为0,应当想法立即返回 if (0 == list.Count&&0==list1.Count) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = 1//有个除0错误的问题 }; if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } #region 期货 期权 foreach (DFITCExchangeInstrumentRtnField inst in list) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count + list1.Count, }; { string securityType2; switch (inst.instrumentType) { case DFITCInstrumentTypeType.COMM_TYPE: securityType2 = FIXSecurityType.Future; break; case DFITCInstrumentTypeType.OPT_TYPE: securityType2 = FIXSecurityType.FutureOption; var match = Regex.Match(inst.InstrumentID, @"(\d+)(-?)([CP])(-?)(\d+)"); if (match.Success) { definition.AddField(EFIXField.PutOrCall, match.Groups[3].Value == "C" ? FIXPutOrCall.Call : FIXPutOrCall.Put); definition.AddField(EFIXField.StrikePrice, double.Parse(match.Groups[5].Value)); } break; default: securityType2 = FIXSecurityType.NoSecurityType; break; } definition.AddField(EFIXField.SecurityType, securityType2); } { double x = inst.minPriceFluctuation; int i = 0; for (; x - (int)x != 0; ++i) { x = x * 10; } definition.AddField(EFIXField.PriceDisplay, string.Format("F{0}", i)); } definition.AddField(EFIXField.Symbol, inst.InstrumentID); definition.AddField(EFIXField.SecurityExchange, inst.ExchangeID); definition.AddField(EFIXField.Currency, "CNY");//Currency.CNY definition.AddField(EFIXField.TickSize, inst.minPriceFluctuation); definition.AddField(EFIXField.SecurityDesc, inst.VarietyName); definition.AddField(EFIXField.Factor, inst.contractMultiplier); try { definition.AddField(EFIXField.MaturityDate, DateTime.ParseExact(inst.instrumentMaturity, "yyyy.MM.dd", CultureInfo.InvariantCulture)); } catch (Exception ex) { tdlog.Warn("合约:{0},字段内容:{1},{2}", inst.InstrumentID, inst.instrumentMaturity, ex.Message); } //还得补全内容 if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } #endregion #region 组合 foreach (DFITCAbiInstrumentRtnField inst in list1) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count + list1.Count, }; string securityType2 = FIXSecurityType.MultiLegInstrument; definition.AddField(EFIXField.SecurityType, securityType2); definition.AddField(EFIXField.Symbol, inst.InstrumentID);// definition.AddField(EFIXField.SecurityExchange, inst.ExchangeID); definition.AddField(EFIXField.Currency, "CNY");//Currency.CNY definition.AddField(EFIXField.SecurityDesc, inst.instrumentName); if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } #endregion } }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (this) { if (!_bTdConnected) { EmitError(-1, -1, "交易没有连接,无法获取合约列表"); tdlog.Error("交易没有连接,无法获取合约列表"); return; } string symbol = request.ContainsField(EFIXField.Symbol) ? request.Symbol : null; string securityType = request.ContainsField(EFIXField.SecurityType) ? request.SecurityType : null; string securityExchange = request.ContainsField(EFIXField.SecurityExchange) ? request.SecurityExchange : null; #region 过滤 List<CThostFtdcInstrumentField> list = new List<CThostFtdcInstrumentField>(); foreach (CThostFtdcInstrumentField inst in _dictInstruments.Values) { int flag = 0; if (null == symbol) { ++flag; } else if (inst.InstrumentID.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (inst.ExchangeID.ToUpper().StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (FIXSecurityType.Future == securityType) { if (TThostFtdcProductClassType.Futures == inst.ProductClass) { ++flag; } } else if (FIXSecurityType.MultiLegInstrument == securityType)//理解上是否有问题 { if (TThostFtdcProductClassType.Combination == inst.ProductClass) { ++flag; } } else if (FIXSecurityType.Option == securityType) { if (TThostFtdcProductClassType.Options == inst.ProductClass) { ++flag; } } } if (3==flag) { list.Add(inst); } } #endregion list.Sort(SortCThostFtdcInstrumentField); //如果查出的数据为0,应当想法立即返回 if (0==list.Count) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = 1//有个除0错误的问题 }; if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } foreach (CThostFtdcInstrumentField inst in list) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count }; { string securityType2; switch (inst.ProductClass) { case TThostFtdcProductClassType.Futures: securityType2 = FIXSecurityType.Future; break; case TThostFtdcProductClassType.Combination: securityType2 = FIXSecurityType.MultiLegInstrument;//此处是否理解上有不同 break; case TThostFtdcProductClassType.Options: securityType2 = FIXSecurityType.Option; break; default: securityType2 = FIXSecurityType.NoSecurityType; break; } definition.AddField(EFIXField.SecurityType, securityType2); } { double x = inst.PriceTick; int i = 0; for (; x - (int)x != 0; ++i) { x = x * 10; } definition.AddField(EFIXField.PriceDisplay, string.Format("F{0}",i)); } definition.AddField(EFIXField.Symbol, inst.InstrumentID); definition.AddField(EFIXField.SecurityExchange, inst.ExchangeID); definition.AddField(EFIXField.Currency, "CNY");//Currency.CNY definition.AddField(EFIXField.TickSize, inst.PriceTick); definition.AddField(EFIXField.SecurityDesc, inst.InstrumentName); definition.AddField(EFIXField.Factor, (double)inst.VolumeMultiple); if(inst.ProductClass == TThostFtdcProductClassType.Futures||inst.ProductClass == TThostFtdcProductClassType.Options) { try { definition.AddField(EFIXField.MaturityDate, DateTime.ParseExact(inst.ExpireDate, "yyyyMMdd", CultureInfo.InvariantCulture)); } catch (Exception ex) { tdlog.Warn("合约:{0},字段内容:{1},{2}", inst.InstrumentID, inst.ExpireDate, ex.Message); } } //还得补全内容 if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } } }
private string DsUMrBufkW([In] FIXSecurityDefinition obj0) { if ((int)this.ElZM5QiWFt.Id == 10) { string str = obj0.Symbol; if (obj0.SecurityType == RNaihRhYEl0wUmAftnB.aYu7exFQKN(33032) || obj0.SecurityType == RNaihRhYEl0wUmAftnB.aYu7exFQKN(33042) || obj0.SecurityType == RNaihRhYEl0wUmAftnB.aYu7exFQKN(33052)) { if (obj0.ContainsField(200)) { string s = obj0.MaturityMonthYear.Substring(4, 2); DateTime dateTime = new DateTime(int.Parse(obj0.MaturityMonthYear.Substring(0, 4), (IFormatProvider)CultureInfo.InvariantCulture), int.Parse(s, (IFormatProvider)CultureInfo.InvariantCulture), 1); str = str + RNaihRhYEl0wUmAftnB.aYu7exFQKN(33064) + dateTime.ToString(RNaihRhYEl0wUmAftnB.aYu7exFQKN(33070), (IFormatProvider)CultureInfo.InvariantCulture); } if (obj0.SecurityType == RNaihRhYEl0wUmAftnB.aYu7exFQKN(33084)) { if (obj0.ContainsField(202)) { str = str + (object)RNaihRhYEl0wUmAftnB.aYu7exFQKN(33094) + (string)(object)obj0.StrikePrice; } if (obj0.ContainsField(201)) { str = obj0.PutOrCall != 0 ? str + RNaihRhYEl0wUmAftnB.aYu7exFQKN(33108) : str + RNaihRhYEl0wUmAftnB.aYu7exFQKN(33100); } } } return(str); } else { if ((int)this.ElZM5QiWFt.Id != 22) { return(obj0.Symbol); } string str = obj0.Symbol; if (obj0.SecurityType == RNaihRhYEl0wUmAftnB.aYu7exFQKN(33116) || obj0.SecurityType == RNaihRhYEl0wUmAftnB.aYu7exFQKN(33126)) { if (obj0.ContainsField(541)) { str = str + RNaihRhYEl0wUmAftnB.aYu7exFQKN(33136) + obj0.MaturityDate.ToString(RNaihRhYEl0wUmAftnB.aYu7exFQKN(33142), (IFormatProvider)CultureInfo.InvariantCulture); } if (obj0.SecurityType == RNaihRhYEl0wUmAftnB.aYu7exFQKN(33156)) { if (obj0.ContainsField(202)) { str = str + (object)RNaihRhYEl0wUmAftnB.aYu7exFQKN(33166) + (string)(object)obj0.StrikePrice; } if (obj0.ContainsField(201)) { switch (obj0.PutOrCall) { case 0: str = str + RNaihRhYEl0wUmAftnB.aYu7exFQKN(33172); break; case 1: str = str + RNaihRhYEl0wUmAftnB.aYu7exFQKN(33180); break; } } } } return(str); } }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (_dictDepthMarketData) { string symbol = request.ContainsField(EFIXField.Symbol) ? request.Symbol : null; string securityType = request.ContainsField(EFIXField.SecurityType) ? request.SecurityType : null; string securityExchange = request.ContainsField(EFIXField.SecurityExchange) ? request.SecurityExchange : null; #region 过滤 List <StructRcvReportEx> list = new List <StructRcvReportEx>(); foreach (StructRcvReport inst in _dictDepthMarketData.Values) { StructRcvReportEx ex = new StructRcvReportEx(inst); int flag = 0; if (null == symbol) { ++flag; } else if (ex.newSymbol.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (ex.yahooExchange.StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (securityType == ex.securityType) { ++flag; } } if (3 == flag) { list.Add(ex); } } #endregion list.Sort(SortCThostFtdcInstrumentField); //如果查出的数据为0,应当想法立即返回 if (0 == list.Count) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = 1//有个除0错误的问题 }; if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } foreach (StructRcvReportEx inst in list) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count }; { definition.AddField(EFIXField.SecurityType, inst.securityType); } { //double x = inst.PriceTick; //if (x > 0.0001) //{ // int i = 0; // for (; x - (int)x != 0; ++i) // { // x = x * 10; // } // definition.AddField(EFIXField.PriceDisplay, string.Format("F{0}", i)); // definition.AddField(EFIXField.TickSize, inst.PriceTick); //} } definition.AddField(EFIXField.Symbol, GetYahooSymbol(inst.newSymbol, inst.yahooExchange)); definition.AddField(EFIXField.SecurityExchange, inst.yahooExchange); definition.AddField(EFIXField.Currency, "CNY");//Currency.CNY definition.AddField(EFIXField.SecurityDesc, inst.RcvReport.StockName); FIXSecurityAltIDGroup group = new FIXSecurityAltIDGroup(); group.SecurityAltID = inst.RcvReport.StockCode; group.SecurityAltExchange = inst.RcvReport.MarketType; group.SecurityAltIDSource = this.Name; definition.AddGroup(group); //还得补全内容 if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } } }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (this) { if (!_bTdConnected) { this.EmitError(-1,-1,"交易没有连接,无法获取合约列表"); return; } string symbol = request.ContainsField(EFIXField.Symbol) ? request.Symbol : null; string securityType = request.ContainsField(EFIXField.SecurityType) ? request.SecurityType : null; string securityExchange = request.ContainsField(EFIXField.SecurityExchange) ? request.SecurityExchange : null; #region 过滤 List<CZQThostFtdcInstrumentField> list = new List<CZQThostFtdcInstrumentField>(); foreach (CZQThostFtdcInstrumentField inst in _dictInstruments.Values) { int flag = 0; if (null == symbol) { ++flag; } else if (inst.InstrumentID.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (inst.ExchangeID.ToUpper().StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (FIXSecurityType.Future == securityType) { if (TZQThostFtdcProductClassType.Futures == inst.ProductClass || TZQThostFtdcProductClassType.EFP == inst.ProductClass) { ++flag; } } else if (FIXSecurityType.MultiLegInstrument == securityType)//理解上是否有问题 { if (TZQThostFtdcProductClassType.Combination == inst.ProductClass) { ++flag; } } else if (FIXSecurityType.Option == securityType) { if (TZQThostFtdcProductClassType.Options == inst.ProductClass) { ++flag; } } else if (FIXSecurityType.CommonStock == securityType) { if (TZQThostFtdcProductClassType.StockA == inst.ProductClass || TZQThostFtdcProductClassType.StockB == inst.ProductClass) { ++flag; } } else if (FIXSecurityType.ExchangeTradedFund == securityType) { if (TZQThostFtdcProductClassType.ETF == inst.ProductClass || TZQThostFtdcProductClassType.ETFPurRed == inst.ProductClass) { ++flag; } } } if (3==flag) { list.Add(inst); } } #endregion list.Sort(SortCZQThostFtdcInstrumentField); //如果查出的数据为0,应当想法立即返回 if (0==list.Count) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = 1//有个除0错误的问题 }; if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } foreach (CZQThostFtdcInstrumentField inst in list) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count }; { string securityType2; switch (inst.ProductClass) { case TZQThostFtdcProductClassType.Futures: securityType2 = FIXSecurityType.Future; break; case TZQThostFtdcProductClassType.Combination: securityType2 = FIXSecurityType.MultiLegInstrument;//此处是否理解上有不同 break; case TZQThostFtdcProductClassType.Options: securityType2 = FIXSecurityType.Option; break; case TZQThostFtdcProductClassType.StockA: case TZQThostFtdcProductClassType.StockB: securityType2 = GetSecurityTypeFromProductID(inst.ProductID); break; case TZQThostFtdcProductClassType.ETF: case TZQThostFtdcProductClassType.ETFPurRed: securityType2 = FIXSecurityType.ExchangeTradedFund; break; default: securityType2 = FIXSecurityType.NoSecurityType; break; } definition.AddField(EFIXField.SecurityType, securityType2); } { double x = inst.PriceTick; if (x>0.0001) { int i = 0; for (; x - (int)x != 0; ++i) { x = x * 10; } definition.AddField(EFIXField.PriceDisplay, string.Format("F{0}", i)); definition.AddField(EFIXField.TickSize, inst.PriceTick); } } definition.AddField(EFIXField.Symbol, inst.InstrumentID); definition.AddField(EFIXField.SecurityExchange, inst.ExchangeID); definition.AddField(EFIXField.Currency, "CNY");//Currency.CNY definition.AddField(EFIXField.SecurityDesc, inst.InstrumentName); definition.AddField(EFIXField.Factor, (double)inst.VolumeMultiple); //try //{ // definition.AddField(EFIXField.MaturityDate, DateTime.ParseExact(inst.ExpireDate, "yyyyMMdd", null)); //} //catch (System.Exception ex) //{ //} //还得补全内容 if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } } }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (this) { if (!_bTdConnected) { EmitError(-1, -1, "交易没有连接,无法获取合约列表"); tdlog.Error("交易没有连接,无法获取合约列表"); return; } string symbol = request.ContainsField(EFIXField.Symbol) ? request.Symbol : null; string securityType = request.ContainsField(EFIXField.SecurityType) ? request.SecurityType : null; string securityExchange = request.ContainsField(EFIXField.SecurityExchange) ? request.SecurityExchange : null; #region 过滤 List<CZQThostFtdcInstrumentField> list = new List<CZQThostFtdcInstrumentField>(); foreach (CZQThostFtdcInstrumentField inst in _dictInstruments.Values) { int flag = 0; if (null == symbol) { ++flag; } else if (inst.InstrumentID.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (inst.ExchangeID.ToUpper().StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (securityType == GetSecurityType(inst)) { ++flag; } } if (3==flag) { list.Add(inst); } } #endregion list.Sort(SortCZQThostFtdcInstrumentField); //如果查出的数据为0,应当想法立即返回 if (0==list.Count) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = 1//有个除0错误的问题 }; if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } foreach (CZQThostFtdcInstrumentField inst in list) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count }; { string securityType2 = GetSecurityType(inst); definition.AddField(EFIXField.SecurityType, securityType2); } { double x = inst.PriceTick; if (x>0.0001) { int i = 0; for (; x - (int)x != 0; ++i) { x = x * 10; } definition.AddField(EFIXField.PriceDisplay, string.Format("F{0}", i)); definition.AddField(EFIXField.TickSize, inst.PriceTick); } } definition.AddField(EFIXField.Symbol, GetYahooSymbol(inst.InstrumentID, inst.ExchangeID)); definition.AddField(EFIXField.SecurityExchange, inst.ExchangeID); definition.AddField(EFIXField.Currency, "CNY");//Currency.CNY definition.AddField(EFIXField.SecurityDesc, inst.InstrumentName); definition.AddField(EFIXField.Factor, (double)inst.VolumeMultiple); //还得补全内容 if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } } }
public void SendSecurityDefinitionRequest(FIXSecurityDefinitionRequest request) { lock (this) { if (!_bTdConnected) { EmitError(-1, -1, "交易没有连接,无法获取合约列表"); tdlog.Error("交易没有连接,无法获取合约列表"); return; } string symbol = request.ContainsField(EFIXField.Symbol) ? request.Symbol : null; string securityType = request.ContainsField(EFIXField.SecurityType) ? request.SecurityType : null; string securityExchange = request.ContainsField(EFIXField.SecurityExchange) ? request.SecurityExchange : null; #region 过滤 List<CThostFtdcInstrumentField> list = new List<CThostFtdcInstrumentField>(); foreach (CThostFtdcInstrumentField inst in _dictInstruments.Values) { int flag = 0; if (null == symbol) { ++flag; } else if (inst.InstrumentID.ToUpper().StartsWith(symbol.ToUpper())) { ++flag; } if (null == securityExchange) { ++flag; } else if (inst.ExchangeID.ToUpper().StartsWith(securityExchange.ToUpper())) { ++flag; } if (null == securityType) { ++flag; } else { if (securityType == GetSecurityType(inst)) { ++flag; } } if (3==flag) { list.Add(inst); } } #endregion list.Sort(SortCThostFtdcInstrumentField); //如果查出的数据为0,应当想法立即返回 if (0==list.Count) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = 1//有个除0错误的问题 }; if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } foreach (CThostFtdcInstrumentField inst in list) { FIXSecurityDefinition definition = new FIXSecurityDefinition { SecurityReqID = request.SecurityReqID, //SecurityResponseID = request.SecurityReqID, SecurityResponseType = request.SecurityRequestType, TotNoRelatedSym = list.Count }; { string securityType2 = GetSecurityType(inst); definition.AddField(EFIXField.SecurityType, securityType2); } { double x = inst.PriceTick; if (x > 0.00001) { int i = 0; for (; x - (int)x != 0; ++i) { x = x * 10; } definition.AddField(EFIXField.PriceDisplay, string.Format("F{0}", i)); definition.AddField(EFIXField.TickSize, inst.PriceTick); } } #if CTP definition.AddField(EFIXField.Symbol, inst.InstrumentID); #elif CTPZQ definition.AddField(EFIXField.Symbol, GetYahooSymbol(inst.InstrumentID, inst.ExchangeID)); #endif definition.AddField(EFIXField.SecurityExchange, inst.ExchangeID); definition.AddField(EFIXField.Currency, "CNY");//Currency.CNY definition.AddField(EFIXField.SecurityDesc, inst.InstrumentName); definition.AddField(EFIXField.Factor, (double)inst.VolumeMultiple); if(inst.ProductClass == TThostFtdcProductClassType.Futures||inst.ProductClass == TThostFtdcProductClassType.Options) { try { definition.AddField(EFIXField.MaturityDate, DateTime.ParseExact(inst.ExpireDate, "yyyyMMdd", CultureInfo.InvariantCulture)); } catch (Exception ex) { tdlog.Warn("合约:{0},字段内容:{1},{2}", inst.InstrumentID, inst.ExpireDate, ex.Message); } //if (inst.ProductClass == TThostFtdcProductClassType.Options) //{ // // 支持中金所,大商所,郑商所 // var match = Regex.Match(inst.InstrumentID, @"(\d+)(-?)([CP])(-?)(\d+)"); // if (match.Success) // { // definition.AddField(EFIXField.PutOrCall, match.Groups[3].Value == "C" ? FIXPutOrCall.Call : FIXPutOrCall.Put); // definition.AddField(EFIXField.StrikePrice, double.Parse(match.Groups[5].Value)); // } //} } // 中金所仿真平台下,居然全设的是股票 var match = Regex.Match(inst.InstrumentID, @"(\d+)(-?)([CP])(-?)(\d+)"); if (match.Success) { definition.AddField(EFIXField.PutOrCall, match.Groups[3].Value == "C" ? FIXPutOrCall.Call : FIXPutOrCall.Put); definition.AddField(EFIXField.StrikePrice, double.Parse(match.Groups[5].Value)); } FIXSecurityAltIDGroup group = new FIXSecurityAltIDGroup(); group.SecurityAltID = inst.InstrumentID; group.SecurityAltExchange = inst.ExchangeID; group.SecurityAltIDSource = this.Name; definition.AddGroup(group); //还得补全内容 if (SecurityDefinition != null) { SecurityDefinition(this, new SecurityDefinitionEventArgs(definition)); } } } }