internal SecurityEntry(SecurityDefinition securityDefinition) { IsMDUpdated = false; SecurityID = securityDefinition.getSecurityID().getValue(); Symbol = securityDefinition.getSymbol().getValue(); SecurityExchange = securityDefinition.getSecurityExchange().getValue(); SecurityType = securityDefinition.getSecurityType().getValue(); if (securityDefinition.isSetMaturityMonthYear()) MaturityMonthYear = securityDefinition.getMaturityMonthYear().getValue(); NoRelatedSym noRelatedSym = securityDefinition.getNoRelatedSym(); SubContractCount = noRelatedSym.getValue(); subcontracts = new SecurityEntry[SubContractCount]; SecurityDefinition.NoRelatedSym group = new SecurityDefinition.NoRelatedSym(); for (uint i = 0; i < SubContractCount; i++) { securityDefinition.getGroup(i + 1, group); InsertSubContract(i, group); } // whether reverse contract if (HasFutureContract() && SubContractCount == 2) { IsInverted = GetSubContract((uint) GetNearSubContractIndex()).Side == QuickFix.Side.SELL; } }
public override void onMessage(QuickFix42.SecurityDefinition securityDefinition, SessionID sessionID) { //Console.WriteLine("securityDefinition " + securityDefinition); try { SecurityType securityType = new SecurityType(); securityDefinition.getField(securityType); SecurityID securityID = new SecurityID(); securityDefinition.getField(securityID); //Create the object in the spreadmatrix; if(securityType.getValue() == SecurityType.MULTILEGINSTRUMENT) { string longUnderlyingMaturityMonthYear=null; string shortUnderlyingMaturityMonthYear=null; NoRelatedSym noRelatedSym = securityDefinition.getNoRelatedSym(); uint SubContractCount = (uint)noRelatedSym.getValue(); if (SubContractCount != 2) { //Console.WriteLine("I don't know how to handle an MLEG with " + SubContractCount + " legs."); return; } SecurityDefinition.NoRelatedSym group = new SecurityDefinition.NoRelatedSym(); for (uint i = 0; i < SubContractCount; i++) { securityDefinition.getGroup(i + 1, group); UnderlyingMaturityMonthYear underlyingMaturityMonthYear = new UnderlyingMaturityMonthYear(); group.getField(underlyingMaturityMonthYear); Side side = new Side(); group.getField(side); if (side.getValue() == QuickFix.Side.SELL) { shortUnderlyingMaturityMonthYear = underlyingMaturityMonthYear.getValue(); } else if (side.getValue() == QuickFix.Side.BUY) { longUnderlyingMaturityMonthYear = underlyingMaturityMonthYear.getValue(); } else { Console.WriteLine("Unsupport MLEG side: " + side.getValue()); return; } } spreadMatrix.CreateSpread(securityID.getValue(), longUnderlyingMaturityMonthYear, shortUnderlyingMaturityMonthYear); } else if (securityType.getValue() == SecurityType.FUTURE) { MaturityMonthYear maturityMonthYear = new MaturityMonthYear(); securityDefinition.getField(maturityMonthYear); spreadMatrix.CreateOutright(securityID.ToString(), maturityMonthYear.ToString()); } else { Console.WriteLine("Unsupport security type: " + securityType.getField()); return; } MarketDataRequest(securityDefinition, sessionID); } catch (Exception exception) { Console.WriteLine(exception.Message); } }