Skip to main content Skip to footer

TradeManagerClass - class that manages all things concerning to trading for selected instrument and account.
All methods of the class can be splitted on several groups:

1. Checking Quantity/Position. Methods of the group allow to get an information about summary opened positions, direction of trading, max and min quantity available for the instrument. Methods of the group are:

  • GetPotentialMarketPosition - summarizes current opened lots with current not filled market orders.If result>0, then position will be Long. If result less than 0,then position will be short;
  • GetPotentialNettingPositionQuantity - has the same meaning as GetPotentialMarketPosition function, but returns SignedQuantity structure;
  • IsMarketPositionFlatAndNoMarketOrders - checks whether current position is flat and no working market orders which may change the position state;
  • NormalizeQuantity - checks if quantity is larger than minimal possible quantity and is aligned to minimal possible quantity. If rounding is necessary it always rounds to higher value;
  • GetQuantityStep - gets quantity step for the instrument;
  • GetMinQuantity - gets min available quantity for the instrument;
  • GetMaxQuantity -gets max available quantity for the instrument;

2. Change/Cancel orders. This group is to make changes in active or pending orders or to cancel them. Methods of the group are:

  • CancelOrder - cancels a specified order;
  • CancelOrders - cancels all specified orders;
  • CancelAllPendingOrders - cancels all working, submitted, accepted and part-filled orders (shortly, pending orders);
  • ChangeOrder - sends new parameters of a specified Order to the broker;

3. Submit orders. This group is to submit orders for trading. Methods of the group are:

  • CreateOrderSubmissionParameters - creates order submission parameters but does not send the order;
  • SubmitOrders - sends multiple orders to broker;
  • SubmitOrder - submits order good-till-date order with specified parameters;
  • IsOrderSubmissionAvailable - checks if the strategy has no limitations to proceed this order;

4. Buy orders/Sell orders. This group is to open long/short positions. Methods of the group are:

  • BuyByMarket - generates a buy market order to enter a long position;
  • SellByMarket - generates a sell short market order to enter a short position;
  • SubmitMarketOrder - generates a buy or sell market order to enter a long/short position;
  • BuyStopLimit - generates a buy stop limit order to enter a long position;
  • SellStopLimit - generates a sell short stop limit order to enter a short position;
  • SubmitStopMarketOrder - submits a buy/sell stop market order to enter a long/short position.
  • BuyStopMarket - generates a buy stop market order to enter a short position;
  • SellStopMarket - generates a sell short stop order to enter a short position;
  • SubmitLimitOrder - submits a buy/sell limit order to enter a long/short position;
  • BuyLimit - generates a buy limit order to enter a long position;
  • SellLimit - generates a sell short stop limit order to enter a short position;

5. Exit orders. This group is to close long/short positions. Methods of the group are:

  • ExitPosition - exits specified position;
  • ExitPositions - exits specified positions;
  • ExitLong - generates a sell market order(s) to exit a long position(s). For netting accounts: if netting positions is short or flat, the method does nothing. For hedging positions: the method closes each long position. Only positions of the current instrument and strategy are considered;
  • ExitLongLimit - generates a sell limit order to exit a long position. This method supports netting accounts only. Only positions of the current instrument and strategy are considered;
  • ExitLongStopLimit - generates a sell stop limit order to exit a long position. This method supports netting accounts only. Only positions of the current instrument and strategy are considered;
  • ExitShort - generates a buy to cover market order to exit a short position. For netting accounts: if netting position is long or flat, the method does nothing. For hedging positions: the method closes each short position. Only positions of the current instrument and strategy are considered;
  • ExitShortStopLimit - generates a buy to cover stop limit order to exit a short position. This method supports netting accounts only. Only positions of the current instrument and strategy are considered;
  • Exit - generates an order(s) to exit current position(s). For netting accounts: generates only one order (short or long) to flatten current netting position. If current netting position is already flat, then return empty list. For hedging positions: the method closes each position. Only positions of the current instrument and strategy are considered;

6. StopLoss/TakeProfit. This group is to set Stop Loss/ Take Profit orders. Methods/properties of the group are:

  • IsStopLossTakeProfitAvailable - returns true if broker supports built-in stop loss and take profit in position;
  • ModifyPosition - changes current stop loss (stop order) and take profit (limit order) for specified position. Broker must support this feature, i.e. IsStopLossTakeProfitAvailable must be True;
  • TrailStopLoss - checks if current stop loss can be moved ahead to keep distance  from current price;
  • CheckBreakEven - checks if current position is set to break-even. If it is not, then it will set;

Cookies Notice

We use cookies to improve your experience, personalize content, and analyze our traffic. By clicking "Accept All Cookies," you agree to the storing of cookies on your device. You can manage your cookie preferences at any time by visiting our Cookie Settings.