Trading operations
Placing a different type of orders, modifying and canceling them using Quantower API
Last updated
Was this helpful?
Placing a different type of orders, modifying and canceling them using Quantower API
Last updated
Was this helpful?
A key part of each strategy is a trading algorithm it implements. In most cases it requires possibilities of placing a different type of orders, modifying and canceling them. In this topic, we will show you how to get access to this operations via .
As we wrote in the previous topic, class is the main entry point for all major functions and placing orders (as well as all other trading operations) are not the exception. The most flexible way of placing orders is using the method, that accepts object as input parameter. This object provides you with more than 15 parameters and using them you can customize your order request according to your needs. It is not necessary to fill all, usually, you will need only main, such as:
Parameter
Description
Account
An account for order
Symbol
A symbol for order
Side
Side of order: Buy or Sell
Price
Price for Limit or Stop Limit order
TriggerPrice
Trigger price for Stop or Stop Limit Order
Quantity
Amount of the order (in lots)
StopLoss
An instance of SlTpHolder object, where you can specify price or offset for Stop Loss order
TakeProfit
An instance of SlTpHolder object, where you can specify price or offset for Take Profit order
OrderTypeID
An ID of required order type. For most cases you will need only basic types, so you can use predefined constants: OrderType.Limit, OrderType.Stop, OrderType.Market and OrderType.StopLimit
And code example of using this method:
Another option to send order request is using the overloaded method, which accepts only basic order parameters. The shortest form will send Short or Long 1 lot position using a specified symbol and account:
You can also add other parameters, for example if you want to place a Limit order just need to specify Price:
Or Trigger price for Stop order:
If you need to change the price of the order:
Or, if you want, you can request changing all parameters simultaneously: quantity, time in force, price:
You can use also Cancel method of Order class as an alternative way:
Or method Close from Position class:
All trading operations return special object TradingOperationResult which contains information about the result of the processing request:
Parameter
Description
Status
Success if a request was sent to server or Failure if some problems occurred
Message
Text with detail information in case of errors
Using these set of trading functions you can simply create any algorithm for your trading strategy. In our further articles, we will cover more specific and practical cases, such as specifying parameters for advanced order types and creating universal trading logic, for different connections.
Once you created your order you can modify its parameters - use function in Core class for this. You can specify only parameter you want to change, for example, if you want to change Quantity of order:
As expected there is a function for canceling Order - . All you need to specify is Order object:
The closing of positions is very similar to canceling orders. Use method from :