Example #1
0
        public void DeleteOrder(string operationId, string orderId, string clientID, TradeRecordSide side, int timeoutInMilliseconds)
        {
            if (operationId == null)
                operationId = string.Empty;

            this.VerifyInitialized();

            Native.TradeServer.DeleteOrder(this.handle, operationId, orderId, clientID, side, (uint)timeoutInMilliseconds);
        }
Example #2
0
        public FxOrder ModifyOrder(string operationId, string orderId, string clientId,
                                   string symbol, TradeRecordType type, TradeRecordSide side,
                                   double?newVolume, double?newMaxVisibleVolume,
                                   double?newPrice, double?newStopPrice,
                                   double?newStopLoss, double?newTakeProfit,
                                   DateTime?newExpiration,
                                   string newComment,
                                   string newTag,
                                   int?newMagic,
                                   double?prevVolume,
                                   bool?IOCOverride,
                                   bool?IFMOverride,
                                   int timeoutInMilliseconds)
        {
            if (operationId == null)
            {
                operationId = string.Empty;
            }
            if (orderId == null)
            {
                orderId = string.Empty;
            }
            if (clientId == null)
            {
                clientId = string.Empty;
            }
            if (newComment == null)
            {
                newComment = string.Empty;
            }
            else if (newComment == string.Empty)
            {
                newComment = "<empty>";
            }
            if (newTag == null)
            {
                newTag = string.Empty;
            }
            else if (newTag == string.Empty)
            {
                newTag = "<empty>";
            }

            this.VerifyInitialized();

            this.Validate(nameof(newVolume), newVolume);
            this.Validate(nameof(newMaxVisibleVolume), newMaxVisibleVolume);
            this.Validate(nameof(newPrice), newPrice);
            this.Validate(nameof(newStopPrice), newStopPrice);
            this.Validate(nameof(newStopLoss), newStopLoss);
            this.Validate(nameof(newTakeProfit), newTakeProfit);
            this.Validate(nameof(prevVolume), prevVolume);

            var order = new FxOrder(orderId, clientId, symbol, (int)type, side, newVolume, newMaxVisibleVolume, newPrice, newStopPrice, newStopLoss, newTakeProfit, newExpiration, newComment, newTag, newMagic, prevVolume, IOCOverride, IFMOverride);

            return(Native.TradeServer.ModifyOrder(this.handle, operationId, order, (uint)timeoutInMilliseconds));
        }
Example #3
0
        /// <summary>
        /// Returns ask for buy and bid for sell
        /// </summary>
        /// <param name="side">trade entry side</param>
        /// <returns></returns>
        public double PriceFromSide(TradeRecordSide side)
        {
            if (side == TradeRecordSide.Buy)
                return this.Ask;
            else if (side == TradeRecordSide.Sell)
                return this.Bid;

            var message = string.Format("Unknown side = {0}", side);
            throw new ArgumentException(message, nameof(side));
        }
Example #4
0
        public FxOrder OpenNewOrder(string operationId, string symbol, TradeCommand command, TradeRecordSide side, double priceThreshold, double volume, double? stopLoss, double? takeProfit, DateTime? expiration, string comment, int timeoutInMilliseconds)
        {
            if (operationId == null)
                operationId = string.Empty;

            this.VerifyInitialized();

            var order = new FxOrder(symbol, (int)command, side, priceThreshold, volume, stopLoss, takeProfit, expiration, comment);

            return Native.TradeServer.OpenNewOrder(this.handle, operationId, order, (uint)timeoutInMilliseconds); 
        }
Example #5
0
 /// <summary>
 /// Creates a new instance of trade entry.
 /// </summary>
 /// <param name="owner">valid account entry instance</param>
 /// <param name="type"></param>
 /// <param name="side"></param>
 /// <param name="symbol"></param>
 /// <param name="volume"></param>
 /// <param name="maxVisibleVolume"></param>
 /// <param name="price"></param>
 /// <param name="stopPrice"></param>
 /// <param name="staticMarginRate"></param>
 public TradeEntry(AccountEntry owner, TradeRecordType type, TradeRecordSide side, string symbol, double volume, double?maxVisibleVolume, double?price, double?stopPrice, double?staticMarginRate = null)
     : base(owner)
 {
     this.Type             = type;
     this.Side             = side;
     this.Symbol           = symbol;
     this.Volume           = volume;
     this.MaxVisibleVolume = maxVisibleVolume;
     this.Price            = price;
     this.StopPrice        = stopPrice;
     //this.StaticMarginRate = staticMarginRate;
 }
Example #6
0
        public static OrderSides ToOrderSides(TradeRecordSide side)
        {
            switch (side)
            {
                case TradeRecordSide.Buy:
                    return OrderSides.Buy;
                case TradeRecordSide.Sell:
                    return OrderSides.Sell;
            }

            throw new ArgumentException("side");
        }
Example #7
0
 /// <summary>
 /// The method modifies an existing trade record.
 /// </summary>
 /// <param name="orderId">An existing pending order ID.</param>
 /// <param name="symbol">Currency pair.</param>
 /// <param name="type">Order type: Limit or Stop.</param>
 /// <param name="side">Order side: buy or sell.</param>
 /// <param name="newVolume">A new volume of pending order.</param>
 /// <param name="newMaxVisibleVolume">A new max visible volume of pending order.</param>
 /// <param name="newPrice">A new price of pending order.</param>
 /// <param name="newStopPrice">A new stop price of pending order.</param>
 /// <param name="newStopLoss">A new stop loss price of pending order.</param>
 /// <param name="newTakeProfit">A new take profit price of pending order.</param>
 /// <param name="newExpiration">A new expiration time.</param>
 /// <param name="newComment">A new comment.</param>
 /// <param name="newTag">A new tag.</param>
 /// <param name="newMagic">A new magic.</param>
 /// <returns>A modified trade record.</returns>
 public TradeRecord ModifyTradeRecord(
     string orderId, string symbol, TradeRecordType type, TradeRecordSide side,
     double? newVolume, double? newMaxVisibleVolume,
     double? newPrice, double? newStopPrice,
     double? newStopLoss, double? newTakeProfit,
     DateTime? newExpiration,
     string newComment,
     string newTag,
     int? newMagic)
 {
     return this.ModifyTradeRecordEx(orderId, symbol, type, side, newVolume, newMaxVisibleVolume, newPrice, newStopPrice, newStopLoss, newTakeProfit, newExpiration, newComment, newTag, newMagic, null, null, null, this.Client.SynchOperationTimeout);
 }
Example #8
0
        public static OrderSides ToOrderSides(TradeRecordSide side)
        {
            switch (side)
            {
            case TradeRecordSide.Buy:
                return(OrderSides.Buy);

            case TradeRecordSide.Sell:
                return(OrderSides.Sell);
            }

            throw new ArgumentException("side");
        }
Example #9
0
        /// <summary>
        /// Returns bid for buy and ask for sell
        /// </summary>
        /// <param name="side">trade entry side</param>
        /// <returns></returns>
        public double PriceFromOppositeSide(TradeRecordSide side)
        {
            switch (side)
            {
                case TradeRecordSide.Buy:
                    return this.Bid;
                case TradeRecordSide.Sell:
                    return this.Ask;
            }

            var message = string.Format("Unknown side = {0}", side);
            throw new ArgumentException(message, nameof(side));
        }
Example #10
0
File: FxOrder.cs Project: ifzz/FDK
 public FxOrder(string symbol, int type, TradeRecordSide side, double price, double volume, double? stopLoss, double? takeProfit, DateTime? expiration, string comment)
     : this()
 {
     this.Symbol = symbol;
     this.Type = type;
     this.Side = side;
     this.Price = price;
     this.Volume = volume;
     this.StopLoss = stopLoss;
     this.TakeProfit = takeProfit;
     this.Expiration = expiration;
     this.Comment = comment;
 }
Example #11
0
        private void SendMarketOrder()
        {
            string          symbol = _symbols[0];
            double          volume = 100000;
            TradeRecordSide side   = TradeRecordSide.Buy;
            double          price  = TryGetOpenPrice(symbol, side);

            DateTime sendTime    = DateTime.UtcNow;
            var      tradeRecord = this.Trade.Server.SendOrderEx(Trade.GenerateOperationId(), symbol, TradeCommand.Market, side, price, volume, null, null, null, null);

            _positions.Add(tradeRecord.OrderId);
            Console.WriteLine("SendMarketOrder(): {0} {1} {2} {3} at {4}", sendTime.ToString(Settings1.Default.DTFormat), side, volume, symbol, price);
        }
Example #12
0
 /// <summary>
 /// The method modifies an existing trade record.
 /// </summary>
 /// <param name="operationId">
 /// Can be null, in this case FDK generates a new unique operation ID automatically.
 /// Otherwise, please use GenerateOperationId method of DataClient object.
 /// </param>
 /// <param name="orderId">An existing pending order ID.</param>
 /// <param name="symbol">Currency pair.</param>
 /// <param name="type">Order type: Limit or Stop.</param>
 /// <param name="side">Order side: buy or sell.</param>
 /// <param name="newVolume">A new volume of pending order.</param>
 /// <param name="newMaxVisibleVolume">A new max visible volume of pending order.</param>
 /// <param name="newPrice">A new price of pending order.</param>
 /// <param name="newStopPrice">A new stop price of pending order.</param>
 /// <param name="newStopLoss">A new stop loss price of pending order.</param>
 /// <param name="newTakeProfit">A new take profit price of pending order.</param>
 /// <param name="newExpiration">A new expiration time.</param>
 /// <param name="newComment">A new comment.</param>
 /// <param name="newTag">A new tag.</param>
 /// <param name="newMagic">A new magic.</param>
 /// <param name="prevVoume">Previous amount to check on server if threre was no amount modification during request.
 /// If PrevAmount is provided and server Amount is different modify operation will rejected</param>
 /// <param name="IOCOverride">'Immediate-Or-Cancel' flag override.</param>
 /// <param name="IFMOverride">'In-Flight-Mitigation' flag override.</param>
 /// <returns>A modified trade record.</returns>
 public TradeRecord ModifyTradeRecordEx(
     string operationId, string orderId, string symbol, TradeRecordType type, TradeRecordSide side,
     double? newVolume, double? newMaxVisibleVolume,
     double? newPrice, double? newStopPrice,
     double? newStopLoss, double? newTakeProfit,
     DateTime? newExpiration,
     string newComment,
     string newTag,
     int? newMagic,
     double? prevVolume,
     bool? IOCOverride,
     bool? IFMOverride)
 {
     return this.ModifyTradeRecordEx(operationId, orderId, "Client-" + orderId, symbol, type, side, newVolume, newMaxVisibleVolume, newPrice, newStopPrice, newStopLoss, newTakeProfit, newExpiration, newComment, newTag, newMagic, prevVolume, IOCOverride, IFMOverride, this.Client.SynchOperationTimeout);
 }
Example #13
0
        /// <summary>
        /// Returns ask for buy and bid for sell
        /// </summary>
        /// <param name="side">trade entry side</param>
        /// <returns></returns>
        public double PriceFromSide(TradeRecordSide side)
        {
            if (side == TradeRecordSide.Buy)
            {
                return(this.Ask);
            }
            else if (side == TradeRecordSide.Sell)
            {
                return(this.Bid);
            }

            var message = string.Format("Unknown side = {0}", side);

            throw new ArgumentException(message, nameof(side));
        }
Example #14
0
        public FxOrder ModifyOrder(string operationId, string orderId, string clientId, string symbol, TradeRecordType type, TradeRecordSide side,
                                        double volume, double? newActivationPrice, double? newStopLoss, double? newTakeProfit, DateTime? newExpiration, string newComment, int timeoutInMilliseconds)
        {
            if (operationId == null)
                operationId = string.Empty;

            if (newComment == null)
                newComment = string.Empty;

            this.VerifyInitialized();

            var order = new FxOrder(orderId, clientId, symbol, (int)type, side, newActivationPrice, volume, newStopLoss, newTakeProfit, newExpiration, newComment);

            return Native.TradeServer.ModifyOrder(this.handle, operationId, order, (uint)timeoutInMilliseconds);
        }
Example #15
0
        /// <summary>
        /// Returns bid for buy and ask for sell
        /// </summary>
        /// <param name="side">trade entry side</param>
        /// <returns></returns>
        public double PriceFromOppositeSide(TradeRecordSide side)
        {
            switch (side)
            {
            case TradeRecordSide.Buy:
                return(this.Bid);

            case TradeRecordSide.Sell:
                return(this.Ask);
            }

            var message = string.Format("Unknown side = {0}", side);

            throw new ArgumentException(message, nameof(side));
        }
Example #16
0
 public FxOrder(string symbol, int type, TradeRecordSide side, double volume, double?maxVisibleVolume, double?price, double?stopPrice, double?stopLoss, double?takeProfit, DateTime?expiration, string comment, string tag, int?magic)
     : this()
 {
     this.Symbol           = symbol;
     this.Type             = type;
     this.Side             = side;
     this.Volume           = volume;
     this.MaxVisibleVolume = maxVisibleVolume;
     this.Price            = price;
     this.StopPrice        = stopPrice;
     this.StopLoss         = stopLoss;
     this.TakeProfit       = takeProfit;
     this.Expiration       = expiration;
     this.Comment          = comment;
     this.Tag   = tag;
     this.Magic = magic;
 }
Example #17
0
        public void DeleteOrder(string operationId, string orderId, string clientId, TradeRecordSide side, int timeoutInMilliseconds)
        {
            if (operationId == null)
            {
                operationId = string.Empty;
            }
            if (orderId == null)
            {
                orderId = string.Empty;
            }
            if (clientId == null)
            {
                clientId = string.Empty;
            }

            this.VerifyInitialized();

            Native.TradeServer.DeleteOrder(this.handle, operationId, orderId, clientId, side, (uint)timeoutInMilliseconds);
        }
Example #18
0
        private bool SendIoCOrder()
        {
            bool            isError = false;
            string          opId    = Guid.NewGuid().GetHashCode().ToString("X");
            string          symbol  = _symbols[0];
            double          volume  = 100000;
            TradeRecordSide side    = TradeRecordSide.Buy;
            double          price   = TryGetOpenPrice(symbol, side, 10);

            try
            {
                TradeResults.Results.Add(opId, new OpenOrderResult());
                var tradeRecord = this.Trade.Server.SendOrderEx(opId, symbol, TradeCommand.IoC, side, price, volume, null, null, null, null);
                _positions.Add(tradeRecord.OrderId);
                TradeResults.Results[opId].Order = tradeRecord.OrderId;
                if (ShowDebug)
                {
                    Console.WriteLine("{0} SendIoCOrder(): {1} {2}", Username, TradeResults.Results[opId].SendingTime, opId);
                }
                return(true);
            }
            catch (Exception ex)
            {
                isError = true;
                if (ShowDebug)
                {
                    Console.WriteLine("{0} SendIoCThread() Exception: {1}", Username, ex.Message);
                }
            }
            finally
            {
                if (TradeResults.Results.ContainsKey(opId))
                {
                    if (isError)
                    {
                        TradeResults.Results.Remove(opId);
                    }
                }
            }
            return(false);
        }
Example #19
0
 public FxOrder(string id, string clientId, string symbol, int type, TradeRecordSide side, double?newVolume, double?newMaxVisibleVolume, double?newPrice, double?newStopPrice, double?stopLoss, double?takeProfit, DateTime?expiration, string comment, string tag, int?magic, double?prevVolume, bool?IOCOverride, bool?IFMOverride)
     : this()
 {
     this.OrderId          = id;
     this.ClientOrderId    = clientId;
     this.Symbol           = symbol;
     this.Type             = type;
     this.Side             = side;
     this.Volume           = newVolume;
     this.MaxVisibleVolume = newMaxVisibleVolume;
     this.Price            = newPrice;
     this.StopPrice        = newStopPrice;
     this.StopLoss         = stopLoss;
     this.TakeProfit       = takeProfit;
     this.Expiration       = expiration;
     this.Comment          = comment;
     this.Tag         = tag;
     this.Magic       = magic;
     this.IOCOverride = IOCOverride;
     this.IFMOverride = IFMOverride;
     this.PrevVolume  = prevVolume;
 }
Example #20
0
        private double TryGetOpenPrice(string symbol, TradeRecordSide side, int points = 0)
        {
            double price = 0;

            if (side == TradeRecordSide.Buy)
            {
                this.Feed.Cache.TryGetAsk(symbol, out price);
            }
            else
            {
                this.Feed.Cache.TryGetBid(symbol, out price);
            }

            if (points != 0)
            {
                var symbolInfo = this.Feed.Cache.Symbols.FirstOrDefault(s => s.Name == symbol);
                if (symbolInfo != null)
                {
                    price = price + Math.Pow(10, -symbolInfo.Precision) * points;
                }
            }

            return(price);
        }
Example #21
0
 /// <summary>
 /// The method deletes an existing pending order.
 /// </summary>
 /// <param name="operationId">
 /// Can be null, in this case FDK generates a new unique operation ID automatically.
 /// Otherwise, please use GenerateOperationId method of DataClient object.
 /// </param>
 /// <param name="orderId">An existing pending order ID.</param>
 /// <param name="side">Order side: buy or sell.</param>
 /// <param name="timeoutInMilliseconds">Timeout of the synchronous operation.</param>
 public void DeletePendingOrderEx(string operationId, string orderId, TradeRecordSide side, int timeoutInMilliseconds)
 {
     this.DeletePendingOrderEx(operationId, orderId, "Client-" + orderId, side, timeoutInMilliseconds);
 }
Example #22
0
        public FxOrder OpenNewOrder(string operationId, string symbol, TradeCommand command, TradeRecordSide side, double volume, double?maxVisibleVolume, double?price, double?stopPrice, double?stopLoss, double?takeProfit, DateTime?expiration, string comment, string tag, int?magic, int timeoutInMilliseconds)
        {
            if (operationId == null)
            {
                operationId = string.Empty;
            }

            this.VerifyInitialized();

            this.Validate(nameof(volume), volume);
            this.Validate(nameof(maxVisibleVolume), maxVisibleVolume);
            this.Validate(nameof(price), price);
            this.Validate(nameof(stopPrice), stopPrice);
            this.Validate(nameof(stopLoss), stopLoss);
            this.Validate(nameof(takeProfit), takeProfit);

            var order = new FxOrder(symbol, (int)command, side, volume, maxVisibleVolume, price, stopPrice, stopLoss, takeProfit, expiration, comment, tag, magic);

            return(Native.TradeServer.OpenNewOrder(this.handle, operationId, order, (uint)timeoutInMilliseconds));
        }
Example #23
0
 /// <summary>
 /// The method opens a new order.
 /// </summary>
 /// <param name="symbol">Trading currency pair symbol; can not be null.</param>
 /// <param name="command">Market, limit or stop.</param>
 /// <param name="side">Trade record side: buy or sell.</param>
 /// <param name="volume">Requsted volume.</param>
 /// <param name="maxVisibleVolume">Max visible volume.</param>
 /// <param name="price">Activating price for pending orders; price threshold for market orders.</param>
 /// <param name="stopPrice">Stop price.</param>
 /// <param name="stopLoss">Stop loss price.</param>
 /// <param name="takeProfit">Take profit price.</param>
 /// <param name="expiration">Expiration time, should be specified for pending orders.</param>
 /// <param name="comment">User defined comment for a new opening order. Null is interpreded as empty string.</param>
 /// <param name="tag">User defined tag for a new opening order. Null is interpreded as empty string.</param>
 /// <param name="magic">User defined magic number for a new opening order. Null is not defined.</param>
 /// <param name="timeoutInMilliseconds">Timeout of the synchronous operation.</param>
 /// <returns>A new trade record; can not be null.</returns>
 public TradeRecord SendOrderEx(string symbol, TradeCommand command, TradeRecordSide side, double volume, double? maxVisibleVolume, double? price, double? stopPrice, double? stopLoss, double? takeProfit, DateTime? expiration, string comment, string tag, int? magic, int timeoutInMilliseconds)
 {
     return this.SendOrderEx(null, symbol, command, side, volume, maxVisibleVolume, price, stopPrice, stopLoss, takeProfit, expiration, comment, tag, magic, timeoutInMilliseconds);
 }
Example #24
0
 /// <summary>
 /// The method modifies an existing trade record.
 /// </summary>
 /// <param name="operationId">
 /// Can be null, in this case FDK generates a new unique operation ID automatically.
 /// Otherwise, please use GenerateOperationId method of DataClient object.
 /// </param>
 /// <param name="orderId">An existing pending order ID.</param>
 /// <param name="symbol">Currency pair.</param>
 /// <param name="type">Order type: Limit or Stop.</param>
 /// <param name="side">Order side: buy or sell.</param>
 /// <param name="newVolume">A new volume of pending order.</param>
 /// <param name="newMaxVisibleVolume">A new max visible volume of pending order.</param>
 /// <param name="newPrice">A new price of pending order.</param>
 /// <param name="newStopPrice">A new stop price of pending order.</param>
 /// <param name="newStopLoss">A new stop loss price of pending order.</param>
 /// <param name="newTakeProfit">A new take profit price of pending order.</param>
 /// <param name="newExpiration">A new expiration time.</param>
 /// <param name="newComment">A new comment.</param>
 /// <param name="newTag">A new tag.</param>
 /// <param name="newMagic">A new magic.</param>
 /// <param name="prevVoume">Previous amount to check on server if threre was no amount modification during request.
 /// If PrevAmount is provided and server Amount is different modify operation will rejected</param>
 /// <param name="IOCOverride">'Immediate-Or-Cancel' flag override.</param>
 /// <param name="IFMOverride">'In-Flight-Mitigation' flag override.</param>
 /// <param name="timeoutInMilliseconds">Timeout of the synchronous operation.</param>
 /// <returns>A modified trade record.</returns>
 public TradeRecord ModifyTradeRecordEx(
     string operationId, string orderId, string clientId, string symbol, TradeRecordType type, TradeRecordSide side,
     double? newVolume, double? newMaxVisibleVolume,
     double? newPrice, double? newStopPrice,
     double? newStopLoss, double? newTakeProfit,
     DateTime? newExpiration,
     string newComment,
     string newTag,
     int? newMagic,
     double? prevVolume,
     bool? IOCOverride,
     bool? IFMOverride,
     int timeoutInMilliseconds)
 {
     var order = this.Client.DataTradeHandle.ModifyOrder(operationId, orderId, clientId, symbol, type, side, newVolume, newMaxVisibleVolume, newPrice, newStopPrice, newStopLoss, newTakeProfit, newExpiration, newComment, newTag, newMagic, prevVolume, IOCOverride, IFMOverride, timeoutInMilliseconds);
     return new TradeRecord(this.Client, order);
 }
Example #25
0
        private double TryGetOpenPrice(string symbol, TradeRecordSide side, int points = 0)
        {
            double price = 0;
            if (side == TradeRecordSide.Buy)
                this.Feed.Cache.TryGetAsk(symbol, out price);
            else
                this.Feed.Cache.TryGetBid(symbol, out price);

            if (points != 0)
            {
                var symbolInfo = this.Feed.Cache.Symbols.FirstOrDefault(s => s.Name == symbol);
                if (symbolInfo != null)
                    price = price + Math.Pow(10, -symbolInfo.Precision) * points;
            }

            return price;
        }
Example #26
0
 /// <summary>
 /// The method deletes an existing pending order.
 /// </summary>
 /// <param name="operationId">
 /// Can be null, in this case FDK generates a new unique operation ID automatically.
 /// Otherwise, please use GenerateOperationId method of DataClient object.
 /// </param>
 /// <param name="orderId">An existing pending order ID.</param>
 /// <param name="side">Order side: buy or sell.</param>
 /// <param name="timeoutInMilliseconds">Timeout of the synchronous operation.</param>
 void DeletePendingOrderEx(string operationId, string orderId, string clientId, TradeRecordSide side, int timeoutInMilliseconds)
 {
     this.Client.DataTradeHandle.DeleteOrder(operationId, orderId, clientId, side, timeoutInMilliseconds);
 }
Example #27
0
 /// <summary>
 /// The method opens a new order.
 /// </summary>
 /// <param name="operationId">
 /// Can be null, in this case FDK generates a new unique operation ID automatically.
 /// Otherwise, please use GenerateOperationId method of DataClient object.
 /// </param>
 /// <param name="symbol">Trading currency pair symbol; can not be null.</param>
 /// <param name="command">Market, limit or stop.</param>
 /// <param name="side">Trade record side: buy or sell.</param>
 /// <param name="volume">Requsted volume.</param>
 /// <param name="maxVisibleVolume">Max visible volume.</param>
 /// <param name="price">Activating price for pending orders; price threshold for market orders.</param>
 /// <param name="stopPrice">Stop price.</param>
 /// <param name="stopLoss">Stop loss price.</param>
 /// <param name="takeProfit">Take profit price.</param>
 /// <param name="expiration">Expiration time, should be specified for pending orders.</param>
 /// <param name="comment">User defined comment for a new opening order. Null is interpreded as empty string.</param>
 /// <param name="tag">User defined tag for a new opening order. Null is interpreded as empty string.</param>
 /// <param name="magic">User defined magic number for a new opening order. Null is not defined.</param>
 /// <returns>A new trade record; can not be null.</returns>
 public TradeRecord SendOrderEx(string operationId, string symbol, TradeCommand command, TradeRecordSide side, double volume, double? maxVisibleVolume, double? price, double? stopPrice, double? stopLoss, double? takeProfit, DateTime? expiration, string comment, string tag, int? magic)
 {
     return this.SendOrderEx(operationId, symbol, command, side, volume, maxVisibleVolume, price, stopPrice, stopLoss, takeProfit, expiration, comment, tag, magic, this.Client.SynchOperationTimeout);
 }
Example #28
0
 /// <summary>
 /// The method deletes an existing pending order.
 /// </summary>
 /// <param name="operationId">
 /// Can be null, in this case FDK generates a new unique operation ID automatically.
 /// Otherwise, please use GenerateOperationId method of DataClient object.
 /// </param>
 /// <param name="orderId">An existing pending order ID.</param>
 /// <param name="side">Order side: buy or sell.</param>
 public void DeletePendingOrderEx(string operationId, string orderId, TradeRecordSide side)
 {
     this.DeletePendingOrderEx(operationId, orderId, "Client-" + orderId, side, this.Client.SynchOperationTimeout);
 }
Example #29
0
        /// <summary>
        /// The method opens a new order.
        /// </summary>
        /// <param name="operationId">
        /// Can be null, in this case FDK generates a new unique operation ID automatically.
        /// Otherwise, please use GenerateOperationId method of DataClient object.
        /// </param>
        /// <param name="symbol">Trading currency pair symbol; can not be null.</param>
        /// <param name="command">Market, limit or stop.</param>
        /// <param name="side">Trade record side: buy or sell.</param>
        /// <param name="volume">Requsted volume.</param>
        /// <param name="maxVisibleVolume">Max visible volume.</param>
        /// <param name="price">Activating price for pending orders; price threshold for market orders.</param>
        /// <param name="stopPrice">Stop price.</param>
        /// <param name="stopLoss">Stop loss price.</param>
        /// <param name="takeProfit">Take profit price.</param>
        /// <param name="expiration">Expiration time, should be specified for pending orders.</param>
        /// <param name="comment">User defined comment for a new opening order. Null is interpreded as empty string.</param>
        /// <param name="tag">User defined tag for a new opening order. Null is interpreded as empty string.</param>
        /// <param name="magic">User defined magic number for a new opening order. Null is not defined.</param>
        /// <param name="timeoutInMilliseconds">Timeout of the synchronous operation.</param>
        /// <returns>A new trade record; can not be null.</returns>
        TradeRecord SendOrderEx(string operationId, string symbol, TradeCommand command, TradeRecordSide side, double volume, double? maxVisibleVolume, double? price, double? stopPrice, double? stopLoss, double? takeProfit, DateTime? expiration, string comment, string tag, int? magic, int timeoutInMilliseconds)
        {
#if LOG_PERFORMANCE
            ulong timestamp = Client.loggerIn_.GetTimestamp();
#endif
            var order = this.Client.DataTradeHandle.OpenNewOrder(operationId, symbol, command, side, volume, maxVisibleVolume, price, stopPrice, stopLoss, takeProfit, expiration, comment ?? string.Empty, tag ?? string.Empty, magic, timeoutInMilliseconds);
            TradeRecord tradeRecord = new TradeRecord(this.Client, order);

#if LOG_PERFORMANCE
            Client.loggerIn_.LogTimestamp(tradeRecord.ClientOrderId, timestamp, "NewOrder");
#endif
            return tradeRecord;
        }
Example #30
0
 static void ConvertCmdToCommandAndSide(int cmd, out TradeCommand command, out TradeRecordSide side)
 {
     if (cmd == OP_BUY)
     {
         command = TradeCommand.Market;
         side = TradeRecordSide.Buy;
     }
     else if (cmd == OP_SELL)
     {
         command = TradeCommand.Market;
         side = TradeRecordSide.Sell;
     }
     else if (cmd == OP_BUYLIMIT)
     {
         command = TradeCommand.Limit;
         side = TradeRecordSide.Buy;
     }
     else if (cmd == OP_SELLLIMIT)
     {
         command = TradeCommand.Limit;
         side = TradeRecordSide.Sell;
     }
     else if (cmd == OP_BUYSTOP)
     {
         command = TradeCommand.Stop;
         side = TradeRecordSide.Buy;
     }
     else if (cmd == OP_SELLSTOP)
     {
         command = TradeCommand.Stop;
         side = TradeRecordSide.Sell;
     }
     else
         throw new ArgumentOutOfRangeException("cmd", cmd, "Expected: OP_BUY, OP_SELL, OP_BUYLIMIT, OP_SELLLIMIT, OP_BUYSTOP or OP_SELLSTOP");
 }