/// <summary> /// handle component status events /// </summary> /// <param name="FIXMsg"></param> void UpdateComponentStatus(EASYROUTERCOMCLIENTLib.IFIXMessage FIXMsg) { string sModule = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESComponentModule); int nModule = FIXMsg.get_AsNumber(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESComponentChannel); string sCategory = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESComponentCategory); if (sModule != RouterModule && nModule != RouterChannel) { SecurityExchange exchange = m_InstrumentManager.GetSecurityExchange(sModule); if (exchange != null) { string strExchangeDesc = exchange.ExchangeDesc; if ((sCategory == MESSAGEFIX3Lib.FIXComponentCategoryConstants.esFIXComponentCategoryOrders) || (sCategory == MESSAGEFIX3Lib.FIXComponentCategoryConstants.esFIXComponentCategoryPricesDepth) || (sCategory == MESSAGEFIX3Lib.FIXComponentCategoryConstants.esFIXComponentCategoryPricesBest) || (sCategory == MESSAGEFIX3Lib.FIXComponentCategoryConstants.esFIXComponentCategoryStructure)) { int nTotalActive = FIXMsg.get_AsNumber(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESComponentTotalActive); int nTotalWaiting = FIXMsg.get_AsNumber(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESComponentTotalActive); int nTotalInactive = FIXMsg.get_AsNumber(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESComponentTotalWaiting); int nTotalStale = FIXMsg.get_AsNumber(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESComponentTotalStale); ComponentStatusArgs args = new ComponentStatusArgs(sCategory,sModule,exchange.ExchangeDesc); args.SetStatus(nTotalActive, nTotalWaiting, nTotalInactive); if(RecvExchangeStatusMsgEvent!=null) { RecvExchangeStatusMsgEvent(this, args); } } } } }
/// <summary> /// Recieve account and logon message /// </summary> /// <param name="FIXMsg"></param> void m_Router_RecvGeneralMsg(EASYROUTERCOMCLIENTLib.IFIXMessage FIXMsg) { EASYROUTERCOMCLIENTLib.FIXMsgConstants type = FIXMsg.MsgType; switch (type) { case EASYROUTERCOMCLIENTLib.FIXMsgConstants.esFIXMsgESAccount: System.Diagnostics.Debug.WriteLine(type.ToString()); break; case EASYROUTERCOMCLIENTLib.FIXMsgConstants.esFIXMsgLogon: { Logon logon = new Logon(); if(FIXMsg.HasGroup(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagText)) { string sMessage = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagText); string[] split = sMessage.Split('|'); if (split.Length > 0) logon.Error = split[0]; else logon.Error = "Logon Error Undefined"; logon.ErrorCode = FIXMsg.get_AsNumber(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESLogonFailureCode); logon.LoggedOn = false; } else { System.Diagnostics.Trace.WriteLine(type.ToString()); RequestStructure("0"); logon.LoggedOn = true; LoadSystemSettings(); } logon.ConnectionType = (Logon.ConnectionTypes)FIXMsg.get_AsNumber(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESEasyRouterType); logon.ConnectionDescription = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESEasyRouterDesc); if (RecvGeneralMsgEvent != null) RecvGeneralMsgEvent(this, logon); break; } case EASYROUTERCOMCLIENTLib.FIXMsgConstants.esFIXMsgEHControl: break; case EASYROUTERCOMCLIENTLib.FIXMsgConstants.esFIXMsgESComponentStatus: UpdateComponentStatus(FIXMsg); break; case EASYROUTERCOMCLIENTLib.FIXMsgConstants.esFIXMsgLogout: { Logon logoff = new Logon(); logoff.Error = "Successfully Logged Out"; logoff.LoggedOn = false; logoff.LoggedOff = true; if (RecvGeneralMsgEvent != null) RecvGeneralMsgEvent(this, logoff); break; } default: System.Diagnostics.Debug.WriteLine(type.ToString()); break; } }
/// <summary> /// Parse msg for instrument data /// </summary> /// <param name="FIXMsg"></param> /// <returns></returns> public bool ParseFIX(EASYROUTERCOMCLIENTLib.IFIXMessage FIXMsg) { try { //exchaange string sExchange = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagSecurityExchange); //Esexchange string sESExchange = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESExchange); //type of instrument string sSecurityType = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagSecurityType); //commodity symbol string sSymbol = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagSymbol); //easyscreen TE symbol string sESTickerMnemonic = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESTickerMnemonic); string sESTickerDesc = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESTickerDesc); //exchange code string sTickerSymbol = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESTickerSymbol); int nESOrderType = FIXMsg.get_AsNumber(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESSupportPriceType); int nESTimeType = FIXMsg.get_AsNumber(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESSupportTimeType); bool bESSupportEdit = FIXMsg.get_AsBoolean(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESSupportEdit); int lESPriceFormatCode = FIXMsg.get_AsNumber(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESPriceFormatCode); m_sSymbol = sSymbol; m_sESTickerMnemonic = sESTickerMnemonic; m_sESTickerDesc = sESTickerDesc; m_sESTickerSymbol = sTickerSymbol; m_eOrderType = (OrderType)nESOrderType; m_eTimeType = (TimeInForce)nESTimeType; m_bESSupportEdit = bESSupportEdit; m_lESPriceFormatCode = lESPriceFormatCode; int nOptionType = 0; if(FIXMsg.GetNumber(out nOptionType,EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagPutOrCall)) { //defaults to 1 - call if never here m_nOptionType = nOptionType; } m_sCFICode = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagCFICode); m_sCurrency = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagCurrency); m_dUnitTickValue = FIXMsg.get_AsDouble(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESUnitTickValue); m_dCompositeDelta = FIXMsg.get_AsDouble(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESCompositeDelta); m_dESShortOptAdjust = FIXMsg.get_AsDouble(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESShortOptAdjust); m_nESDecimalPlaces = FIXMsg.get_AsNumber(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESDecimalPlaces); AdditonalUpdates(FIXMsg); } catch(Exception) { return false; } return true; }
/// <summary> /// handle structure update /// </summary> /// <param name="FIXMsg"></param> public void ReceiveStructureUpdate(EASYROUTERCOMCLIENTLib.IFIXMessage FIXMsg) { m_bSubscribedAdditionalInfo = true; int nNumber = FIXMsg.get_AsNumber(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESDecimalPlaces); int nPrefRiskValue = 0; if (FIXMsg.GetNumber(out nPrefRiskValue, EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESPreferredRiskArrayType)) m_nFIXTagESPreferredRiskArrayType = nPrefRiskValue; if(nNumber != 0) m_nESDecimalPlaces = nNumber; double dPriceMovement = 0.0; if (FIXMsg.GetDouble(out dPriceMovement, EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESPriceMovement )) m_nFIXTagESPreferredRiskArrayType = nPrefRiskValue; if (dPriceMovement != 0) m_dPriceMovement = dPriceMovement; string sStrategyCode = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESStrategyCode); if (sStrategyCode != string.Empty) m_sStrategyCode = sStrategyCode; string sSecurityID = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagSecurityID); if (sSecurityID != string.Empty) m_sSecurityID = sSecurityID; string sIDSource = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagIDSource); if (sIDSource != string.Empty) m_sIDSource = sIDSource; string sCombinedCommodityCode = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESCombinedCommodityCode); if (sCombinedCommodityCode != string.Empty) m_sCombinedCommodityCode = sCombinedCommodityCode; string sClearingHouse = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESClearingHouse); if (sClearingHouse != string.Empty) { m_sClearingHouse = sClearingHouse; System.Diagnostics.Debug.WriteLine(this.ESTickerMnemonic + " " + m_sClearingHouse); } int nOptionType = 0; if (FIXMsg.GetNumber(out nOptionType, EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagPutOrCall)) { //defaults to 1 - call if never here m_nOptionType = nOptionType; } //RISK ARRAYS string sRiskArray = string.Empty; int nRiskArrayType = 0; if (FIXMsg.HasGroup(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESNoRiskArrays)) { EASYROUTERCOMCLIENTLib.IFIXGroup defaultGroup = FIXMsg.GetGroupByTag(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESNoRiskArrays, null); if (defaultGroup != null) { int nDefaultCount = defaultGroup.get_NumberOfGroups(null); for (int j = 0; j < nDefaultCount; j++) { EASYROUTERCOMCLIENTLib.IFIXGroup singleDefaultGroup = defaultGroup.GetGroupByIndex(j); int nValue = singleDefaultGroup.get_AsNumber(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESRiskArrayType); if (nValue != nRiskArrayType) { CreateRiskArray(nValue, sRiskArray); nRiskArrayType = nValue; } string sValue = singleDefaultGroup.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESRiskArrayValue); if (sValue != null) { sRiskArray = sRiskArray + sValue + "\\"; } } } } CreateRiskArray(nRiskArrayType, sRiskArray); }
/// <summary> /// Get Process Account Details from FIX message /// </summary> /// <param name="FIXMsg"></param> public void ProcessAccount(EASYROUTERCOMCLIENTLib.IFIXMessage FIXMsg) { //repeats ESNoSecurityExchanges=2 m_nAccountID = FIXMsg.get_AsNumber(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESAccountID); m_sAccountName = FIXMsg.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESAccountName); bool bHasGroup = FIXMsg.HasGroup(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESNoSecurityExchanges); //note pass null EASYROUTERCOMCLIENTLib.IFIXGroup group = FIXMsg.GetGroupByTag(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagESNoSecurityExchanges, null); if (group != null) { int nCount = group.get_NumberOfGroups(null); for(int i = 0; i < nCount; i++) { EASYROUTERCOMCLIENTLib.IFIXGroup singleGroup = group.GetGroupByIndex(i); string sExchange = singleGroup.get_AsString(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagSecurityExchange); AddTicker(sExchange, singleGroup); } } }