Exemple #1
0
 protected void InstantiateTestingModules()
 {
     foreach (Module testingModule in Configuration.TestingModules)
     {
         try
         {
             DoLog(string.Format("Initializing Testing Module {0}", testingModule.Name), Constants.MessageType.Information);
             if (!string.IsNullOrEmpty(testingModule.Assembly))
             {
                 var moduleType = Type.GetType(testingModule.Assembly);
                 if (moduleType != null)
                 {
                     ICommunicationModule module = (ICommunicationModule)Activator.CreateInstance(moduleType);
                     module.Initialize(ProcessMessage, DoLog, testingModule.Config);
                     if (!TestingModules.ContainsKey(testingModule.Name))
                     {
                         TestingModules.Add(testingModule.Name, module);
                     }
                 }
                 else
                 {
                     throw new Exception("assembly not found: " + testingModule.Assembly);
                 }
             }
             else
             {
                 DoLog(string.Format("Testing module {0} not found. It will not be initialized", testingModule.Name), Constants.MessageType.Error);
             }
         }
         catch (Exception ex)
         {
             DoLog(string.Format("Critical error initializing module {0}:{1}", testingModule.Name, ex.Message), Constants.MessageType.Error);
         }
     }
 }
Exemple #2
0
        protected void ProcesssExecutionReportMessage(object param)
        {
            try
            {
                QuickFix.FIX44.ExecutionReport execReport = (QuickFix.FIX44.ExecutionReport)param;
                string clOrdId = execReport.GetString(QuickFix.Fields.Tags.ClOrdID);

                lock (tLock)
                {
                    if (SentOrders.ContainsKey(clOrdId))
                    {
                        string sender = SentOrders[clOrdId];

                        if (TestingModules.ContainsKey(sender))
                        {
                            FIXExecutionReportWrapper wrapper = new FIXExecutionReportWrapper(clOrdId, execReport, Configuration);
                            TestingModules[sender].ProcessMessage(wrapper);
                        }
                        else
                        {
                            DoLog(string.Format("{0}-Unknown sender @{1} ", Configuration.Name, sender), Fwk.Main.Common.Util.Constants.MessageType.Error);
                        }
                    }
                    else
                    {
                        DoLog(string.Format("{0}-Ignoring unknown ClOrdId execution report @{1} ", Configuration.Name, clOrdId), Fwk.Main.Common.Util.Constants.MessageType.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                DoLog(string.Format("Critical error processing execution report @{0}:{1}", Configuration.Name, ex.Message), Fwk.Main.Common.Util.Constants.MessageType.Error);
            }
        }
Exemple #3
0
        protected void ProcessNewOrder(object param)
        {
            try
            {
                lock (tLock)
                {
                    Wrapper wrapper = (Wrapper)param;
                    Order   order   = OrderConverter.ConvertNewOrder(wrapper);
                    string  sender  = (string)wrapper.GetField(OrderFields.SENDER);

                    if (!string.IsNullOrEmpty(sender) && TestingModules.ContainsKey(sender))
                    {
                        SentOrders.Add(order.ClOrdId, sender);

                        QuickFix.Message nos = FIXMessageCreator.CreateNewOrderSingle(order.ClOrdId, order.Security.Symbol, order.Side, order.OrdType, order.SettlType,
                                                                                      order.TimeInForce, order.EffectiveTime, order.OrderQty, order.Price, order.StopPx,
                                                                                      order.Account, order.Exchange);

                        Session.SendToTarget(nos, SessionID);

                        SendersDict.Add(nos.Header.GetInt(QuickFix.Fields.Tags.MsgSeqNum), sender);
                        KeysDict.Add(nos.Header.GetInt(QuickFix.Fields.Tags.MsgSeqNum), order.ClOrdId);
                    }
                    else
                    {
                        throw new Exception("Cannot create an order for unknown sender");
                    }
                }
            }
            catch (Exception ex)
            {
                DoLog(string.Format("Critical error processing new order @{0}:{1}", Configuration.Name, ex.Message), Fwk.Main.Common.Util.Constants.MessageType.Error);
            }
        }
Exemple #4
0
        protected void ProcessMessageReject(object param)
        {
            try
            {
                Reject reject = (Reject)param;

                int refSeqNum = reject.GetInt(QuickFix.Fields.Tags.RefSeqNum);

                if (SendersDict.ContainsKey(refSeqNum))
                {
                    string sender = SendersDict[refSeqNum];

                    if (TestingModules.ContainsKey(sender))
                    {
                        if (KeysDict.ContainsKey(refSeqNum))
                        {
                            string        key           = KeysDict[refSeqNum];
                            RejectWrapper rejectWrapper = new RejectWrapper(key, reject);
                            TestingModules[sender].ProcessMessage(rejectWrapper);
                        }
                        else
                        {
                            DoLog(string.Format("Discarding message because no key was identified @{0}: Sender={1}", Configuration.Name, sender), Fwk.Main.Common.Util.Constants.MessageType.Information);
                        }
                    }
                    else
                    {
                        DoLog(string.Format("Discarding message because no sender was identified @{0}: Sender={1}", Configuration.Name, sender), Fwk.Main.Common.Util.Constants.MessageType.Information);
                    }
                }
                else
                {
                    DoLog(string.Format("Discarding message because no sender was identified @{0}: Message={1}", Configuration.Name, refSeqNum), Fwk.Main.Common.Util.Constants.MessageType.Information);
                }
            }
            catch (Exception ex)
            {
                DoLog(string.Format("Critical error processing a Reject message @{0}:{1}", Configuration.Name, ex.Message), Fwk.Main.Common.Util.Constants.MessageType.Error);
            }
        }