/** * Envia a mensagem FIX de SecurityListRequest, solicitando a lista de * todos os instrumentos do sinal de difusão BM&F. * */ private void solicitaListaInstrumentos() { SecurityListRequest mensagemFIX = new SecurityListRequest(); mensagemFIX.setField( new SecurityReqID(sessao.getSenderCompID())); mensagemFIX.setField( new SubscriptionRequestType(SubscriptionRequestType.SNAPSHOT_PLUS_UPDATES)); mensagemFIX.setField( new SecurityListRequestType(SecurityListRequestType.ALL_SECURITIES)); mensagemFIX.getHeader().setField( new SenderCompID(sessao.getSenderCompID())); mensagemFIX.getHeader().setField( new TargetCompID(sessao.getTargetCompID())); try { logger.Info("Requisita lista de todos os instrumentos"); Session.sendToTarget(mensagemFIX, sessao); } catch (SessionNotFound e) { logger.Error("Sessao invalida: " + e.Message); } }
public void onLogon(SessionID sessionID) { if (onSessionLogon != null) { onSessionLogon(sessionID); } if (FixMessage.FixVersion == FixVersion.Fix44 && needUserRequestMessage) { // послать UserRequest var userName = SessionSettingsParser.Instance.GetSessionParam( sessionID.getTargetCompID(), sessionID.getSenderCompID(), "Username", ""); var password = SessionSettingsParser.Instance.GetSessionParam( sessionID.getTargetCompID(), sessionID.getSenderCompID(), "Password", ""); QuickFix44.UserRequest msg; try { msg = new QuickFix44.UserRequest(new UserRequestID("1"), new UserRequestType(1), new Username(userName)); msg.setField(new SendingTime(DateTime.Now.ToUniversalTime(), FixMessageMaker.Instance.ShowMillisecond)); // !! появляется дважды msg.setField(new Password(password)); msg.getHeader().setField(new SenderCompID(sessionID.getSenderCompID())); msg.getHeader().setField(new TargetCompID(sessionID.getTargetCompID())); } catch (Exception ex) { Logger.Error("Ошибка сборки сообщения UserRequest", ex); throw; } SendMessage(msg); } }
public void onLogon(SessionID sessionID) { _senderCompID = sessionID.getSenderCompID(); _targetCompID = sessionID.getTargetCompID(); _FixSessionStatusChangedDelegate(Beltone.Services.Fix.Entities.FixSessionStatus.Connected); SystemLogger.WriteOnConsoleAsync(true, "Logged In: session id " + sessionID.ToString(), ConsoleColor.Green, ConsoleColor.Yellow, false); }
public override void onMessage(QuickFix44.Logon message, SessionID sessionID) { Logger.InfoFormat("Logon command (Sender = {0}, Target = {1}, Encrypt = {2}," + " Password = {3}, Heartbeat int = {4})", sessionID.getSenderCompID(), sessionID.getTargetCompID(), message.getEncryptMethod(), message.getPassword(), message.getHeartBtInt()); }
public override void onMessage(QuickFix44.Logout message, SessionID sessionID) { Logger.InfoFormat("Logout command (Sender = {0}, Target = {1}, Text = {2}," + " Encoded text = {3})", sessionID.getSenderCompID(), sessionID.getTargetCompID(), message.getText(), message.getEncodedText()); }
public void onCreate(SessionID sessionID) { SystemLogger.WriteOnConsoleAsync(true, string.Format("new sessionID: {0} ", sessionID.ToString()), ConsoleColor.Cyan, ConsoleColor.Black, false); lock (_lockObj) { if (!_sessionCode_sessionDetails.ContainsKey(sessionID.ToString())) { if (!_targetCompID_SessionCode.ContainsKey(sessionID.getTargetCompID())) { SystemLogger.WriteOnConsoleAsync(true, string.Format("not added sessionID: {0} because not found in database", sessionID.ToString()), ConsoleColor.White, ConsoleColor.Red, false); return; } _sessionCode_sessionDetails.Add(_targetCompID_SessionCode[sessionID.getTargetCompID()], new SessionInfo() { Session = sessionID, TargetCode = sessionID.getTargetCompID() }); _sessionID_sessionCode.Add(sessionID.ToString(), _targetCompID_SessionCode[sessionID.getTargetCompID()]); //SystemLogger.WriteOnConsoleAsync(true, string.Format("new added sessionID: {0} ", sessionID.ToString()), ConsoleColor.Cyan, ConsoleColor.Black, false); } } }
public void onLogon(SessionID sessionID) { lock (_lockObj) { if (!_targetCompID_SessionCode.ContainsKey(sessionID.getTargetCompID())) { SystemLogger.WriteOnConsoleAsync(true, string.Format("kicked sessionID: {0} because not found in database", sessionID.ToString()), ConsoleColor.White, ConsoleColor.Red, false); Session.lookupSession(sessionID).logout(); return; } //sessionID.getSenderCompID(); //FixSessions.Add(sessionID.ToString(), sessionID); SystemLogger.WriteOnConsoleAsync(true, string.Format("loggedin sessionID: {0} ", sessionID.ToString()), ConsoleColor.DarkMagenta, ConsoleColor.White, false); } // test send //SendFixMessageToAllConnections(new QuickFix44.ExecutionReport(new OrderID("324"),new ExecID("234"), new ExecType(ExecType.FILL), new OrdStatus(OrdStatus.FILLED), new Side(Side.BUY), new LeavesQty(324), new CumQty(123), new AvgPx(12))); }
public void fromApp(Message message, SessionID sessionID) { //SystemLogger.WriteOnConsoleAsync(true, string.Format("fromApp: {0} ", message.ToString()), ConsoleColor.Green, ConsoleColor.Black, false); //SystemLogger.LogEventAsync(string.Format("fromApp: {0} ", message.ToString())); //crack(message, sessionID); // extract clientAllocID // check max char length // prefix clientAllocID with "F" stand for "Fix Connection" // add to current cache // update db // send to MCDR try { lock (_lockObj) { if (message.isSetField(11)) { string target = sessionID.getTargetCompID(); if (!_targetCompID_SessionCode.ContainsKey(target)) { SystemLogger.WriteOnConsoleAsync(true, string.Format("Error recieveing fix msg from Target {0} Not FOund! : ", target), ConsoleColor.White, ConsoleColor.Red, true); return; } string msgKey = message.getField(11); string sessionCode = _targetCompID_SessionCode[target]; string mapKey = string.Format("{0}{1}{2}{3}", _fixPrefix, sessionCode, _msgSplit, msgKey); message.removeField(11); message.setField(11, mapKey); MarketFixClient.SendDirectFix(message); } } } catch (Exception ex) { SystemLogger.WriteOnConsoleAsync(true, "Error recieveing fix msg from Target : " + ex.ToString(), ConsoleColor.Red, ConsoleColor.Black, true); } }
public static Message MakeQuoteRequest(string ticker, SessionID sessionInfo) { var senderId = sessionInfo.getSenderCompID(); if (string.IsNullOrEmpty(senderId)) { Logger.ErrorFormat("MakeMessage: код отправителя для [{0}] не найден", sessionInfo); return(null); } var msg = FixMessage.FixVersion == FixVersion.Fix42 ? (Message) new QuickFix42.MarketDataRequest( new MDReqID(string.Format("{0}-{1:dd-HH-mm}", ticker, DateTime.Now)), new SubscriptionRequestType((char)1), // subscribe new MarketDepth(marketDepth)) : FixMessage.FixVersion == FixVersion.Fix43 ? (Message) new QuickFix43.MarketDataRequest( new MDReqID(string.Format("{0}-{1:dd-HH-mm}", ticker, DateTime.Now)), new SubscriptionRequestType((char)1), // subscribe new MarketDepth(marketDepth)) : new QuickFix44.MarketDataRequest( new MDReqID(string.Format("{0}-{1:dd-HH-mm}", ticker, DateTime.Now)), // 262=EURAUD-02-17-07 new SubscriptionRequestType(SubscriptionRequestType.SNAPSHOT_PLUS_UPDATES), // subscribe new MarketDepth(marketDepth)); msg.setField(new MDUpdateType( quoteSubscriptionIncrementalUpdateType ? MDUpdateType.INCREMENTAL_REFRESH : MDUpdateType.FULL_REFRESH)); if (!AddBidAskQueryClause(msg, ticker)) { return(null); } msg.getHeader().setField(new SenderCompID(senderId)); msg.getHeader().setField(new TargetCompID(sessionInfo.getTargetCompID())); return(msg); }
public void RequestMarketData(SessionID sessionId) { if (string.IsNullOrEmpty(quoteSessionTargetId)) { return; } var sessionTarget = sessionId.getTargetCompID(); if (sessionTarget != quoteSessionTargetId) { Logger.InfoFormat("RequestMarketData skipped (session target is '{0}', target is '{1}')", sessionTarget, quoteSessionTargetId); return; } if (useTickerCsvDictionary) { RequestTickersFromCsvDic(sessionId); } else { RequestTickersFromTextFile(sessionId); } }
public void onCreate(SessionID __p1) { debug("session created" + __p1.getSenderCompID() + " " + __p1.getTargetCompID()); }
public override void onMessage(QuickFix44.ExecutionReport message, SessionID sessionID) { Logger.InfoFormat("Execution report (Sender = {0}, Target = {1})", sessionID.getSenderCompID(), sessionID.getTargetCompID()); }
public void toAdmin(Message message, SessionID sessionID) { if (message is QuickFix44.Logon && needCredsInLogon) { var logonMsg = (QuickFix44.Logon)message; var userName = SessionSettingsParser.Instance.GetSessionParam( sessionID.getTargetCompID(), sessionID.getSenderCompID(), "Username", ""); var password = SessionSettingsParser.Instance.GetSessionParam( sessionID.getTargetCompID(), sessionID.getSenderCompID(), "Password", ""); logonMsg.setField(new Password(password)); logonMsg.setField(new Username(userName)); } var subId = SessionSettingsParser.Instance.GetSessionParam( sessionID.getTargetCompID(), sessionID.getSenderCompID(), "SessionQualifier", "FX"); var targetSubID = SessionSettingsParser.Instance.GetSessionParam( sessionID.getTargetCompID(), sessionID.getSenderCompID(), "TargetSubID", ""); try { if (!string.IsNullOrEmpty(subId) && message is QuickFix43.Logon && needSenderSubId) { message.getHeader().setField(new SenderSubID(subId)); } message.getHeader().setField(new SendingTime(DateTime.Now.ToUniversalTime(), FixMessageMaker.Instance.ShowMillisecond)); if (!string.IsNullOrEmpty(targetSubID) && needTargetSubId) { message.getHeader().setField(new TargetSubID(targetSubID)); } } catch (Exception ex) { Logger.ErrorFormat("Ошибка установки данных заголовка админ. сообщения, сессия {0}", sessionID); Logger.Error("Исключение", ex); return; } #region Fix43 if (message is QuickFix43.Logon) { try { var logon = (QuickFix43.Logon)message; logon.setField(new ResetSeqNumFlag(true)); var userName = SessionSettingsParser.Instance.GetSessionParam( sessionID.getTargetCompID(), sessionID.getSenderCompID(), "Username", ""); var password = SessionSettingsParser.Instance.GetSessionParam( sessionID.getTargetCompID(), sessionID.getSenderCompID(), "Password", ""); if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password)) { Logger.ErrorFormat("Не найдены настройки сессии {0}", sessionID); } else { logon.set(new Username(userName)); logon.set(new Password(password)); } } catch (Exception ex) { Logger.ErrorFormat("Ошибка установки параметров авторизации, сессия {0}", sessionID); Logger.Error("Исключение", ex); } } #endregion #region Fix44 if (message is QuickFix44.Logon) {// ничего не делаю - пароль и логин указываются отдельно в последующем UserRequest (BE) } #endregion if (!ShouldFilterMessage(message)) { Logger.Info(string.Format("toAdmin({0}, {1})", message, sessionID)); } }
public void onLogout(SessionID sessionId) { #region Documentation // notifies you when an FIX session is no longer online. This could happen during a normal logout exchange or // because of a forced termination or a loss of network connection. #endregion _bLoggedOn = false; string msg = string.Format("OnLogout: Session({0} <-> {1})", sessionId.getSenderCompID(), sessionId.getTargetCompID()); GatLogger.Instance.AddMessage(msg, LogMode.LogAndScreen); }
public void onLogon(SessionID sessionId) { #region Documentation // notifies you when a valid logon has been established with a counter party. This is called when a connection // has been established and the FIX logon process has completed with both parties exchanging valid logon // messages. #endregion _bLoggedOn = true; string msg = string.Format("OnLogon: Session({0} <-> {1})", sessionId.getSenderCompID(), sessionId.getTargetCompID()); GatLogger.Instance.AddMessage(msg, LogMode.LogAndScreen); }
// APPLICATION INTERFACE FUNCTIONS #region APPLICATION INTERFACE FUNCTIONS public void onCreate(SessionID sessionId) { #region Documentation // gets called when quickfix creates a new session. A session comes into and remains in existence for the life // of the application. Sessions exist whether or not a counter party is connected to it. As soon as a session // is created, you can begin sending messages to it. If no one is logged on, the messages will be sent at the // time a connection is established with the counterparty. #endregion _bCreated = true; string msg = string.Format("OnCreate: Session({0} <-> {1})", sessionId.getSenderCompID(), sessionId.getTargetCompID()); GatLogger.Instance.AddMessage(msg, LogMode.LogAndScreen); }