예제 #1
0
        public static OrderTypes ToOrderTypes(TradeRecordType type)
        {
            switch (type)
            {
            case TradeRecordType.Market:
                return(OrderTypes.Market);

            case TradeRecordType.Position:
                return(OrderTypes.Position);

            case TradeRecordType.Limit:
                return(OrderTypes.Limit);

            case TradeRecordType.Stop:
                return(OrderTypes.Stop);

            case TradeRecordType.IoC:
                return(OrderTypes.Limit);

            case TradeRecordType.MarketWithSlippage:
                return(OrderTypes.Limit);

            case TradeRecordType.StopLimit:
                return(OrderTypes.StopLimit);

            case TradeRecordType.StopLimit_IoC:
                return(OrderTypes.StopLimit);
            }

            throw new ArgumentException("type");
        }
예제 #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));
        }
예제 #3
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);
 }
예제 #4
0
파일: TradeEntry.cs 프로젝트: hombrevrc/FDK
 /// <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;
 }
예제 #5
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);
 }
예제 #6
0
파일: FxDataTrade.cs 프로젝트: ifzz/FDK
        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);
        }
예제 #7
0
        public static OrderTypes ToOrderTypes(TradeRecordType type)
        {
            switch (type)
            {
                case TradeRecordType.Market:
                    return OrderTypes.Market;
                case TradeRecordType.Position:
                    return OrderTypes.Position;
                case TradeRecordType.Limit:
                    return OrderTypes.Limit;
                case TradeRecordType.Stop:
                    return OrderTypes.Stop;
            }

            throw new ArgumentException("type");
        }
예제 #8
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);
 }
예제 #9
0
파일: TradeData.cs 프로젝트: hombrevrc/FDK
        static TradeType TradeTypeFromTradeRecordType(TradeRecordType type)
        {
            if (type == TradeRecordType.Position)
            {
                return(TradeType.Position);
            }
            if (type == TradeRecordType.Limit)
            {
                return(TradeType.Limit);
            }
            if (type == TradeRecordType.Stop)
            {
                return(TradeType.Stop);
            }
            if (type == TradeRecordType.StopLimit)
            {
                return(TradeType.StopLimit);
            }

            var message = string.Format("Unsupported trade record type = {0}", type);

            throw new ArgumentException(message, nameof(type));
        }
예제 #10
0
파일: TradeData.cs 프로젝트: ifzz/FDK
        static TradeType TradeTypeFromTradeRecordType(TradeRecordType type)
        {
            if (type == TradeRecordType.Position)
            {
                return TradeType.Position;
            }
            if (type == TradeRecordType.Limit)
            {
                return TradeType.Limit;
            }
            if (type == TradeRecordType.Stop)
            {
                return TradeType.Stop;
            }

            var message = string.Format("Unsupported trade record type = {0}", type);
            throw new ArgumentException(message, nameof(type));
        }