/// <summary> /// create message for new order /// создать сообщение для нового ордера /// </summary> public string NewOrderSingleMsg(string clOrdId, string securityId, string side, string orderQty, string ordType, string price) { var newMessage = new FixMessage(++_msgSeqNum, "D", true, _settings); var newOrder = new List <Field> { new Field((int)Tags.ClOrdID, clOrdId), new Field((int)Tags.SecurityID, securityId), new Field((int)Tags.SecurityIDSource, "8"), new Field((int)Tags.Side, side), new Field((int)Tags.ExecInst, "H"), new Field((int)Tags.TransactTime, DateTime.UtcNow.ToString("yyyyMMdd-HH:mm:ss")), new Field((int)Tags.OrderQty, orderQty), new Field((int)Tags.OrdType, ordType) }; if (ordType == "2")// if limit order / если лимитный { newOrder.Add(new Field((int)Tags.Price, price)); newOrder.Add(new Field((int)Tags.TimeInForce, "1")); } newMessage.AddBody(newOrder); var res = newMessage.ToString(); return(res); }
/// <summary> /// The OnSessionTxAppMessage callback is invoked by a session /// when it is ready to dispatch an application message to the /// peer session it's interacting with. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing the /// callback to the handler. /// </param> /// <param name="msg"> /// The application message that the session wants to have sent /// to its corresponding peer session. /// </param> public void OnSessionTxAppMessage(IVfxFixSession session, FixMessage msg) { // REC: Forward the app message to the application: _fixApplication.OnSessionTxAppMessage(_appSession, msg); // REC: Send the app message to the peer system: _ipcEndpoint.Send(null, new VfxMsgBlock(msg.ToString())); }
/// <summary> /// message for exit /// сообщение для выхода /// </summary> /// <param name="isTrading">true - if the exit from the trading session, false for market data / true - если выход из торговой сессии, false для market data</param> /// <returns>message in fix format / сообщение в формате fix</returns> public string LogOutMsg(bool isTrading) { var newMessage = new FixMessage(++_msgSeqNum, "5", isTrading, _settings); var res = newMessage.ToString(); return(res); }
public void ToString() { var sessionId = new SessionIdentity("FIX.4.2", "EXECUTOR", "CLIENT1"); var target = new FixMessage(sessionId, 'A'); target.Header.Add(34, "1"); target.Header.Add(52, "20200925-11:05:13.797"); target.Add(98, "0"); target.Add(108, "30"); var str = target.ToString(); Assert.AreEqual("8=FIX.4.2\u00019=70\u000135=A\u000149=EXECUTOR\u000156=CLIENT1\u000134=1\u000152=20200925-11:05:13.797\u000198=0\u0001108=30\u000110=096\u0001", str); }
/// <summary> /// create message for test request /// создать сообщение для тестового запроса /// </summary> /// <param name="reqId"></param> /// <param name="isTrading"></param> /// <returns></returns> public string TestRequestMsg(string reqId, bool isTrading) { var newMessage = new FixMessage(++_msgSeqNum, "1", isTrading, _settings); var logOnFields = new List <Field> { new Field((int)Tags.TestReqID, reqId) }; newMessage.AddBody(logOnFields); var res = newMessage.ToString(); return(res); }
/// <summary> /// The OnSessionTxAppMessage callback is invoked by a session /// when it is ready to dispatch an application message to the /// peer session it's interacting with. /// </summary> /// <param name="session"> /// The IVfxFixSession implementation that is issuing the /// callback to the handler. /// </param> /// <param name="msg"> /// The application message that the session wants to have sent /// to its corresponding peer session. /// </param> public void OnSessionTxAppMessage(IVfxFixSession session, FixMessage msg) { if (_mapAppSessions.ContainsKey(session.InstanceId)) { IVfxFixAppSession appSession = _mapAppSessions[session.InstanceId]; _application.OnSessionTxAppMessage(appSession, msg); // REC: Locate the IPC session identifier of the IPC session // that is associated with the service that is generating the // event and use that to send the message to the peer: if (_mapFixToIpc.ContainsKey(session.InstanceId)) { string ipcIdentifier = _mapFixToIpc[session.InstanceId]; _endpoint.Send(ipcIdentifier, new VfxMsgBlock(msg.ToString())); } } }
/// <summary> /// create a message for request status /// создать сообщение для запроса статуса ордера /// </summary> /// <param name="clOrdId">order number specified by the user when creating/номер ордера заданный пользователем при создании</param> /// <param name="side">order side/направление ордера</param> /// <param name="securityId">instrument id/id инструмента</param> public string OrderStatusRequestMsg(string clOrdId, string securityId, string side) { var newMessage = new FixMessage(++_msgSeqNum, "H", true, _settings); var newOrder = new List <Field> { new Field((int)Tags.ClOrdID, clOrdId), new Field((int)Tags.SecurityID, securityId), new Field((int)Tags.SecurityIDSource, "8"), new Field((int)Tags.Side, side) }; newMessage.AddBody(newOrder); var res = newMessage.ToString(); return(res); }
/// <summary> /// create message for cancelling order /// создать сообщение для отмены ордера /// </summary> public string OrderCancelRequestMsg(string origClOrdId, string clOrdId, string securityId) { var newMessage = new FixMessage(++_msgSeqNum, "F", true, _settings); var newOrder = new List <Field> { new Field((int)Tags.OrigClOrdID, clOrdId), new Field((int)Tags.ClOrdID, origClOrdId), new Field((int)Tags.SecurityID, securityId), new Field((int)Tags.SecurityIDSource, "8"), new Field((int)Tags.TransactTime, DateTime.UtcNow.ToString("yyyyMMdd-HH:mm:ss")) }; newMessage.AddBody(newOrder); var res = newMessage.ToString(); return(res); }
/// <summary> /// message for entering /// сообщение для входа /// </summary> /// <param name="isTrading">true - if the entrance to the trading session, false for market data / true - если вход в торговую сессию, false для market data</param> /// <param name="heartbeatInterval"></param> /// <returns>сообщение в формате fix</returns> public string LogOnMsg(bool isTrading, int heartbeatInterval) { var newMessage = new FixMessage(++_msgSeqNum, "A", isTrading, _settings); var logOnFields = new List <Field> { new Field((int)Tags.EncryptMethod, "0"), new Field((int)Tags.HeartBtInt, heartbeatInterval.ToString()), new Field((int)Tags.ResetSeqNumFlag, "Y"), new Field((int)Tags.Username, _settings.Username), new Field((int)Tags.Password, _settings.Password) }; newMessage.AddBody(logOnFields); var res = newMessage.ToString(); return(res); }
public string TradeCaptureReportRequestMsg(string tradeRequestId, string tradeRequestType, string subscriptionRequestType, DateTime starTime, DateTime endTime) { var newMessage = new FixMessage(++_msgSeqNum, "AD", true, _settings); var newOrder = new List <Field> { new Field((int)Tags.TradeRequestID, tradeRequestId), new Field((int)Tags.TradeRequestType, tradeRequestType), new Field((int)Tags.SubscriptionRequestType, subscriptionRequestType), new Field((int)Tags.NoDates, "2"), new Field((int)Tags.TransactTime, starTime.ToString("yyyyMMdd-HH:mm:ss")), new Field((int)Tags.TransactTime, endTime.ToString("yyyyMMdd-HH:mm:ss")) }; newMessage.AddBody(newOrder); var res = newMessage.ToString(); return(res); }
public void OnMessage(FixMessage msg) { Console.WriteLine(">" + msg.ToString()); var msgType = msg.Header[Tags.MsgType] as FixField <char>; switch (msgType.Value) { case 'D': var accept = new FixMessage(_session.RevertID, '8'); accept.Header.Add(52, DateTime.UtcNow.ToString(FixSettings.DateTimeFormat)); accept.Add(6, 0); accept.Add(14, 0); accept.Add(17, _execId++); accept.Add(37, _orderId++); accept.Add(msg[11]); accept.Add(39, 2); accept.Add(msg[54]); accept.Add(msg[55]); accept.Add(150, 0); accept.Add(151, 0); _session.SendAsync(accept); return; } }
public void OnSessionRxAdmMessage(IVfxFixAppSession session, FixMessage msg) { FixField fixSCID = msg.Header.GetField(49); Console.WriteLine(string.Format("FIX CLIENT: {0} SENT: {1}", fixSCID.Content, msg.ToString())); }
/// <summary> /// heartbeat message /// сообщение пулься /// </summary> public string HeartbeatMsg(bool isTrading) { var newMessage = new FixMessage(++_msgSeqNum, "0", isTrading, _settings); return(newMessage.ToString()); }
public void OnMessage(FixMessage msg) { Console.WriteLine(">" + msg.ToString()); }
public void OnSessionRxAppMessage(IVfxFixAppSession session, FixMessage msg) { FixField fixSCID = msg.Header.GetField(49); Console.WriteLine(string.Format("FIX SERVER: {0} SENT: {1}", fixSCID.Content, msg.ToString())); }