Ejemplo n.º 1
0
        public RithmicClient(ILogReceiver receiver, string adminConnectionPoint, string certFile, string domainServerAddress, string domainName, string licenseServerAddress, string localBrokerAddress, string loggerAddress, string logFileName)
        {
            if (receiver == null)
            {
                throw new ArgumentNullException(nameof(receiver));
            }

            if (!File.Exists(certFile))
            {
                throw new FileNotFoundException(LocalizedStrings.Str3457Params.Put(certFile));
            }

            Callbacks = new RCallbacksImpl(this, receiver);

            var eParams = new REngineParams
            {
                AdmCnnctPt   = adminConnectionPoint,
                AdmCallbacks = new AdmCallbacksImpl(this, receiver),
                AppName      = "StockSharp",
                AppVersion   = GetType().Assembly.GetName().Version.ToString(),
                CertFile     = certFile,
                DmnSrvrAddr  = domainServerAddress,
                DomainName   = domainName,
                LicSrvrAddr  = licenseServerAddress,
                LocBrokAddr  = localBrokerAddress,
                LoggerAddr   = loggerAddress,
                LogFilePath  = logFileName,
            };

            Session = new REngine(eParams);
        }
Ejemplo n.º 2
0
		public RithmicClient(ILogReceiver receiver, string adminConnectionPoint, string certFile, string domainServerAddress, string domainName, string licenseServerAddress, string localBrokerAddress, string loggerAddress, string logFileName)
		{
			if (receiver == null)
				throw new ArgumentNullException(nameof(receiver));

			if (!File.Exists(certFile))
				throw new FileNotFoundException(LocalizedStrings.Str3457Params.Put(certFile));

			Callbacks = new RCallbacksImpl(this, receiver);

			var eParams = new REngineParams
			{
				AdmCnnctPt = adminConnectionPoint,
				AdmCallbacks = new AdmCallbacksImpl(this, receiver),
				AppName = "StockSharp",
				AppVersion = GetType().Assembly.GetName().Version.ToString(),
				CertFile = certFile,
				DmnSrvrAddr = domainServerAddress,
				DomainName = domainName,
				LicSrvrAddr = licenseServerAddress,
				LocBrokAddr = localBrokerAddress,
				LoggerAddr = loggerAddress,
				LogFilePath = logFileName,
			};

			Session = new REngine(eParams);
		}
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            string USAGE = "SampleMD adm_cnnct_pt " +
                           "user password md_cnnct_pt ts_cnnct_pt " +
                           "exchange symbol flags";

            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 sFlags      = 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      = "SampleMD.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)
                {
                    System.Threading.Thread.Sleep(1000);
                }

                /*   ------------------------------------------------------   */
                /*   Subscribe to the instrument of interest.  To express     */
                /*   interest in different types of updates, see              */
                /*   SubscriptionFlags.                                       */
                /*   ------------------------------------------------------   */

                oEngine.subscribe(sExchange,
                                  sSymbol,
                                  (SubscriptionFlags)Convert.ToInt32(sFlags),
                                  null);

                /*   ------------------------------------------------------   */
                /*   At this point the callback routines will start firing    */
                /*   on a different thread.  This main thread will wait       */
                /*   until a key is pressed before continuing.                */
                /*   ------------------------------------------------------   */

                Console.Read();

                /*   ------------------------------------------------------   */
                /*   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;
        }
Ejemplo n.º 4
0
     static void Main(string[] args)
          {
          string USAGE = "SampleMD adm_cnnct_pt " +
                         "user password md_cnnct_pt ts_cnnct_pt " +
                         "exchange symbol flags";

          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 sFlags      = 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      = "SampleMD.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)
                    {
                    System.Threading.Thread.Sleep(1000);
                    }

               /*   ------------------------------------------------------   */
               /*   Subscribe to the instrument of interest.  To express     */
               /*   interest in different types of updates, see              */
               /*   SubscriptionFlags.                                       */
               /*   ------------------------------------------------------   */

               oEngine.subscribe(sExchange, 
                    sSymbol, 
                    (SubscriptionFlags)Convert.ToInt32(sFlags), 
                    null);

               /*   ------------------------------------------------------   */
               /*   At this point the callback routines will start firing    */
               /*   on a different thread.  This main thread will wait       */
               /*   until a key is pressed before continuing.                */
               /*   ------------------------------------------------------   */

               Console.Read();

               /*   ------------------------------------------------------   */
               /*   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;
          }
Ejemplo n.º 5
0
     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;
          }
Ejemplo n.º 6
0
        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;
        }