Jump to content
Sign in to follow this  
rob sinclair

How do I add a stop or limit order to a trade using CIAPI.Rpc.Client.TradesAndOrders.UpdateOrder?

Recommended Posts

To attach a stop/limit to an existing order or trade, you need to call UpdateOrder() and populate the IfDone property. Create a ApiIfDoneDTO, with a ApiStopLimitOrderDTO for the stop/limit (this should have the current bid/offer and the trigger price for your intended stop/limit), then create an array of ApiIfDoneDTO[] with 1 element.

Well spotted, TradingAccountId should be an int.

Share this post

Link to post
Guest andreif

I’m trying to do it like this:

  const int orderId = 472307456;
        var order = _client.TradesAndOrders.GetActiveStopLimitOrder(orderId.ToString()).ActiveStopLimitOrder;

        var request = new UpdateStopLimitOrderRequestDTO
            OrderId = orderId,
            TradingAccountId = (int)order.TradingAccountId,
            Direction = order.Direction,
            MarketId = order.MarketId,
            Quantity = order.Quantity,
            OfferPrice = order.TriggerPrice * 0.9M,
            TriggerPrice = order.TriggerPrice,
            BidPrice = order.TriggerPrice * 1.1M,
        var resp = _client.TradesAndOrders.UpdateOrder(request);

        var order2 = _client.TradesAndOrders.GetActiveStopLimitOrder(orderId.ToString()).ActiveStopLimitOrder;

UpdateOrder() returns status “OK”, but no stop/limit is created (order2 variable is the same as order). Anyone knows why?

PS ApiActiveStopLimitOrderDTO.TradingAccountId is decimal, probably it should be int instead

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this