Ejemplo n.º 1
0
        /// <summary>
        /// Create true market order request
        /// </summary>
        private static O2GRequest CreateTrueMarketOrderRequest(O2GSession session, string sOfferID, string sAccountID, int iAmount, string sBuySell)
        {
            O2GRequest        request        = null;
            O2GRequestFactory requestFactory = session.getRequestFactory();

            if (requestFactory == null)
            {
                throw new Exception("Cannot create request factory");
            }
            O2GValueMap valuemap = requestFactory.createValueMap();

            valuemap.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
            valuemap.setString(O2GRequestParamsEnum.OrderType, Constants.Orders.TrueMarketOpen);
            valuemap.setString(O2GRequestParamsEnum.AccountID, sAccountID);
            valuemap.setString(O2GRequestParamsEnum.OfferID, sOfferID);
            valuemap.setString(O2GRequestParamsEnum.BuySell, sBuySell);
            valuemap.setInt(O2GRequestParamsEnum.Amount, iAmount);
            valuemap.setString(O2GRequestParamsEnum.CustomID, "TrueMarketOrder");
            request = requestFactory.createOrderRequest(valuemap);
            if (request == null)
            {
                Console.WriteLine(requestFactory.getLastError());
            }
            return(request);
        }
Ejemplo n.º 2
0
        public void CreateRangeCloseOrder(string sOfferID, string sAccountID, string sTradeID, int iAmount, double dRateMin, double dRateMax, string sBuySell)
        {
            O2GRequestFactory factory = m_o2gsession.getRequestFactory();

            if (factory == null)
            {
                return;
            }
            O2GValueMap valuemap = factory.createValueMap();

            valuemap.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
            valuemap.setString(O2GRequestParamsEnum.OrderType, Constants.Orders.MarketCloseRange);
            valuemap.setString(O2GRequestParamsEnum.AccountID, sAccountID);
            valuemap.setString(O2GRequestParamsEnum.OfferID, sOfferID);              // The identifier of the instrument the order should be placed for.
            valuemap.setString(O2GRequestParamsEnum.TradeID, sTradeID);              // The identifier of the trade to be closed.
            valuemap.setString(O2GRequestParamsEnum.BuySell, sBuySell);              // The order direction (Constants.Buy for Buy, Constants.Sell for Sell). Must be opposite to the direction of the trade.
            valuemap.setInt(O2GRequestParamsEnum.Amount, iAmount);                   // The quantity of the instrument to be bought or sold. Must be <= size of the position (Lot of the trade). Must be divisible by baseUnitSize.
            valuemap.setDouble(O2GRequestParamsEnum.RateMin, dRateMin);              // The minimum dRate at which the order can be filled.
            valuemap.setDouble(O2GRequestParamsEnum.RateMax, dRateMax);              // The maximum dRate at which the order can be filled.
            valuemap.setString(O2GRequestParamsEnum.CustomID, "CloseRangeOrder");    // The custom identifier of the order.
            O2GRequest request = factory.createOrderRequest(valuemap);

            m_o2gsession.sendRequest(request);

            SaveOrders(sOfferID, sAccountID, sTradeID, iAmount, sBuySell);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create entry order with attached stop and limit orders request
        /// </summary>
        private static O2GRequest CreateELSRequest(O2GSession session, string sOfferID, string sAccountID, int iAmount, double dRate, double dRateLimit, double dRateStop, string sBuySell, string sOrderType)
        {
            O2GRequest        request        = null;
            O2GRequestFactory requestFactory = session.getRequestFactory();

            if (requestFactory == null)
            {
                throw new Exception("Cannot create request factory");
            }
            O2GValueMap valuemap = requestFactory.createValueMap();

            valuemap.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
            valuemap.setString(O2GRequestParamsEnum.OrderType, sOrderType);
            valuemap.setString(O2GRequestParamsEnum.AccountID, sAccountID);
            valuemap.setString(O2GRequestParamsEnum.OfferID, sOfferID);
            valuemap.setString(O2GRequestParamsEnum.BuySell, sBuySell);
            valuemap.setInt(O2GRequestParamsEnum.Amount, iAmount);
            valuemap.setDouble(O2GRequestParamsEnum.Rate, dRate);
            valuemap.setDouble(O2GRequestParamsEnum.RateLimit, dRateLimit);
            valuemap.setDouble(O2GRequestParamsEnum.RateStop, dRateStop);
            valuemap.setString(O2GRequestParamsEnum.CustomID, "EntryOrderWithStopLimit");
            request = requestFactory.createOrderRequest(valuemap);
            if (request == null)
            {
                Console.WriteLine(requestFactory.getLastError());
            }
            return(request);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create entry order request
        /// </summary>
        private static O2GRequest CreateEntryOrderRequest(O2GSession session, string sOfferID, string sAccountID, int iAmount, double dRate, string sBuySell, string sOrderType, string sExpireDate)
        {
            O2GRequest        request        = null;
            O2GRequestFactory requestFactory = session.getRequestFactory();

            if (requestFactory == null)
            {
                throw new Exception("Cannot create request factory");
            }
            O2GValueMap valuemap = requestFactory.createValueMap();

            valuemap.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
            valuemap.setString(O2GRequestParamsEnum.OrderType, sOrderType);
            valuemap.setString(O2GRequestParamsEnum.AccountID, sAccountID);
            valuemap.setString(O2GRequestParamsEnum.OfferID, sOfferID);
            valuemap.setString(O2GRequestParamsEnum.BuySell, sBuySell);
            valuemap.setInt(O2GRequestParamsEnum.Amount, iAmount);
            valuemap.setDouble(O2GRequestParamsEnum.Rate, dRate);
            valuemap.setString(O2GRequestParamsEnum.CustomID, "EntryOrder");

            if (!string.IsNullOrEmpty(sExpireDate))
            {
                valuemap.setString(O2GRequestParamsEnum.TimeInForce, Constants.TIF.GTD);
                valuemap.setString(O2GRequestParamsEnum.ExpireDateTime, sExpireDate); // UTCTimestamp format: "yyyyMMdd-HH:mm:ss.SSS" (milliseconds are optional)
            }

            request = requestFactory.createOrderRequest(valuemap);
            if (request == null)
            {
                Console.WriteLine(requestFactory.getLastError());
            }
            return(request);
        }
Ejemplo n.º 5
0
        /***************************************************************************************************************/
        /*****                                      TRUE MARKET ORDERS                                             *****/
        /***************************************************************************************************************/

        /* True Market Order */
        public void CreateTrueMarketOrder(string sOfferID, string sAccountID, int iAmount, string sBuySell)
        {
            try
            {
                O2GRequestFactory factory = m_o2gsession.getRequestFactory();
                if (factory == null)
                {
                    return;
                }
                O2GValueMap valuemap = factory.createValueMap();
                valuemap.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
                valuemap.setString(O2GRequestParamsEnum.OrderType, Constants.Orders.TrueMarketOpen);
                valuemap.setString(O2GRequestParamsEnum.AccountID, sAccountID);          // The identifier of the account the order should be placed for.
                valuemap.setString(O2GRequestParamsEnum.OfferID, sOfferID);              // The identifier of the instrument the order should be placed for.
                valuemap.setString(O2GRequestParamsEnum.BuySell, sBuySell);              // The order direction: Constants.Sell for "Sell", Constants.Buy for "Buy".
                valuemap.setInt(O2GRequestParamsEnum.Amount, iAmount);                   // The quantity of the instrument to be bought or sold.
                valuemap.setString(O2GRequestParamsEnum.CustomID, "TrueMarketOrder");    // The custom identifier of the order.

                if (sBuySell == "Buy")
                {
                    valuemap.setString(O2GRequestParamsEnum.BuySell, Constants.Buy);
                }
                else
                {
                    valuemap.setString(O2GRequestParamsEnum.BuySell, Constants.Sell);
                }

                O2GRequest request = factory.createOrderRequest(valuemap);
                m_o2gsession.sendRequest(request);
            }
            catch
            {
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Create request for join two existing entry orders into a new contingency group
        /// </summary>
        private static O2GRequest JoinToNewGroupRequest(O2GSession session, string sAccountID, string sPrimaryID, string sSecondaryID, int iContingencyType)
        {
            O2GRequest        request        = null;
            O2GRequestFactory requestFactory = session.getRequestFactory();

            if (requestFactory == null)
            {
                throw new Exception("Cannot create request factory");
            }
            O2GValueMap valuemapMain = requestFactory.createValueMap();

            valuemapMain.setString(O2GRequestParamsEnum.Command, Constants.Commands.JoinToNewContingencyGroup);
            valuemapMain.setInt(O2GRequestParamsEnum.ContingencyGroupType, iContingencyType);

            O2GValueMap valuemapChild;

            valuemapChild = requestFactory.createValueMap();
            valuemapChild.setString(O2GRequestParamsEnum.OrderID, sPrimaryID);
            valuemapChild.setString(O2GRequestParamsEnum.AccountID, sAccountID);
            valuemapMain.appendChild(valuemapChild);

            valuemapChild = requestFactory.createValueMap();
            valuemapChild.setString(O2GRequestParamsEnum.OrderID, sSecondaryID);
            valuemapChild.setString(O2GRequestParamsEnum.AccountID, sAccountID);
            valuemapMain.appendChild(valuemapChild);

            request = requestFactory.createOrderRequest(valuemapMain);
            if (request == null)
            {
                Console.WriteLine(requestFactory.getLastError());
            }
            return(request);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Create OTO request
        /// </summary>
        private static O2GRequest CreateOTO_ELSRequest(O2GSession session, string sOfferID, string sAccountID, int iAmount, double dRateOTO, double dRateELS, double dRateELS_stop, double dRateELS_limit)
        {
            O2GRequest        request        = null;
            O2GRequestFactory requestFactory = session.getRequestFactory();

            if (requestFactory == null)
            {
                throw new Exception("Cannot create request factory");
            }

            // Create OTO command
            O2GValueMap valuemapMain = requestFactory.createValueMap();

            valuemapMain.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOTO);

            // ValueMap for if-then
            O2GValueMap valuemapIf = requestFactory.createValueMap();

            valuemapIf.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
            valuemapIf.setString(O2GRequestParamsEnum.OrderType, Constants.Orders.LimitEntry);
            valuemapIf.setString(O2GRequestParamsEnum.AccountID, sAccountID);
            valuemapIf.setString(O2GRequestParamsEnum.OfferID, sOfferID);
            valuemapIf.setString(O2GRequestParamsEnum.BuySell, Constants.Sell);
            valuemapIf.setInt(O2GRequestParamsEnum.Amount, 0);
            valuemapIf.setDouble(O2GRequestParamsEnum.Rate, dRateOTO);
            valuemapIf.setString(O2GRequestParamsEnum.CustomID, "if-then-order");
            valuemapMain.appendChild(valuemapIf);

            //valuemapELS for ELS order
            O2GValueMap valuemapELS = requestFactory.createValueMap();

            valuemapELS.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
            valuemapELS.setString(O2GRequestParamsEnum.OrderType, "LE");
            valuemapELS.setString(O2GRequestParamsEnum.AccountID, sAccountID);
            valuemapELS.setString(O2GRequestParamsEnum.OfferID, sOfferID);
            valuemapELS.setString(O2GRequestParamsEnum.BuySell, "B");
            valuemapELS.setInt(O2GRequestParamsEnum.Amount, iAmount);
            valuemapELS.setDouble(O2GRequestParamsEnum.Rate, dRateELS);
            valuemapELS.setDouble(O2GRequestParamsEnum.RateLimit, dRateELS_limit);
            valuemapELS.setDouble(O2GRequestParamsEnum.RateStop, dRateELS_stop);
            valuemapELS.setString(O2GRequestParamsEnum.CustomID, "ELS-order");
            valuemapMain.appendChild(valuemapELS);


            request = requestFactory.createOrderRequest(valuemapMain);
            if (request == null)
            {
                Console.WriteLine(requestFactory.getLastError());
            }
            return(request);
        }
Ejemplo n.º 8
0
        public void CreateTrueMarketOrder(string accountID, string sOfferID, int iAmount, string sBuySell)
        {
            O2GRequestFactory factory = _session.Session.getRequestFactory();

            O2GValueMap valuemap = factory.createValueMap();

            valuemap.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
            valuemap.setString(O2GRequestParamsEnum.OrderType, Constants.Order.TrueMarketOpen);
            valuemap.setString(O2GRequestParamsEnum.AccountID, accountID);                                           // The identifier of the account the order should be placed for.
            valuemap.setString(O2GRequestParamsEnum.OfferID, sOfferID);                                              // The identifier of the instrument the order should be placed for.
            valuemap.setString(O2GRequestParamsEnum.BuySell, (sBuySell.Equals("Buy")?Constants.Buy:Constants.Sell)); // The order direction: Constants.Sell for "Sell", Constants.Buy for "Buy".
            valuemap.setInt(O2GRequestParamsEnum.Amount, iAmount);                                                   // The quantity of the instrument to be bought or sold.
            valuemap.setString(O2GRequestParamsEnum.CustomID, "TrueMarketOrder");                                    // The custom identifier of the order.

            O2GRequest request = factory.createOrderRequest(valuemap);

            _session.Session.sendRequest(request);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Create OTO request
        /// </summary>
        private static O2GRequest CreateOTORequest(O2GSession session, string sOfferID, string sAccountID, int iAmount, double dRatePrimary, double dRateSecondary)
        {
            O2GRequest        request        = null;
            O2GRequestFactory requestFactory = session.getRequestFactory();

            if (requestFactory == null)
            {
                throw new Exception("Cannot create request factory");
            }
            O2GValueMap valuemapMain = requestFactory.createValueMap();

            valuemapMain.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOTO);

            // ValueMap for primary order
            O2GValueMap valuemapPrimary = requestFactory.createValueMap();

            valuemapPrimary.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
            valuemapPrimary.setString(O2GRequestParamsEnum.OrderType, Constants.Orders.StopEntry);
            valuemapPrimary.setString(O2GRequestParamsEnum.AccountID, sAccountID);
            valuemapPrimary.setString(O2GRequestParamsEnum.OfferID, sOfferID);
            valuemapPrimary.setString(O2GRequestParamsEnum.BuySell, Constants.Sell);
            valuemapPrimary.setInt(O2GRequestParamsEnum.Amount, iAmount);
            valuemapPrimary.setDouble(O2GRequestParamsEnum.Rate, dRatePrimary);
            valuemapMain.appendChild(valuemapPrimary);

            // ValueMap for secondary order
            O2GValueMap valuemapSecondary = requestFactory.createValueMap();

            valuemapSecondary.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
            valuemapSecondary.setString(O2GRequestParamsEnum.OrderType, Constants.Orders.StopEntry);
            valuemapSecondary.setString(O2GRequestParamsEnum.AccountID, sAccountID);
            valuemapSecondary.setString(O2GRequestParamsEnum.OfferID, sOfferID);
            valuemapSecondary.setString(O2GRequestParamsEnum.BuySell, Constants.Buy);
            valuemapSecondary.setInt(O2GRequestParamsEnum.Amount, iAmount);
            valuemapSecondary.setDouble(O2GRequestParamsEnum.Rate, dRateSecondary);
            valuemapMain.appendChild(valuemapSecondary);

            request = requestFactory.createOrderRequest(valuemapMain);
            if (request == null)
            {
                Console.WriteLine(requestFactory.getLastError());
            }
            return(request);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Create close market order request
        /// </summary>
        private static O2GRequest CreateCloseMarketOrderRequest(O2GSession session, string sInstrument, O2GTradeRow tradeRow)
        {
            O2GRequest        request        = null;
            O2GRequestFactory requestFactory = session.getRequestFactory();

            if (requestFactory == null)
            {
                throw new Exception("Cannot create request factory");
            }

            O2GLoginRules        loginRules        = session.getLoginRules();
            O2GPermissionChecker permissionChecker = loginRules.getPermissionChecker();

            O2GValueMap valuemap = requestFactory.createValueMap();

            valuemap.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);

            if (permissionChecker.canCreateMarketCloseOrder(sInstrument) != O2GPermissionStatus.PermissionEnabled)
            {
                valuemap.setString(O2GRequestParamsEnum.OrderType, Constants.Orders.TrueMarketOpen); // in USA you need to use "OM" to close a position.
            }
            else
            {
                valuemap.setString(O2GRequestParamsEnum.OrderType, Constants.Orders.TrueMarketClose);
                valuemap.setString(O2GRequestParamsEnum.TradeID, tradeRow.TradeID);
            }

            valuemap.setString(O2GRequestParamsEnum.AccountID, tradeRow.AccountID);
            valuemap.setString(O2GRequestParamsEnum.OfferID, tradeRow.OfferID);
            valuemap.setString(O2GRequestParamsEnum.BuySell, tradeRow.BuySell.Equals(Constants.Buy) ? Constants.Sell : Constants.Buy);
            valuemap.setInt(O2GRequestParamsEnum.Amount, tradeRow.Amount);
            valuemap.setString(O2GRequestParamsEnum.CustomID, "CloseMarketOrder");
            request = requestFactory.createOrderRequest(valuemap);
            if (request == null)
            {
                Console.WriteLine(requestFactory.getLastError());
            }
            return(request);
        }
Ejemplo n.º 11
0
        /***************************************************************************************************************/



        /***************************************************************************************************************/
        /*****                                      OPEN ORDERS                                                    *****/
        /***************************************************************************************************************/

        /* Open Order (Market Order) */
        public void CreateMarketOrder(string sOfferID, string sAccountID, int iAmount, double dRate, string sBuySell)
        {
            O2GRequestFactory factory = m_o2gsession.getRequestFactory();

            if (factory == null)
            {
                return;
            }
            O2GValueMap valuemap = factory.createValueMap();

            valuemap.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
            valuemap.setString(O2GRequestParamsEnum.OrderType, Constants.Orders.MarketOpen);
            valuemap.setString(O2GRequestParamsEnum.AccountID, sAccountID);               // The identifier of the account the order should be placed for.
            valuemap.setString(O2GRequestParamsEnum.OfferID, sOfferID);                   // The identifier of the instrument the order should be placed for.
            valuemap.setString(O2GRequestParamsEnum.BuySell, sBuySell);                   // The order direction (use Constants.Buy for Buy, Constants.Sell for Sell)
            valuemap.setDouble(O2GRequestParamsEnum.Rate, dRate);                         // The dRate at which the order must be filled.
            valuemap.setInt(O2GRequestParamsEnum.Amount, iAmount);                        // The quantity of the instrument to be bought or sold.
            valuemap.setString(O2GRequestParamsEnum.CustomID, "OpenMarketOrder");         // The custom identifier of the order.

            O2GRequest request = factory.createOrderRequest(valuemap);

            m_o2gsession.sendRequest(request);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Create OTO request
        /// </summary>
        private static O2GRequest CreateOTOCORequest(O2GSession session, string sOfferID, string sAccountID, int iAmount, double dRatePrimary, double dRateOcoFirst, double dRateOcoSecond)
        {
            O2GRequest        request        = null;
            O2GRequestFactory requestFactory = session.getRequestFactory();

            if (requestFactory == null)
            {
                throw new Exception("Cannot create request factory");
            }

            // Create OTO command
            O2GValueMap valuemapMain = requestFactory.createValueMap();

            valuemapMain.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOTO);

            // Create Entry order
            O2GValueMap valuemapPrimary = requestFactory.createValueMap();

            valuemapPrimary.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
            valuemapPrimary.setString(O2GRequestParamsEnum.OrderType, Constants.Orders.StopEntry);
            valuemapPrimary.setString(O2GRequestParamsEnum.AccountID, sAccountID);
            valuemapPrimary.setString(O2GRequestParamsEnum.OfferID, sOfferID);
            valuemapPrimary.setString(O2GRequestParamsEnum.BuySell, Constants.Sell);
            valuemapPrimary.setInt(O2GRequestParamsEnum.Amount, iAmount);
            valuemapPrimary.setDouble(O2GRequestParamsEnum.Rate, dRatePrimary);

            // Create OCO group of orders
            O2GValueMap valuemapOCO = requestFactory.createValueMap();

            valuemapOCO.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOCO);

            // Create Entry order to OCO
            O2GValueMap valuemapOCOFirst = requestFactory.createValueMap();

            valuemapOCOFirst.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
            valuemapOCOFirst.setString(O2GRequestParamsEnum.OrderType, Constants.Orders.StopEntry);
            valuemapOCOFirst.setString(O2GRequestParamsEnum.AccountID, sAccountID);
            valuemapOCOFirst.setString(O2GRequestParamsEnum.OfferID, sOfferID);
            valuemapOCOFirst.setString(O2GRequestParamsEnum.BuySell, Constants.Buy);
            valuemapOCOFirst.setInt(O2GRequestParamsEnum.Amount, iAmount);
            valuemapOCOFirst.setDouble(O2GRequestParamsEnum.Rate, dRateOcoFirst);

            O2GValueMap valuemapOCOSecond = requestFactory.createValueMap();

            valuemapOCOSecond.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
            valuemapOCOSecond.setString(O2GRequestParamsEnum.OrderType, Constants.Orders.StopEntry);
            valuemapOCOSecond.setString(O2GRequestParamsEnum.AccountID, sAccountID);
            valuemapOCOSecond.setString(O2GRequestParamsEnum.OfferID, sOfferID);
            valuemapOCOSecond.setString(O2GRequestParamsEnum.BuySell, Constants.Sell);
            valuemapOCOSecond.setInt(O2GRequestParamsEnum.Amount, iAmount);
            valuemapOCOSecond.setDouble(O2GRequestParamsEnum.Rate, dRateOcoSecond);

            // Fill the created groups. Please note, first you should add an entry order to OTO order and then OCO group of orders
            valuemapMain.appendChild(valuemapPrimary);
            valuemapOCO.appendChild(valuemapOCOFirst);
            valuemapOCO.appendChild(valuemapOCOSecond);
            valuemapMain.appendChild(valuemapOCO);

            request = requestFactory.createOrderRequest(valuemapMain);
            if (request == null)
            {
                Console.WriteLine(requestFactory.getLastError());
            }
            return(request);
        }
        public static bool CreateMarketOrder(this FxcmBroker fxcm, string instrument, int lotsAmount, TradeDirection direction, out string orderId, double?rateStop = null, double?rateLimit = null)
        {
            orderId = string.Empty;

            if (fxcm.Status != ConnectStatus.Connected)
            {
                Log.Error("FXCM not connected");

                return(false);
            }

            O2GOfferRow offer = GetOffer(fxcm.Session, instrument);

            if (offer == null)
            {
                throw new Exception(string.Format("The instrument '{0}' is not valid", instrument));
            }

            O2GRequest        request        = null;
            O2GRequestFactory requestFactory = fxcm.Session.getRequestFactory();

            if (requestFactory == null)
            {
                throw new Exception("Cannot create request factory");
            }
            var         account  = GetAccount(fxcm.Session);
            O2GValueMap valuemap = requestFactory.createValueMap();

            valuemap.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder);
            valuemap.setString(O2GRequestParamsEnum.OrderType, Constants.Orders.TrueMarketOpen);
            valuemap.setString(O2GRequestParamsEnum.AccountID, account.AccountID);
            valuemap.setString(O2GRequestParamsEnum.OfferID, offer.OfferID);
            valuemap.setString(O2GRequestParamsEnum.BuySell, direction == TradeDirection.Long ? "B" : "S");

            if (rateStop != null)
            {
                valuemap.setDouble(O2GRequestParamsEnum.RateStop, rateStop.Value);
            }

            if (rateLimit != null)
            {
                valuemap.setDouble(O2GRequestParamsEnum.RateLimit, rateLimit.Value);
            }

            // Get account
            var loginRules = fxcm.Session.getLoginRules();
            var tradingSettingsProvider = loginRules.getTradingSettingsProvider();
            int iBaseUnitSize           = tradingSettingsProvider.getBaseUnitSize(instrument, account);
            int iAmount = iBaseUnitSize * lotsAmount;

            valuemap.setInt(O2GRequestParamsEnum.Amount, iAmount);
            valuemap.setString(O2GRequestParamsEnum.CustomID, "TrueMarketOrder");
            request = requestFactory.createOrderRequest(valuemap);

            if (request == null)
            {
                Log.Error($"Unable to process request - {requestFactory.getLastError()}");
                return(false);
            }

            var ret = ProcessOrderRequest(fxcm, request, out orderId);

            return(ret);
        }