static void Main(string[] args) { string USAGE = "SampleOrder adm_cnnct_pt " + "user password md_cnnct_pt ts_cnnct_pt " + "exchange symbol [B|S]"; if (args.Length < 8) { System.Console.Out.WriteLine(USAGE); return; } /* ----------------------------------------------------------- */ string sAdmCnnctPt = args[0]; string sUser = args[1]; string sPassword = args[2]; string sMdCnnctPt = args[3]; string sTsCnnctPt = args[4]; string sExchange = args[5]; string sSymbol = args[6]; string sBuySellType = args[7]; /* ----------------------------------------------------------- */ MyAdmCallbacks oAdmCallbacks = new MyAdmCallbacks(); MyCallbacks oCallbacks = new MyCallbacks(); REngineParams oParams = new REngineParams(); REngine oEngine; /* ---------------------------------------------------------- */ /* You may need to change some values, such as the CertFile */ /* ---------------------------------------------------------- */ oParams.AdmCnnctPt = sAdmCnnctPt; oParams.AppName = "SampleOrder.NET"; oParams.AppVersion = "1.0.0.0"; oParams.AdmCallbacks = oAdmCallbacks; oParams.CertFile = "c:\\data\\rithmiccerts\\RithmicCertificate.pk12"; oParams.DmnSrvrAddr = "rituz01000.01.rithmic.com:65000"; oParams.DomainName = "rithmic_uat_01_dmz_domain"; oParams.LicSrvrAddr = "rituz01000.01.rithmic.com:56000"; oParams.LocBrokAddr = "rituz01000.01.rithmic.com:64100"; oParams.LoggerAddr = "rituz01000.01.rithmic.com:45454"; /* ---------------------------------------------------------- */ try { /* ------------------------------------------------------ */ /* Instantiate the REngine. */ /* ------------------------------------------------------ */ oEngine = new REngine(oParams); /* ------------------------------------------------------ */ /* Initiate the login. */ /* ------------------------------------------------------ */ oEngine.login(oCallbacks, sUser, sPassword, sMdCnnctPt, sTsCnnctPt, string.Empty, string.Empty); /* ------------------------------------------------------ */ /* After calling REngine::login, RCallbacks::Alert will be */ /* called a number of times. Wait for when the login to */ /* the MdCnnctPt and TsCnnctPt is complete. (See */ /* MyCallbacks::Alert() for details). */ /* ------------------------------------------------------ */ while (!oCallbacks.LoggedIntoMd || !oCallbacks.LoggedIntoTs) { System.Threading.Thread.Sleep(1000); } /* ------------------------------------------------------ */ /* Wait for the AccountList callback to fire, so we know */ /* which accounts we are permissioned on. The account on */ /* which we place the order will be the first account in */ /* the list. See MyCallbacks::AccountList() for details. */ /* ------------------------------------------------------ */ while (!oCallbacks.GotAccounts) { System.Threading.Thread.Sleep(1000); } /* ------------------------------------------------------ */ if (oCallbacks.Account == null) { System.Console.WriteLine("Error : didn't get an account"); return; } /* ------------------------------------------------------ */ /* Subscribe to account activity. By doing so, we will */ /* receive updates for orders placed on the account and */ /* pnl updates for that account. */ /* ------------------------------------------------------ */ oEngine.subscribeAccount(oCallbacks.Account); /* ------------------------------------------------------ */ /* Prepare the order params and then send it. */ /* ------------------------------------------------------ */ MarketOrderParams oOrderParams = new MarketOrderParams(); oOrderParams.Account = oCallbacks.Account; oOrderParams.BuySellType = sBuySellType; oOrderParams.Context = null; oOrderParams.Duration = Constants.ORDER_DURATION_DAY; oOrderParams.EntryType = Constants.ORDER_ENTRY_TYPE_MANUAL; oOrderParams.Exchange = sExchange; oOrderParams.Qty = 1; oOrderParams.Symbol = sSymbol; oOrderParams.Tag = null; oOrderParams.UserMsg = null; oEngine.sendOrder(oOrderParams); /* ------------------------------------------------------ */ /* Wait for the order to complete. A number of related */ /* callbacks will fire, but the one controlling the status */ /* of complete is done in MyCallbacks::LineUpdate(). */ /* ------------------------------------------------------ */ while (!oCallbacks.OrderComplete) { System.Threading.Thread.Sleep(1000); } /* ------------------------------------------------------ */ /* We are done, so log out... */ /* ------------------------------------------------------ */ oEngine.logout(); /* ------------------------------------------------------ */ /* and shutdown the REngine instance. */ /* ------------------------------------------------------ */ oEngine.shutdown(); } catch (OMException oEx) { System.Console.Out.WriteLine("error : {0}", oEx.Message); } catch (Exception e) { System.Console.Out.WriteLine("exception : {0}", e.Message); } /* ---------------------------------------------------------- */ return; }