Пример #1
0
 /// <summary>
 /// Update a trade *(for adding a stop/limit etc)*.
 /// </summary>
 /// <param name="update">The update trade request.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginUpdateTrade(UpdateTradeOrderRequestDTO update, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/updatetradeorder";
     _client.BeginRequest(RequestMethod.POST, "order", uriTemplate , 
     new Dictionary<string, object>
     {
         { "update", update}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,0 ,callback, state);
 }
Пример #2
0
        // ***********************************
        // UpdateTrade
        // ***********************************


        /// <summary>
        /// Update a trade *(for adding a stop/limit etc)*.
        /// </summary>
        /// <param name="update">The update trade request.</param>
        public virtual ApiTradeOrderResponseDTO UpdateTrade(UpdateTradeOrderRequestDTO update)
        {
            string uriTemplate = "/updatetradeorder";
            return _client.Request<ApiTradeOrderResponseDTO>(RequestMethod.POST,"order", uriTemplate ,
            new Dictionary<string, object>
            {
                { "update", update}
            },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0),30000,0 );
        }
Пример #3
0
 /// <summary>
 /// Update a trade (for adding a stop/limit etc). Post an <a onclick="dojo.hash('#type.UpdateTradeOrderRequestDTO'); return false;" class="json-link" href="#">UpdateTradeOrderRequestDTO</a> to the uri specified below</p>
 /// </summary>
 /// <param name="update">The trade request</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public void BeginUpdateTrade(UpdateTradeOrderRequestDTO update, ApiAsyncCallback<ApiTradeOrderResponseDTO> callback, object state)
 {
     BeginRequest(callback, state, "order", "/updatetradeorder", "POST",
     new Dictionary<string, object>
     {
         { "update", update}
     }, TimeSpan.FromMilliseconds(0), "trading");
 }
Пример #4
0
 // ***********************************
 // UpdateTrade
 // ***********************************
 /// <summary>
 /// Update a trade (for adding a stop/limit etc). Post an <a onclick="dojo.hash('#type.UpdateTradeOrderRequestDTO'); return false;" class="json-link" href="#">UpdateTradeOrderRequestDTO</a> to the uri specified below</p>
 /// </summary>
 /// <param name="update">The trade request</param>
 public ApiTradeOrderResponseDTO UpdateTrade(UpdateTradeOrderRequestDTO update)
 {
     return Request<ApiTradeOrderResponseDTO>("order", "/updatetradeorder", "POST",
     new Dictionary<string, object>
     {
         { "update", update}
     }, TimeSpan.FromMilliseconds(0), "trading");
 }
Пример #5
0
        public void CanUpdateTrade()
        {
            var rpcClient = BuildRpcClient();

            AccountInformationResponseDTO accounts = rpcClient.AccountInformation.GetClientAndTradingAccount();

            PriceDTO marketInfo = GetMarketInfo(_CFDmarketId);

            var trade = new NewTradeOrderRequestDTO()
            {
                AuditId = marketInfo.AuditId,
                AutoRollover = false,
                BidPrice = marketInfo.Bid,
                Close = null,
                Currency = null,
                Direction = "buy",
                IfDone = null,
                MarketId = marketInfo.MarketId,
                OfferPrice = marketInfo.Offer,
                Quantity = 1,
                QuoteId = null,
                TradingAccountId = accounts.CFDAccount.TradingAccountId
            };
            var order = rpcClient.TradesAndOrders.Trade(trade);
            rpcClient.MagicNumberResolver.ResolveMagicNumbers(order);

            Assert.AreEqual("Accepted", order.Status_Resolved);

            var update = new UpdateTradeOrderRequestDTO
            {
                OrderId = order.OrderId,
                MarketId = trade.MarketId,
                Currency = trade.Currency,
                IfDone = new[] 
                        { 
                            new ApiIfDoneDTO 
                                { 
                                    Stop = new ApiStopLimitOrderDTO
                                        {
                                            TriggerPrice = marketInfo.Offer+10,
                                            Direction = "sell",
                                            IfDone = null,
                                            MarketId = marketInfo.MarketId,
                                            Quantity = 1,
                                            TradingAccountId = accounts.CFDAccount.TradingAccountId    
                                        }
                                }
                        },
                AuditId = trade.AuditId,
                AutoRollover = trade.AutoRollover,
                BidPrice = trade.BidPrice,
                Close = trade.Close,
                Direction = trade.Direction,
                OfferPrice = trade.OfferPrice,
                Quantity = trade.Quantity,
                QuoteId = trade.QuoteId,
                TradingAccountId = trade.TradingAccountId
            };

            var response = rpcClient.TradesAndOrders.UpdateTrade(update);
        }