Click or drag to resize

Create new stop order

To create a new stop order, you need to create an Order, object that contains information about the order and register it on the exchange.

Unlike a regular order, for a stop order, you need to specify the OrderType property as Conditional and set the OrderCondition property with the necessary order conditions.

Further, if you need to work with the order (for example, cancel it or change it), then this Order. object shall be used. To register orders on the exchange, the RegisterOrder(Order) method is provided, which sends an order to the server.

C#
Connector Connector = new Connector();        
...   
private void StopOrder_Click(object sender, RoutedEventArgs e)
{
    var order = new Order
    {
        Security = SecurityEditor.SelectedSecurity,
        Portfolio = PortfolioEditor.SelectedPortfolio,
        Price = decimal.Parse(TextBoxPrice.Text),
        Volume = decimal.Parse(TextBoxVolumePrice.Text),
        Direction = Sides.Buy,
        Type = OrderTypes.Conditional,
        Condition = new FixOrderCondition()
        {
            Type = FixOrderConditionTypes.StopLimit,
            StopLimitPrice = decimal.Parse(TextBoxStopLimitPrice.Text),
        }
    };

    Connector.RegisterOrder(order);
}

...

Each connection has its own implementation of the OrderCondition class, since each connection has its own unique features. For example, for Kucoin it is KucoinOrderCondition, etc.

See Also