public void PlaceMarketOrder_Test()
        {
            var orderParams = new MarketOrderParams
            {
                ClientOid = Guid.NewGuid().ToString(),
                Pair      = "ETH-BTC",
                Side      = Side.BUY,
                Size      = 2
            };

            var orderId = _service.PlaceMarketOrder(orderParams).Result;

            Assert.NotNull(orderId);
        }
示例#2
0
        long tl_newSendOrderRequest(Order o)
        {
            MarketOrderParams oOrderParams = new MarketOrderParams();

            oOrderParams.Account     = Account;
            oOrderParams.BuySellType = o.side ? Constants.BUY_SELL_TYPE_BUY : Constants.BUY_SELL_TYPE_SELL;
            oOrderParams.Context     = null;
            oOrderParams.Duration    = Constants.ORDER_DURATION_DAY;
            oOrderParams.EntryType   = Constants.ORDER_ENTRY_TYPE_AUTO;
            oOrderParams.Exchange    = o.ex;
            oOrderParams.Qty         = o.size;
            oOrderParams.Symbol      = o.symbol;
            oOrderParams.Tag         = o.id.ToString();
            oOrderParams.UserMsg     = o.comment;

            oEngine.sendOrder(oOrderParams);

            return((long)MessageTypes.OK);
        }
示例#3
0
        /// <summary>
        /// Place a market order
        /// </summary>
        /// <param name="parms">Market Order Parameters</param>
        /// <returns>String of order id</returns>
        public static async Task <string> PlaceMarketOrder(this IKuCoinDotNet service, MarketOrderParams parms)
        {
            var body = new SortedDictionary <string, object>();

            if (string.IsNullOrEmpty(parms.ClientOid))
            {
                parms.ClientOid = Guid.NewGuid().ToString();
            }
            if (parms.Funds > 0)
            {
                body.Add("funds", parms.Funds);
            }
            body.Add("clientOid", parms.ClientOid);
            body.Add("symbol", parms.Pair);
            if (!string.IsNullOrEmpty(parms.Remark))
            {
                body.Add("remark", parms.Remark);
            }
            if (parms.SelfTradeProtect != null)
            {
                body.Add("stp", parms.SelfTradeProtect.ToString());
            }
            body.Add("side", parms.Side.ToString().ToLower());
            body.Add("size", parms.Size);
            body.Add("type", parms.Type.ToString().ToLower());

            return(await service.PlaceOrder(body));
        }
示例#4
0
        long tl_newSendOrderRequest(Order o)
        {
            MarketOrderParams oOrderParams = new MarketOrderParams();
            oOrderParams.Account = Account;
            oOrderParams.BuySellType = o.side ? Constants.BUY_SELL_TYPE_BUY : Constants.BUY_SELL_TYPE_SELL;
            oOrderParams.Context = null;
            oOrderParams.Duration = Constants.ORDER_DURATION_DAY;
            oOrderParams.EntryType = Constants.ORDER_ENTRY_TYPE_AUTO;
            oOrderParams.Exchange = o.ex;
            oOrderParams.Qty = o.size;
            oOrderParams.Symbol = o.symbol;
            oOrderParams.Tag = o.id.ToString();
            oOrderParams.UserMsg = o.comment;

            oEngine.sendOrder(oOrderParams);

            return (long)MessageTypes.OK;
        }
示例#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;
          }
示例#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;
        }