• C#
  • Java
  • VB
  • C++
  • Python
Contact us
IB Algorithms

Adaptive Algo

The Adaptive Algo combines IB's Smartrouting capabilities with user-defined priority settings in an effort to achieve further cost efficiency at the point of execution. Using the Adaptive algo leads to better execution prices on average than for regular limit or market orders.

ParameterDescriptionValues
adaptivePriority The 'Priority' selector determines the time taken to scan for better execution prices. The 'Urgent' setting scans only briefly, while the 'Patient' scan works more slowly and has a higher chance of achieving a better overall fill for your order. Urgent > Normal > Patient


  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillAdaptiveParams(baseOrder, "Normal");
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillAdaptiveParams(Order baseOrder, string priority)
    {
    baseOrder.AlgoStrategy = "Adaptive";
    baseOrder.AlgoParams = new List<TagValue>();
    baseOrder.AlgoParams.Add(new TagValue("adaptivePriority", priority));
    }
  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillAdaptiveParams(baseOrder, "Normal");
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillAdaptiveParams(Order baseOrder, String priority) {
    baseOrder.algoStrategy("Adaptive");
    baseOrder.algoParams(new ArrayList<>());
    baseOrder.algoParams().add(new TagValue("adaptivePriority", priority));
    }
  • Dim baseOrder As Order = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    AvailableAlgoParams.FillAdaptiveParams(baseOrder, "Normal")
    client.placeOrder(increment(nextOrderId), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    Public Shared Sub FillAdaptiveParams(baseOrder As Order, priority As String)
    baseOrder.AlgoStrategy = "Adaptive"
    baseOrder.AlgoParams = New List(Of TagValue)
    baseOrder.AlgoParams.Add(New TagValue("adaptivePriority", priority))
    End Sub
  • Order baseOrder = OrderSamples::LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams::FillAdaptiveParams(baseOrder, "Normal");
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStockAtSmart(), baseOrder);
    ...
    void AvailableAlgoParams::FillAdaptiveParams(Order& baseOrder, std::string priority){
    baseOrder.algoStrategy = "Adaptive";
    baseOrder.algoParams.reset(new TagValueList());
    TagValueSPtr tag1(new TagValue("adaptivePriority", priority));
    baseOrder.algoParams->push_back(tag1);
    }
  • 1  baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    1  AvailableAlgoParams.FillAdaptiveParams(baseOrder, "Normal")
    2  self.placeOrder(self.nextOrderId(), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    1  @staticmethod
    2  def FillAdaptiveParams(baseOrder: Order, priority: str):
    3  baseOrder.algoStrategy = "Adaptive"
    4  baseOrder.algoParams = []
    5  baseOrder.algoParams.append(TagValue("adaptivePriority", priority))
    6 


Note: The Time Zone in "startTime" and "endTime" attributes is only applied when the format "hh:mm:ss TMZ" is used

ArrivalPrice

The Arrival Price algorithmic order type will attempt to achieve, over the course of the order, the bid/ask midpoint at the time the order is submitted. The Arrival Price algo is designed to keep hidden orders that will impact a high percentage of the average daily volume (ADV). The pace of execution is determined by the user-assigned level of risk aversion and the user-defined target percent of average daily volume. How quickly the order is submitted during the day is determined by the level of urgency: the higher the urgency the faster it will execute but will expose it to a greater market impact. Market impact can be lessened by assigning lesser urgency, which is likely to lengthen the duration of the order. The user can set the max percent of ADV from 1 to 50%. The order entry screen allows the user to determine when the order will start and end regardless of whether or not the full amount of the order has been filled. By checking the box marked Allow trading past end time the algo will continue to work past the specified end time in an effort to fill the remaining portion of the order.

ParameterDescriptionValues
maxPctVolMaximum percentage of ADV0.1 (10%) - 0.5 (50%)
riskAversionUrgency/risk aversionGet Done, Aggressive, Neutral, Passive
startTimeAlgorithm starting timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
endTimeAlgorithm ending timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
allowPastEndTimeAllow trading past end time1 (true) or 0 (false)
forceCompletionAttempt completion by the end of the day1 (true) or 0 (false)
monetaryValueCash Quantity


  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillArrivalPriceParams(baseOrder, 0.1, "Aggressive", "09:00:00 CET", "16:00:00 CET", true, true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillArrivalPriceParams(Order baseOrder, double maxPctVol, string riskAversion, string startTime, string endTime,
    bool forceCompletion, bool allowPastTime, double monetaryValue)
    {
    baseOrder.AlgoStrategy = "ArrivalPx";
    baseOrder.AlgoParams = new List<TagValue>();
    baseOrder.AlgoParams.Add(new TagValue("maxPctVol", maxPctVol.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("riskAversion", riskAversion));
    baseOrder.AlgoParams.Add(new TagValue("startTime", startTime));
    baseOrder.AlgoParams.Add(new TagValue("endTime", endTime));
    baseOrder.AlgoParams.Add(new TagValue("forceCompletion", forceCompletion ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("allowPastEndTime", allowPastTime ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("monetaryValue", monetaryValue.ToString()));
    }
  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillArrivalPriceParams(baseOrder, 0.1, "Aggressive", "09:00:00 CET", "16:00:00 CET", true, true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillArrivalPriceParams(Order baseOrder, double maxPctVol, String riskAversion, String startTime,
    String endTime, boolean forceCompletion, boolean allowPastTime, double monetaryValue) {
    baseOrder.algoStrategy("ArrivalPx");
    baseOrder.algoParams(new ArrayList<>());
    baseOrder.algoParams().add(new TagValue("maxPctVol", String.valueOf(maxPctVol)));
    baseOrder.algoParams().add(new TagValue("riskAversion", riskAversion));
    baseOrder.algoParams().add(new TagValue("startTime", startTime));
    baseOrder.algoParams().add(new TagValue("endTime", endTime));
    baseOrder.algoParams().add(new TagValue("forceCompletion", forceCompletion ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("allowPastEndTime", allowPastTime ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("monetaryValue", String.valueOf(monetaryValue)));
    }
  • Dim baseOrder As Order = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    AvailableAlgoParams.FillArrivalPriceParams(baseOrder, 0.10000000000000001, "Aggressive", "09:00:00 CET", "16:00:00 CET", True, True, 100000)
    client.placeOrder(increment(nextOrderId), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    Public Shared Sub FillArrivalPriceParams(baseOrder As Order, maxPctVol As Double, riskAversion As String, startTime As String, endTime As String,
    forceCompletion As Boolean, allowPastTime As Boolean, monetaryValue As Double)
    baseOrder.AlgoStrategy = "ArrivalPx"
    baseOrder.AlgoParams = New List(Of TagValue)
    baseOrder.AlgoParams.Add(New TagValue("maxPctVol", maxPctVol.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("riskAversion", riskAversion))
    baseOrder.AlgoParams.Add(New TagValue("startTime", startTime))
    baseOrder.AlgoParams.Add(New TagValue("endTime", endTime))
    baseOrder.AlgoParams.Add(New TagValue("forceCompletion", BooleantoString(forceCompletion)))
    baseOrder.AlgoParams.Add(New TagValue("allowPastEndTime", BooleantoString(allowPastTime)))
    baseOrder.AlgoParams.Add(New TagValue("monetaryValue", monetaryValue.ToString()))
    End Sub
  • Order baseOrder = OrderSamples::LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams::FillArrivalPriceParams(baseOrder, 0.1, "Aggressive", "09:00:00 CET", "16:00:00 CET", true, true, 100000);
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStockAtSmart(), baseOrder);
    ...
    void AvailableAlgoParams::FillArrivalPriceParams(Order& baseOrder, double maxPctVol, std::string riskAversion, std::string startTime, std::string endTime,
    bool forceCompletion, bool allowPastTime, double monetaryValue){
    baseOrder.algoStrategy = "ArrivalPx";
    baseOrder.algoParams.reset(new TagValueList());
    TagValueSPtr tag1(new TagValue("maxPctVol", std::to_string(maxPctVol)));
    TagValueSPtr tag2(new TagValue("riskAversion", riskAversion));
    TagValueSPtr tag3(new TagValue("startTime", startTime));
    TagValueSPtr tag4(new TagValue("endTime", endTime));
    TagValueSPtr tag5(new TagValue("forceCompletion", forceCompletion ? "1" : "0"));
    TagValueSPtr tag6(new TagValue("allowPastEndTime", allowPastTime ? "1" : "0"));
    TagValueSPtr tag7(new TagValue("monetaryValue", std::to_string(monetaryValue)));
    baseOrder.algoParams->push_back(tag1);
    baseOrder.algoParams->push_back(tag2);
    baseOrder.algoParams->push_back(tag3);
    baseOrder.algoParams->push_back(tag4);
    baseOrder.algoParams->push_back(tag5);
    baseOrder.algoParams->push_back(tag6);
    baseOrder.algoParams->push_back(tag7);
    }
  • 1  baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    1  AvailableAlgoParams.FillArrivalPriceParams(baseOrder, 0.1, "Aggressive", "09:00:00 CET", "16:00:00 CET", True, True, 100000)
    2  self.placeOrder(self.nextOrderId(), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    1  @staticmethod
    2  def FillArrivalPriceParams(baseOrder: Order, maxPctVol: float,
    3  riskAversion: str, startTime: str, endTime: str,
    4  forceCompletion: bool, allowPastTime: bool,
    5  monetaryValue: float):
    6  baseOrder.algoStrategy = "ArrivalPx"
    7  baseOrder.algoParams = []
    8  baseOrder.algoParams.append(TagValue("maxPctVol", maxPctVol))
    9  baseOrder.algoParams.append(TagValue("riskAversion", riskAversion))
    10  baseOrder.algoParams.append(TagValue("startTime", startTime))
    11  baseOrder.algoParams.append(TagValue("endTime", endTime))
    12  baseOrder.algoParams.append(TagValue("forceCompletion",
    13  int(forceCompletion)))
    14  baseOrder.algoParams.append(TagValue("allowPastEndTime",
    15  int(allowPastTime)))
    16  baseOrder.algoParams.append(TagValue("monetaryValue", monetaryValue))
    17 

Close Price

Investors submitting market or limit orders into the closing auction may adversely affect the closing price, especially when the size of the order is large relative to the average close auction volume. In order to help investors attempting to execute towards the end of the trading session we have developed the Close Price algo Strategy. This algo breaks down large order amounts and determines the timing of order entry so that it will continuously execute in order to minimize slippage. The start and pace of execution are determined by the user who assigns a level of market risk and specifies the target percentage of volume, while the algo considers the prior volatility of the stock.

ParameterDescriptionValues
maxPctVolMaximum percentage of ADV0.1 (10%) - 0.5 (50%)
riskAversionUrgency/risk aversionGet Done, Aggressive, Neutral, Passive
startTimeAlgorithm starting timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
forceCompletionAttempt completion by the end of the day1 (true) or 0 (false)
monetaryValueCash Quantity


  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillClosePriceParams(baseOrder, 0.5, "Neutral", "12:00:00 EST", true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillClosePriceParams(Order baseOrder, double maxPctVol, string riskAversion, string startTime,
    bool forceCompletion, double monetaryValue)
    {
    baseOrder.AlgoStrategy = "ClosePx";
    baseOrder.AlgoParams = new List<TagValue>();
    baseOrder.AlgoParams.Add(new TagValue("maxPctVol", maxPctVol.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("riskAversion", riskAversion));
    baseOrder.AlgoParams.Add(new TagValue("startTime", startTime));
    baseOrder.AlgoParams.Add(new TagValue("forceCompletion", forceCompletion ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("monetaryValue", monetaryValue.ToString()));
    }
  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillClosePriceParams(baseOrder, 0.5, "Neutral", "12:00:00 EST", true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillClosePriceParams(Order baseOrder, double maxPctVol, String riskAversion, String startTime,
    boolean forceCompletion, double monetaryValue){
    baseOrder.algoStrategy("ClosePx");
    baseOrder.algoParams(new ArrayList<>());
    baseOrder.algoParams().add(new TagValue("maxPctVol", String.valueOf(maxPctVol)));
    baseOrder.algoParams().add(new TagValue("riskAversion", riskAversion));
    baseOrder.algoParams().add(new TagValue("startTime", startTime));
    baseOrder.algoParams().add(new TagValue("forceCompletion", forceCompletion ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("monetaryValue", String.valueOf(monetaryValue)));
    }
  • Dim baseOrder As Order = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    AvailableAlgoParams.FillClosePriceParams(baseOrder, 0.5, "Neutral", "12:00:00 EST", True, 100000)
    client.placeOrder(increment(nextOrderId), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    Public Shared Sub FillClosePriceParams(baseOrder As Order, maxPctVol As Double, riskAversion As String, startTime As String, forceCompletion As Boolean, monetaryValue As Double)
    baseOrder.AlgoStrategy = "ClosePx"
    baseOrder.AlgoParams = New List(Of TagValue)
    baseOrder.AlgoParams.Add(New TagValue("maxPctVol", maxPctVol.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("riskAversion", riskAversion))
    baseOrder.AlgoParams.Add(New TagValue("startTime", startTime))
    baseOrder.AlgoParams.Add(New TagValue("forceCompletion", BooleantoString(forceCompletion)))
    baseOrder.AlgoParams.Add(New TagValue("monetaryValue", monetaryValue.ToString()))
    End Sub
  • Order baseOrder = OrderSamples::LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams::FillClosePriceParams(baseOrder, 0.5, "Neutral", "12:00:00 EST", true, 100000);
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStockAtSmart(), baseOrder);
    ...
    void AvailableAlgoParams::FillClosePriceParams(Order& baseOrder, double maxPctVol, std::string riskAversion, std::string startTime, bool forceCompletion, double monetaryValue){
    baseOrder.algoStrategy = "ClosePx";
    baseOrder.algoParams.reset(new TagValueList());
    TagValueSPtr tag1(new TagValue("maxPctVol", std::to_string(maxPctVol)));
    TagValueSPtr tag2(new TagValue("riskAversion",riskAversion));
    TagValueSPtr tag3(new TagValue("startTime", startTime));
    TagValueSPtr tag4(new TagValue("forceCompletion", forceCompletion ? "1" : "0"));
    TagValueSPtr tag5(new TagValue("monetaryValue", std::to_string(monetaryValue)));
    baseOrder.algoParams->push_back(tag1);
    baseOrder.algoParams->push_back(tag2);
    baseOrder.algoParams->push_back(tag3);
    baseOrder.algoParams->push_back(tag4);
    baseOrder.algoParams->push_back(tag5);
    }
  • 1  baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    1  AvailableAlgoParams.FillClosePriceParams(baseOrder, 0.4, "Neutral", "20180926-06:06:49", True, 100000)
    2  self.placeOrder(self.nextOrderId(), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    1  @staticmethod
    2  def FillClosePriceParams(baseOrder: Order, maxPctVol: float, riskAversion: str,
    3  startTime: str, forceCompletion: bool,
    4  monetaryValue: float):
    5  baseOrder.algoStrategy = "ClosePx"
    6  baseOrder.algoParams = []
    7  baseOrder.algoParams.append(TagValue("maxPctVol", maxPctVol))
    8  baseOrder.algoParams.append(TagValue("riskAversion", riskAversion))
    9  baseOrder.algoParams.append(TagValue("startTime", startTime))
    10  baseOrder.algoParams.append(TagValue("forceCompletion", int(forceCompletion)))
    11  baseOrder.algoParams.append(TagValue("monetaryValue", monetaryValue))
    12 

Midprice

A Midprice order is designed to split the difference between the bid and ask prices, and fill at the current midpoint of the NBBO or better. Set an optional price cap to define the highest price (for a buy order) or the lowest price (for a sell order) you are willing to accept. Requires TWS 975+. Smart-routing to US stocks only.

  • Products: US STK
  • Exchanges: Smart-routing only
  • Order order = new Order();
    order.Action = action;
    order.OrderType = "MIDPRICE";
    order.TotalQuantity = quantity;
    order.LmtPrice = priceCap;
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), OrderSamples.Midprice("BUY", 1, 150));
  • Order order = new Order();
    order.action(action);
    order.orderType("MIDPRICE");
    order.totalQuantity(quantity);
    order.lmtPrice(priceCap); // optional
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), OrderSamples.Midprice("BUY", 1, 150));
  • Dim order As Order = New Order
    order.Action = action
    order.OrderType = "MIDPRICE"
    order.TotalQuantity = quantity
    order.LmtPrice = priceCap ''' optional
    client.placeOrder(increment(nextOrderId), ContractSamples.USStockAtSmart(), OrderSamples.Midprice("BUY", 1, 150))
  • Order order;
    order.action = action;
    order.orderType = "MIDPRICE";
    order.totalQuantity = quantity;
    order.lmtPrice = priceCap; // optional
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStockAtSmart(), OrderSamples::Midprice("BUY", 1, 150));
  • 1  order = Order()
    2  order.action = action
    3  order.orderType = "MIDPRICE"
    4  order.totalQuantity = quantity
    5  order.lmtPrice = priceCap # optional
    1  self.placeOrder(self.nextOrderId(), ContractSamples.USStockAtSmart(), OrderSamples.Midprice("BUY", 1, 150))

DarkIce

The Dark Ice order type develops the concept of privacy adopted by orders such as Iceberg or Reserve, using a proprietary algorithm to further hide the volume displayed to the market by the order. Clients can determine the timeframe an order remains live and have the option to allow trading past end time in the event it is unfilled by the stated end time. In order to minimize market impact in the event of large orders, users can specify a display size to be shown to the market different from the actual order size. Additionally, the Dark Ice algo randomizes the display size +/- 50% based upon the probability of the price moving favourably. Further, using calculated probabilities, the algo decides whether to place the order at the limit price or one tick lower than the current offer for buy orders and one tick higher than the current bid for sell orders.

ParameterDescriptionValues
displaySizeOrder size to be displayed
startTimeAlgorithm starting timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
endTimeAlgorithm ending timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
allowPastEndTimeAllow trading past end time1 (true) or 0 (false)
monetaryValueCash Quantity


  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillDarkIceParams(baseOrder, 10, "09:00:00 CET", "16:00:00 CET", true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillDarkIceParams(Order baseOrder, int displaySize, string startTime, string endTime,
    bool allowPastEndTime, double monetaryValue)
    {
    baseOrder.AlgoStrategy = "DarkIce";
    baseOrder.AlgoParams = new List<TagValue>();
    baseOrder.AlgoParams.Add(new TagValue("displaySize", displaySize.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("startTime", startTime));
    baseOrder.AlgoParams.Add(new TagValue("endTime", endTime));
    baseOrder.AlgoParams.Add(new TagValue("allowPastEndTime", allowPastEndTime ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("monetaryValue", monetaryValue.ToString()));
    }
  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillDarkIceParams(baseOrder, 10, "09:00:00 CET", "16:00:00 CET", true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillDarkIceParams(Order baseOrder, int displaySize, String startTime, String endTime,
    boolean allowPastEndTime, double monetaryValue) {
    baseOrder.algoStrategy("DarkIce");
    baseOrder.algoParams(new ArrayList<>());
    baseOrder.algoParams().add(new TagValue("displaySize", String.valueOf(displaySize)));
    baseOrder.algoParams().add(new TagValue("startTime", startTime));
    baseOrder.algoParams().add(new TagValue("endTime", endTime));
    baseOrder.algoParams().add(new TagValue("allowPastEndTime", allowPastEndTime ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("monetaryValue", String.valueOf(monetaryValue)));
    }
  • Dim baseOrder As Order = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    AvailableAlgoParams.FillDarkIceParams(baseOrder, 10, "09:00:00 CET", "16:00:00 CET", True, 100000)
    client.placeOrder(increment(nextOrderId), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    Public Shared Sub FillDarkIceParams(baseOrder As Order, displaySize As Integer, startTime As String, endTime As String,
    allowPastEndTime As Boolean, monetaryValue As Double)
    baseOrder.AlgoStrategy = "DarkIce"
    baseOrder.AlgoParams = New List(Of TagValue)
    baseOrder.AlgoParams.Add(New TagValue("displaySize", displaySize.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("startTime", startTime))
    baseOrder.AlgoParams.Add(New TagValue("endTime", endTime))
    baseOrder.AlgoParams.Add(New TagValue("allowPastEndTime", BooleantoString(allowPastEndTime)))
    baseOrder.AlgoParams.Add(New TagValue("monetaryValue", monetaryValue.ToString()))
    End Sub
  • Order baseOrder = OrderSamples::LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams::FillDarkIceParams(baseOrder, 10, "09:00:00 CET", "16:00:00 CET", true, 100000);
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStockAtSmart(), baseOrder);
    ...
    void AvailableAlgoParams::FillDarkIceParams(Order& baseOrder, int displaySize, std::string startTime, std::string endTime, bool allowPastEndTime, double monetaryValue){
    baseOrder.algoStrategy = "DarkIce";
    baseOrder.algoParams.reset(new TagValueList());
    TagValueSPtr tag1(new TagValue("displaySize", std::to_string(displaySize)));
    TagValueSPtr tag2(new TagValue("startTime", startTime));
    TagValueSPtr tag3(new TagValue("endTime", endTime));
    TagValueSPtr tag4(new TagValue("allowPastEndTime", allowPastEndTime ? "1" : "0"));
    TagValueSPtr tag5(new TagValue("monetaryValue", std::to_string(monetaryValue)));
    baseOrder.algoParams->push_back(tag1);
    baseOrder.algoParams->push_back(tag2);
    baseOrder.algoParams->push_back(tag3);
    baseOrder.algoParams->push_back(tag4);
    baseOrder.algoParams->push_back(tag5);
    }
  • 1  baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    1  AvailableAlgoParams.FillDarkIceParams(baseOrder, 10, "09:00:00 CET", "16:00:00 CET", True, 100000)
    2  self.placeOrder(self.nextOrderId(), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    1  @staticmethod
    2  def FillDarkIceParams(baseOrder: Order, displaySize: int, startTime: str,
    3  endTime: str, allowPastEndTime: bool,
    4  monetaryValue: float):
    5  baseOrder.algoStrategy = "DarkIce"
    6  baseOrder.algoParams = []
    7  baseOrder.algoParams.append(TagValue("displaySize", displaySize))
    8  baseOrder.algoParams.append(TagValue("startTime", startTime))
    9  baseOrder.algoParams.append(TagValue("endTime", endTime))
    10  baseOrder.algoParams.append(TagValue("allowPastEndTime",
    11  int(allowPastEndTime)))
    12  baseOrder.algoParams.append(TagValue("monetaryValue", monetaryValue))
    13 

Accumulate/Distribute

The Accumulate/Distribute algo can help you to achieve the best price for a large volume order without being noticed in the market, and can be set up for high frequency trading. By slicing your order into smaller randomly-sized order increments that are released at random time intervals within a user-defined time period, the algo allows the trading of large blocks of stock and other instruments without being detected in the market. The algo allows limit, market, and relative order types. It is important to keep in mind the API A/D algo will not have all available parameters of the A/D algos that can be created in TWS. Note: The new fields activeTimeStart and activeTimeEnd are used in TWS 971+; startTime and endTime were used previously.

ParameterDescriptionValues
componentSizeQuantity of incrementCannot exceed initial size
timeBetweenOrdersTime interval in seconds between each order
randomizeTime20Randomise time period by +/- 20%1 (true) or 0 (false)
randomizeSize55Randomise size by +/- 55%1 (true) or 0 (false)
giveUpNumber associated with the clearing
catchUpCatch up in time1 (true) or 0 (false)
waitForFillWait for current order to fill before submitting next order1 (true) or 0 (false)
activeTimeStartAlgorithm starting timeYYYYMMDD-hh:mm:ss TMZ
activeTimeEndAlgorithm ending timeYYYYMMDD-hh:mm:ss TMZ


  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    // The Time Zone in "startTime" and "endTime" attributes is ignored and always defaulted to GMT
    AvailableAlgoParams.FillAccumulateDistributeParams(baseOrder, 10, 60, true, true, 1, true, true, "20161010-12:00:00 GMT", "20161010-16:00:00 GMT");
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillAccumulateDistributeParams(Order baseOrder, int componentSize, int timeBetweenOrders, bool randomizeTime20, bool randomizeSize55,
    int giveUp, bool catchUp, bool waitForFill, string startTime, string endTime)
    {
    baseOrder.AlgoStrategy = "AD";
    baseOrder.AlgoParams = new List<TagValue>();
    baseOrder.AlgoParams.Add(new TagValue("componentSize", componentSize.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("timeBetweenOrders", timeBetweenOrders.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("randomizeTime20", randomizeTime20 ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("randomizeSize55", randomizeSize55 ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("giveUp", giveUp.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("catchUp", catchUp ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("waitForFill", waitForFill ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("activeTimeStart", startTime));
    baseOrder.AlgoParams.Add(new TagValue("activeTimeEnd", endTime));
    }
  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    // The Time Zone in "startTime" and "endTime" attributes is ignored and always defaulted to GMT
    AvailableAlgoParams.FillAccumulateDistributeParams(baseOrder, 10, 60, true, true, 1, true, true, "20161010-12:00:00 GMT", "20161010-16:00:00 GMT");
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillAccumulateDistributeParams(Order baseOrder, int componentSize, int timeBetweenOrders, boolean randomizeTime20, boolean randomizeSize55,
    int giveUp, boolean catchUp, boolean waitForFill, String startTime, String endTime) {
    baseOrder.algoStrategy("AD");
    baseOrder.algoParams(new ArrayList<>());
    baseOrder.algoParams().add(new TagValue("componentSize", String.valueOf(componentSize)));
    baseOrder.algoParams().add(new TagValue("timeBetweenOrders", String.valueOf(timeBetweenOrders)));
    baseOrder.algoParams().add(new TagValue("randomizeTime20", randomizeTime20 ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("randomizeSize55", randomizeSize55 ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("giveUp", String.valueOf(giveUp)));
    baseOrder.algoParams().add(new TagValue("catchUp", catchUp ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("waitForFill", waitForFill ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("activeTimeStart", startTime));
    baseOrder.algoParams().add(new TagValue("activeTimeEnd", endTime));
    }
  • Dim baseOrder As Order = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    ' The Time Zone in "startTime" and "endTime" attributes is ignored and always defaulted to GMT
    AvailableAlgoParams.FillAccumulateDistributeParams(baseOrder, 10, 60, True, True, 1, True, True, "20161010-12:00:00 GMT", "20161010-16:00:00 GMT")
    client.placeOrder(increment(nextOrderId), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    Public Shared Sub FillAccumulateDistributeParams(baseOrder As Order, componentSize As Integer, timeBetweenOrders As Integer, randomizeTime20 As Boolean, randomizeSize55 As Boolean,
    giveUp As Integer, catchUp As Boolean, waitForFill As Boolean, startTime As String, endTime As String)
    baseOrder.AlgoStrategy = "AD"
    baseOrder.AlgoParams = New List(Of TagValue)
    baseOrder.AlgoParams.Add(New TagValue("componentSize", componentSize.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("timeBetweenOrders", timeBetweenOrders.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("randomizeTime20", BooleantoString(randomizeTime20)))
    baseOrder.AlgoParams.Add(New TagValue("randomizeSize55", BooleantoString(randomizeSize55)))
    baseOrder.AlgoParams.Add(New TagValue("giveUp", giveUp.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("catchUp", BooleantoString(catchUp)))
    baseOrder.AlgoParams.Add(New TagValue("waitForFill", BooleantoString(waitForFill)))
    baseOrder.AlgoParams.Add(New TagValue("activeTimeStart", startTime))
    baseOrder.AlgoParams.Add(New TagValue("activeTimeEnd", endTime))
    End Sub
  • Order baseOrder = OrderSamples::LimitOrder("BUY", 1000, 1);
    ...
    // The Time Zone in "startTime" and "endTime" attributes is ignored and always defaulted to GMT
    AvailableAlgoParams::FillAccumulateDistributeParams(baseOrder, 10, 60, true, true, 1, true, true, "20161010-12:00:00 GMT", "20161010-16:00:00 GMT");
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStockAtSmart(), baseOrder);
    ...
    void AvailableAlgoParams::FillAccumulateDistributeParams(Order& baseOrder, int componentSize, int timeBetweenOrders, bool randomizeTime20, bool randomizeSize55,
    int giveUp, bool catchUp, bool waitForFill, std::string startTime, std::string endTime){
    baseOrder.algoStrategy = "AD";
    baseOrder.algoParams.reset(new TagValueList());
    TagValueSPtr tag1(new TagValue("componentSize", std::to_string(componentSize)));
    TagValueSPtr tag2(new TagValue("timeBetweenOrders",std::to_string(timeBetweenOrders)));
    TagValueSPtr tag3(new TagValue("randomizeTime20", randomizeTime20 ? "1" : "0"));
    TagValueSPtr tag4(new TagValue("randomizeSize55", randomizeSize55 ? "1" : "0"));
    TagValueSPtr tag5(new TagValue("giveUp", std::to_string(giveUp)));
    TagValueSPtr tag6(new TagValue("catchUp", catchUp ? "1" : "0"));
    TagValueSPtr tag7(new TagValue("waitForFill", waitForFill ? "1" : "0"));
    TagValueSPtr tag8(new TagValue("activeTimeStart", startTime));
    TagValueSPtr tag9(new TagValue("activeTimeEnd", endTime));
    baseOrder.algoParams->push_back(tag1);
    baseOrder.algoParams->push_back(tag2);
    baseOrder.algoParams->push_back(tag3);
    baseOrder.algoParams->push_back(tag4);
    baseOrder.algoParams->push_back(tag5);
    baseOrder.algoParams->push_back(tag6);
    baseOrder.algoParams->push_back(tag7);
    baseOrder.algoParams->push_back(tag8);
    baseOrder.algoParams->push_back(tag9);
    }
  • 1  baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    1  # The Time Zone in "startTime" and "endTime" attributes is ignored and always defaulted to GMT
    2  AvailableAlgoParams.FillAccumulateDistributeParams(baseOrder, 10, 60, True, True, 1, True, True, "20161010-12:00:00 GMT", "20161010-16:00:00 GMT")
    3  self.placeOrder(self.nextOrderId(), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    1  @staticmethod
    2  def FillAccumulateDistributeParams(baseOrder: Order, componentSize: int,
    3  timeBetweenOrders: int, randomizeTime20: bool, randomizeSize55: bool,
    4  giveUp: int, catchUp: bool, waitForFill: bool, startTime: str,
    5  endTime: str):
    6  baseOrder.algoStrategy = "AD"
    7  baseOrder.algoParams = []
    8  baseOrder.algoParams.append(TagValue("componentSize", componentSize))
    9  baseOrder.algoParams.append(TagValue("timeBetweenOrders", timeBetweenOrders))
    10  baseOrder.algoParams.append(TagValue("randomizeTime20",
    11  int(randomizeTime20)))
    12  baseOrder.algoParams.append(TagValue("randomizeSize55",
    13  int(randomizeSize55)))
    14  baseOrder.algoParams.append(TagValue("giveUp", giveUp))
    15  baseOrder.algoParams.append(TagValue("catchUp", int(catchUp)))
    16  baseOrder.algoParams.append(TagValue("waitForFill", int(waitForFill)))
    17  baseOrder.algoParams.append(TagValue("activeTimeStart", startTime))
    18  baseOrder.algoParams.append(TagValue("activeTimeEnd", endTime))
    19 

Percentage of Volume

The Percent of Volume algo can limit the contribution of orders to overall average daily volume in order to minimize impact. Clients can set a value between 1-50% to control their participation between stated start and end times. Order quantity and volume distribution over the day is determined using the target percent of volume you entered along with continuously updated volume forecasts calculated from TWS market data. In addition, the algo can be set to avoid taking liquidity, which may help avoid liquidity-taker fees and could result in liquidity-adding rebates. By checking the Attempt to never take liquidity box, the algo is discouraged from hitting the bid or lifting the offer if possible. However, this may also result in greater deviations from the benchmark, and in partial fills, since the posted bid/offer may not always get hit as the price moves up/down. IB will use best efforts not to take liquidity when this box is checked, however, there will be times that it cannot be avoided.

ParameterDescriptionValues
pctVolTarget Percentage0.1 (10%) - 0.5 (50%)
startTimeAlgorithm starting timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
endTimeAlgorithm ending timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
noTakeLiqAttempt to never take liquidity1 (true) or 0 (false)
monetaryValueCash Quantity


  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillPctVolParams(baseOrder, 0.5, "12:00:00 EST", "14:00:00 EST", true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillPctVolParams(Order baseOrder, double pctVol, string startTime, string endTime, bool noTakeLiq, double monetaryValue)
    {
    baseOrder.AlgoStrategy = "PctVol";
    baseOrder.AlgoParams = new List<TagValue>();
    baseOrder.AlgoParams.Add(new TagValue("pctVol", pctVol.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("startTime", startTime));
    baseOrder.AlgoParams.Add(new TagValue("endTime", endTime));
    baseOrder.AlgoParams.Add(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("monetaryValue", monetaryValue.ToString()));
    }
  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillPctVolParams(baseOrder, 0.5, "12:00:00 EST", "14:00:00 EST", true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillPctVolParams(Order baseOrder, double pctVol, String startTime, String endTime, boolean noTakeLiq, double monetaryValue) {
    baseOrder.algoStrategy("PctVol");
    baseOrder.algoParams(new ArrayList<>());
    baseOrder.algoParams().add(new TagValue("pctVol", String.valueOf(pctVol)));
    baseOrder.algoParams().add(new TagValue("startTime", startTime));
    baseOrder.algoParams().add(new TagValue("endTime", endTime));
    baseOrder.algoParams().add(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("monetaryValue", String.valueOf(monetaryValue)));
    }
  • Dim baseOrder As Order = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    AvailableAlgoParams.FillPctVolParams(baseOrder, 0.5, "12:00:00 EST", "14:00:00 EST", True, 100000)
    client.placeOrder(increment(nextOrderId), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    Public Shared Sub FillPctVolParams(baseOrder As Order, pctVol As Double, startTime As String, endTime As String, noTakeLiq As Boolean, monetaryValue As Double)
    baseOrder.AlgoStrategy = "PctVol"
    baseOrder.AlgoParams = New List(Of TagValue)
    baseOrder.AlgoParams.Add(New TagValue("pctVol", pctVol.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("startTime", startTime))
    baseOrder.AlgoParams.Add(New TagValue("endTime", endTime))
    baseOrder.AlgoParams.Add(New TagValue("noTakeLiq", BooleantoString(noTakeLiq)))
    baseOrder.AlgoParams.Add(New TagValue("monetaryValue", monetaryValue.ToString()))
    End Sub
  • Order baseOrder = OrderSamples::LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams::FillPctVolParams(baseOrder, 0.5, "12:00:00 EST", "14:00:00 EST", true, 100000);
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStockAtSmart(), baseOrder);
    ...
    void AvailableAlgoParams::FillPctVolParams(Order& baseOrder, double pctVol, std::string startTime, std::string endTime, bool noTakeLiq, double monetaryValue){
    baseOrder.algoStrategy = "PctVol";
    baseOrder.algoParams.reset(new TagValueList());
    TagValueSPtr tag1(new TagValue("pctVol", std::to_string(pctVol)));
    TagValueSPtr tag2(new TagValue("startTime", startTime));
    TagValueSPtr tag3(new TagValue("endTime", endTime));
    TagValueSPtr tag4(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    TagValueSPtr tag5(new TagValue("monetaryValue", std::to_string(monetaryValue)));
    baseOrder.algoParams->push_back(tag1);
    baseOrder.algoParams->push_back(tag2);
    baseOrder.algoParams->push_back(tag3);
    baseOrder.algoParams->push_back(tag4);
    baseOrder.algoParams->push_back(tag5);
    }
  • 1  baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    1  AvailableAlgoParams.FillPctVolParams(baseOrder, 0.5, "12:00:00 EST", "14:00:00 EST", True, 100000)
    2  self.placeOrder(self.nextOrderId(), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    1  @staticmethod
    2  def FillPctVolParams(baseOrder: Order, pctVol: float, startTime: str,
    3  endTime: str, noTakeLiq: bool,
    4  monetaryValue: float):
    5  baseOrder.algoStrategy = "PctVol"
    6  baseOrder.algoParams = []
    7  baseOrder.algoParams.append(TagValue("pctVol", pctVol))
    8  baseOrder.algoParams.append(TagValue("startTime", startTime))
    9  baseOrder.algoParams.append(TagValue("endTime", endTime))
    10  baseOrder.algoParams.append(TagValue("noTakeLiq", int(noTakeLiq)))
    11  baseOrder.algoParams.append(TagValue("monetaryValue", monetaryValue))
    12 

TWAP

The TWAP algo aims to achieve the time-weighted average price calculated from the time you submit the order to the time it completes. Incomplete orders at the end of the stated completion time will continue to fill if the box 'allow trading past end time' is checked. Users can set the order to trade only when specified conditions are met. Those user-defined inputs include when the order is marketable, when the midpoint matches the required price, when the same side (buy or sell) matches to make the order marketable or when the last traded price would make the order marketable. For the TWAP algo, the average price calculation is calculated from the order entry time through the close of the market and will only attempt to execute when the criterion is met. The order may not fill throughout its stated duration and so the order is not guaranteed. TWAP is available for all US equities.

ParameterDescriptionValues
strategyTypeTrade strategyMarketable, Matching, Midpoint, Matching Same Side, Matching Last
startTimeAlgorithm starting timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
endTimeAlgorithm ending timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
allowPastEndTimeAllow trading past end time1 (true) or 0 (false)
monetaryValueCash Quantity


  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillTwapParams(baseOrder, "Marketable", "09:00:00 CET", "16:00:00 CET", true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillTwapParams(Order baseOrder, string strategyType, string startTime, string endTime, bool allowPastEndTime, double monetaryValue)
    {
    baseOrder.AlgoStrategy = "Twap";
    baseOrder.AlgoParams = new List<TagValue>();
    baseOrder.AlgoParams.Add(new TagValue("strategyType", strategyType));
    baseOrder.AlgoParams.Add(new TagValue("startTime", startTime));
    baseOrder.AlgoParams.Add(new TagValue("endTime", endTime));
    baseOrder.AlgoParams.Add(new TagValue("allowPastEndTime", allowPastEndTime ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("monetaryValue", monetaryValue.ToString()));
    }
  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillTwapParams(baseOrder, "Marketable", "09:00:00 CET", "16:00:00 CET", true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillTwapParams(Order baseOrder, String strategyType, String startTime, String endTime,
    boolean allowPastEndTime, double monetaryValue) {
    baseOrder.algoStrategy("Twap");
    baseOrder.algoParams(new ArrayList<>());
    baseOrder.algoParams().add(new TagValue("strategyType", strategyType));
    baseOrder.algoParams().add(new TagValue("startTime", startTime));
    baseOrder.algoParams().add(new TagValue("endTime", endTime));
    baseOrder.algoParams().add(new TagValue("allowPastEndTime", allowPastEndTime ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("monetaryValue", String.valueOf(monetaryValue)));
    }
  • Dim baseOrder As Order = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    AvailableAlgoParams.FillTwapParams(baseOrder, "Marketable", "09:00:00 CET", "16:00:00 CET", True, 100000)
    client.placeOrder(increment(nextOrderId), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    Public Shared Sub FillTwapParams(baseOrder As Order, strategyType As String, startTime As String, endTime As String,
    allowPastEndTime As Boolean, monetaryValue As Double)
    baseOrder.AlgoStrategy = "Twap"
    baseOrder.AlgoParams = New List(Of TagValue)
    baseOrder.AlgoParams.Add(New TagValue("strategyType", strategyType))
    baseOrder.AlgoParams.Add(New TagValue("startTime", startTime))
    baseOrder.AlgoParams.Add(New TagValue("endTime", endTime))
    baseOrder.AlgoParams.Add(New TagValue("allowPastEndTime", BooleantoString(allowPastEndTime)))
    baseOrder.AlgoParams.Add(New TagValue("monetaryValue", monetaryValue.ToString()))
    End Sub
  • Order baseOrder = OrderSamples::LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams::FillTwapParams(baseOrder, "Marketable", "09:00:00 CET", "16:00:00 CET", true, 100000);
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStockAtSmart(), baseOrder);
    ...
    void AvailableAlgoParams::FillTwapParams(Order& baseOrder, std::string strategyType, std::string startTime, std::string endTime, bool allowPastEndTime, double monetaryValue){
    baseOrder.algoStrategy = "Twap";
    baseOrder.algoParams.reset(new TagValueList());
    TagValueSPtr tag1(new TagValue("strategyType", strategyType));
    TagValueSPtr tag2(new TagValue("startTime", startTime));
    TagValueSPtr tag3(new TagValue("endTime", endTime));
    TagValueSPtr tag4(new TagValue("allowPastEndTime", allowPastEndTime ? "1" : "0"));
    TagValueSPtr tag5(new TagValue("monetaryValue", std::to_string(monetaryValue)));
    baseOrder.algoParams->push_back(tag1);
    baseOrder.algoParams->push_back(tag2);
    baseOrder.algoParams->push_back(tag3);
    baseOrder.algoParams->push_back(tag4);
    baseOrder.algoParams->push_back(tag5);
    }
  • 1  baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    1  AvailableAlgoParams.FillTwapParams(baseOrder, "Marketable", "09:00:00 CET", "16:00:00 CET", True, 100000)
    2  self.placeOrder(self.nextOrderId(), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    1  @staticmethod
    2  def FillTwapParams(baseOrder: Order, strategyType: str, startTime: str,
    3  endTime: str, allowPastEndTime: bool,
    4  monetaryValue: float):
    5  baseOrder.algoStrategy = "Twap"
    6  baseOrder.algoParams = []
    7  baseOrder.algoParams.append(TagValue("strategyType", strategyType))
    8  baseOrder.algoParams.append(TagValue("startTime", startTime))
    9  baseOrder.algoParams.append(TagValue("endTime", endTime))
    10  baseOrder.algoParams.append(TagValue("allowPastEndTime",
    11  int(allowPastEndTime)))
    12  baseOrder.algoParams.append(TagValue("monetaryValue", monetaryValue))
    13 

Price Variant Percentage of Volume Strategy

Price Variant Percentage of Volume Strategy - This algo allows you to participate in volume at a user-defined rate that varies over time depending on the market price of the security. This algo allows you to buy more aggressively when the price is low and be more passive as the price increases, and just the opposite for sell orders. The order quantity and volume distribution over the time during which the order is active is determined using the target percent of volume you entered along with continuously updated volume forecasts calculated from TWS market data.

ParameterDescriptionValues
pctVolTarget Percentage0.1 (10%) - 0.5 (50%)
deltaPctVolTarget Percentage Change Rate0.1 (10%) - 0.5 (50%)
minPctVol4PxMinimum Target Percentage0.1 (10%) - 0.5 (50%)
maxPctVol4PxMaximum Target Percentage0.1 (10%) - 0.5 (50%)
startTimeAlgorithm starting timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
endTimeAlgorithm ending timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
noTakeLiqAttempt to never take liquidity1 (true) or 0 (false)
monetaryValueCash Quantity


  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillPriceVariantPctVolParams(baseOrder, 0.1, 0.05, 0.01, 0.2, "12:00:00 EST", "14:00:00 EST", true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillPriceVariantPctVolParams(Order baseOrder, double pctVol, double deltaPctVol, double minPctVol4Px,
    double maxPctVol4Px, String startTime, String endTime, bool noTakeLiq, double monetaryValue)
    {
    baseOrder.AlgoStrategy = "PctVolPx";
    baseOrder.AlgoParams = new List<TagValue>();
    baseOrder.AlgoParams.Add(new TagValue("pctVol", pctVol.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("deltaPctVol", deltaPctVol.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("minPctVol4Px", minPctVol4Px.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("maxPctVol4Px", maxPctVol4Px.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("startTime", startTime));
    baseOrder.AlgoParams.Add(new TagValue("endTime", endTime));
    baseOrder.AlgoParams.Add(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("monetaryValue", monetaryValue.ToString()));
    }
  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillPriceVariantPctVolParams(baseOrder, 0.1, 0.05, 0.01, 0.2, "12:00:00 EST", "14:00:00 EST", true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillPriceVariantPctVolParams(Order baseOrder, double pctVol, double deltaPctVol, double minPctVol4Px,
    double maxPctVol4Px, String startTime, String endTime, boolean noTakeLiq, double monetaryValue){
    baseOrder.algoStrategy("PctVolPx");
    baseOrder.algoParams(new ArrayList<>());
    baseOrder.algoParams().add(new TagValue("pctVol", String.valueOf(pctVol)));
    baseOrder.algoParams().add(new TagValue("deltaPctVol", String.valueOf(deltaPctVol)));
    baseOrder.algoParams().add(new TagValue("minPctVol4Px", String.valueOf(minPctVol4Px)));
    baseOrder.algoParams().add(new TagValue("maxPctVol4Px", String.valueOf(maxPctVol4Px)));
    baseOrder.algoParams().add(new TagValue("startTime", startTime));
    baseOrder.algoParams().add(new TagValue("endTime", endTime));
    baseOrder.algoParams().add(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("monetaryValue", String.valueOf(monetaryValue)));
    }
  • Dim baseOrder As Order = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    AvailableAlgoParams.FillPriceVariantPctVolParams(baseOrder, 0.10000000000000001, 0.050000000000000003, 0.01, 0.20000000000000001, "12:00:00 EST", "14:00:00 EST", True, 100000)
    client.placeOrder(increment(nextOrderId), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    Public Shared Sub FillPriceVariantPctVolParams(baseOrder As Order, pctVol As Double, deltaPctVol As Double, minPctVol4Px As Double,
    maxPctVol4Px As Double, startTime As String, endTime As String, noTakeLiq As Boolean, monetaryValue As Double)
    baseOrder.AlgoStrategy = "PctVolPx"
    baseOrder.AlgoParams = New List(Of TagValue)
    baseOrder.AlgoParams.Add(New TagValue("pctVol", pctVol.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("deltaPctVol", deltaPctVol.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("minPctVol4Px", minPctVol4Px.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("maxPctVol4Px", maxPctVol4Px.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("startTime", startTime))
    baseOrder.AlgoParams.Add(New TagValue("endTime", endTime))
    baseOrder.AlgoParams.Add(New TagValue("noTakeLiq", BooleantoString(noTakeLiq)))
    baseOrder.AlgoParams.Add(New TagValue("monetaryValue", monetaryValue.ToString()))
    End Sub
  • Order baseOrder = OrderSamples::LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams::FillPriceVariantPctVolParams(baseOrder, 0.1, 0.05, 0.01, 0.2, "12:00:00 EST", "14:00:00 EST", true, 100000);
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStockAtSmart(), baseOrder);
    ...
    void AvailableAlgoParams::FillPriceVariantPctVolParams(Order baseOrder, double pctVol, double deltaPctVol, double minPctVol4Px,
    double maxPctVol4Px, std::string startTime, std::string endTime, bool noTakeLiq, double monetaryValue){
    baseOrder.algoStrategy = "PctVolPx";
    baseOrder.algoParams.reset(new TagValueList());
    TagValueSPtr tag1(new TagValue("pctVol", std::to_string(pctVol)));
    TagValueSPtr tag2(new TagValue("deltaPctVol", std::to_string(deltaPctVol)));
    TagValueSPtr tag3(new TagValue("minPctVol4Px", std::to_string(minPctVol4Px)));
    TagValueSPtr tag4(new TagValue("maxPctVol4Px", std::to_string(maxPctVol4Px)));
    TagValueSPtr tag5(new TagValue("startTime", startTime));
    TagValueSPtr tag6(new TagValue("endTime", endTime));
    TagValueSPtr tag7(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    TagValueSPtr tag8(new TagValue("monetaryValue", std::to_string(monetaryValue)));
    baseOrder.algoParams->push_back(tag1);
    baseOrder.algoParams->push_back(tag2);
    baseOrder.algoParams->push_back(tag3);
    baseOrder.algoParams->push_back(tag4);
    baseOrder.algoParams->push_back(tag5);
    baseOrder.algoParams->push_back(tag6);
    baseOrder.algoParams->push_back(tag7);
    baseOrder.algoParams->push_back(tag8);
    }
  • 1  baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    1  AvailableAlgoParams.FillPriceVariantPctVolParams(baseOrder, 0.1, 0.05, 0.01, 0.2, "12:00:00 EST", "14:00:00 EST", True, 100000)
    2  self.placeOrder(self.nextOrderId(), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    1  @staticmethod
    2  def FillPriceVariantPctVolParams(baseOrder: Order, pctVol: float,
    3  deltaPctVol: float, minPctVol4Px: float,
    4  maxPctVol4Px: float, startTime: str,
    5  endTime: str, noTakeLiq: bool,
    6  monetaryValue: float):
    7  baseOrder.algoStrategy = "PctVolPx"
    8  baseOrder.algoParams = []
    9  baseOrder.algoParams.append(TagValue("pctVol", pctVol))
    10  baseOrder.algoParams.append(TagValue("deltaPctVol", deltaPctVol))
    11  baseOrder.algoParams.append(TagValue("minPctVol4Px", minPctVol4Px))
    12  baseOrder.algoParams.append(TagValue("maxPctVol4Px", maxPctVol4Px))
    13  baseOrder.algoParams.append(TagValue("startTime", startTime))
    14  baseOrder.algoParams.append(TagValue("endTime", endTime))
    15  baseOrder.algoParams.append(TagValue("noTakeLiq", int(noTakeLiq)))
    16  baseOrder.algoParams.append(TagValue("monetaryValue", monetaryValue))
    17 

Size Variant Percentage of Volume Strategy

Size Variant Percentage of Volume Strategy - This algo allows you to participate in volume at a user-defined rate that varies over time depending on the remaining size of the order. Define the target percent rate at the start time (Initial Participation Rate) and at the end time (Terminal Participation Rate), and the algo calculates the participation rate over time between the two based on the remaining order size. This allows the order to be more aggressive initially and less aggressive toward the end, or vice versa.

ParameterDescriptionValues
startPctVolInitial Target Percentage0.1 (10%) - 0.5 (50%)
endPctVolTerminal Target Percentage0.1 (10%) - 0.5 (50%)
startTimeAlgorithm starting timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
endTimeAlgorithm ending timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
noTakeLiqAttempt to never take liquidity1 (true) or 0 (false)
monetaryValueCash Quantity


  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillSizeVariantPctVolParams(baseOrder, 0.2, 0.4, "12:00:00 EST", "14:00:00 EST", true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillSizeVariantPctVolParams(Order baseOrder, double startPctVol, double endPctVol,
    String startTime, String endTime, bool noTakeLiq, double monetaryValue)
    {
    baseOrder.AlgoStrategy = "PctVolSz";
    baseOrder.AlgoParams = new List<TagValue>();
    baseOrder.AlgoParams.Add(new TagValue("startPctVol", startPctVol.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("endPctVol", endPctVol.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("startTime", startTime));
    baseOrder.AlgoParams.Add(new TagValue("endTime", endTime));
    baseOrder.AlgoParams.Add(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("monetaryValue", monetaryValue.ToString()));
    }
  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillSizeVariantPctVolParams(baseOrder, 0.2, 0.4, "12:00:00 EST", "14:00:00 EST", true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillSizeVariantPctVolParams(Order baseOrder, double startPctVol, double endPctVol,
    String startTime, String endTime, boolean noTakeLiq, double monetaryValue){
    baseOrder.algoStrategy("PctVolSz");
    baseOrder.algoParams(new ArrayList<>());
    baseOrder.algoParams().add(new TagValue("startPctVol", String.valueOf(startPctVol)));
    baseOrder.algoParams().add(new TagValue("endPctVol", String.valueOf(endPctVol)));
    baseOrder.algoParams().add(new TagValue("startTime", startTime));
    baseOrder.algoParams().add(new TagValue("endTime", endTime));
    baseOrder.algoParams().add(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("monetaryValue", String.valueOf(monetaryValue)));
    }
  • Dim baseOrder As Order = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    AvailableAlgoParams.FillSizeVariantPctVolParams(baseOrder, 0.20000000000000001, 0.40000000000000002, "12:00:00 EST", "14:00:00 EST", True, 100000)
    client.placeOrder(increment(nextOrderId), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    Public Shared Sub FillSizeVariantPctVolParams(baseOrder As Order, startPctVol As Double, endPctVol As Double,
    startTime As String, endTime As String, noTakeLiq As Boolean, monetaryValue As Double)
    baseOrder.AlgoStrategy = "PctVolSz"
    baseOrder.AlgoParams = New List(Of TagValue)
    baseOrder.AlgoParams.Add(New TagValue("startPctVol", startPctVol.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("endPctVol", endPctVol.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("startTime", startTime))
    baseOrder.AlgoParams.Add(New TagValue("endTime", endTime))
    baseOrder.AlgoParams.Add(New TagValue("noTakeLiq", BooleantoString(noTakeLiq)))
    baseOrder.AlgoParams.Add(New TagValue("monetaryValue", monetaryValue.ToString()))
    End Sub
  • Order baseOrder = OrderSamples::LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams::FillSizeVariantPctVolParams(baseOrder, 0.2, 0.4, "12:00:00 EST", "14:00:00 EST", true, 100000);
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStockAtSmart(), baseOrder);
    ...
    void AvailableAlgoParams::FillSizeVariantPctVolParams(Order baseOrder, double startPctVol, double endPctVol,
    std::string startTime, std::string endTime, bool noTakeLiq, double monetaryValue){
    baseOrder.algoStrategy = "PctVolSz";
    baseOrder.algoParams.reset(new TagValueList());
    TagValueSPtr tag1(new TagValue("startPctVol", std::to_string(startPctVol)));
    TagValueSPtr tag2(new TagValue("endPctVol", std::to_string(endPctVol)));
    TagValueSPtr tag3(new TagValue("startTime", startTime));
    TagValueSPtr tag4(new TagValue("endTime", endTime));
    TagValueSPtr tag5(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    TagValueSPtr tag6(new TagValue("monetaryValue", std::to_string(monetaryValue)));
    baseOrder.algoParams->push_back(tag1);
    baseOrder.algoParams->push_back(tag2);
    baseOrder.algoParams->push_back(tag3);
    baseOrder.algoParams->push_back(tag4);
    baseOrder.algoParams->push_back(tag5);
    baseOrder.algoParams->push_back(tag6);
    }
  • 1  baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    1  AvailableAlgoParams.FillSizeVariantPctVolParams(baseOrder, 0.2, 0.4, "12:00:00 EST", "14:00:00 EST", True, 100000)
    2  self.placeOrder(self.nextOrderId(), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    1  @staticmethod
    2  def FillSizeVariantPctVolParams(baseOrder: Order, startPctVol: float,
    3  endPctVol: float, startTime: str,
    4  endTime: str, noTakeLiq: bool,
    5  monetaryValue: float):
    6  baseOrder.algoStrategy = "PctVolSz"
    7  baseOrder.algoParams = []
    8  baseOrder.algoParams.append(TagValue("startPctVol", startPctVol))
    9  baseOrder.algoParams.append(TagValue("endPctVol", endPctVol))
    10  baseOrder.algoParams.append(TagValue("startTime", startTime))
    11  baseOrder.algoParams.append(TagValue("endTime", endTime))
    12  baseOrder.algoParams.append(TagValue("noTakeLiq", int(noTakeLiq)))
    13  baseOrder.algoParams.append(TagValue("monetaryValue", monetaryValue))
    14 

Time Variant Percentage of Volume Strategy

Time Variant Percentage of Volume Strategy - This algo allows you to participate in volume at a user-defined rate that varies with time. Define the target percent rate at the start time and at the end time, and the algo calculates the participation rate over time between the two. This allows the order to be more aggressive initially and less aggressive toward the end, or vice versa.

ParameterDescriptionValues
startPctVolInitial Target Percentage0.1 (10%) - 0.5 (50%)
endPctVolTerminal Target Percentage0.1 (10%) - 0.5 (50%)
startTimeAlgorithm starting timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
endTimeAlgorithm ending timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
noTakeLiqAttempt to never take liquidity1 (true) or 0 (false)
monetaryValueCash Quantity


  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillTimeVariantPctVolParams(baseOrder, 0.2, 0.4, "12:00:00 EST", "14:00:00 EST", true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillTimeVariantPctVolParams(Order baseOrder, double startPctVol, double endPctVol,
    String startTime, String endTime, bool noTakeLiq, double monetaryValue)
    {
    baseOrder.AlgoStrategy = "PctVolTm";
    baseOrder.AlgoParams = new List<TagValue>();
    baseOrder.AlgoParams.Add(new TagValue("startPctVol", startPctVol.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("endPctVol", endPctVol.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("startTime", startTime));
    baseOrder.AlgoParams.Add(new TagValue("endTime", endTime));
    baseOrder.AlgoParams.Add(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("monetaryValue", monetaryValue.ToString()));
    }
  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillTimeVariantPctVolParams(baseOrder, 0.2, 0.4, "12:00:00 EST", "14:00:00 EST", true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillTimeVariantPctVolParams(Order baseOrder, double startPctVol, double endPctVol,
    String startTime, String endTime, boolean noTakeLiq, double monetaryValue){
    baseOrder.algoStrategy("PctVolTm");
    baseOrder.algoParams(new ArrayList<>());
    baseOrder.algoParams().add(new TagValue("startPctVol", String.valueOf(startPctVol)));
    baseOrder.algoParams().add(new TagValue("endPctVol", String.valueOf(endPctVol)));
    baseOrder.algoParams().add(new TagValue("startTime", startTime));
    baseOrder.algoParams().add(new TagValue("endTime", endTime));
    baseOrder.algoParams().add(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("monetaryValue", String.valueOf(monetaryValue)));
    }
  • Dim baseOrder As Order = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    AvailableAlgoParams.FillTimeVariantPctVolParams(baseOrder, 0.20000000000000001, 0.40000000000000002, "12:00:00 EST", "14:00:00 EST", True, 100000)
    client.placeOrder(increment(nextOrderId), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    Public Shared Sub FillTimeVariantPctVolParams(baseOrder As Order, startPctVol As Double, endPctVol As Double,
    startTime As String, endTime As String, noTakeLiq As Boolean, monetaryValue As Double)
    baseOrder.AlgoStrategy = "PctVolTm"
    baseOrder.AlgoParams = New List(Of TagValue)
    baseOrder.AlgoParams.Add(New TagValue("startPctVol", startPctVol.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("endPctVol", endPctVol.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("startTime", startTime))
    baseOrder.AlgoParams.Add(New TagValue("endTime", endTime))
    baseOrder.AlgoParams.Add(New TagValue("noTakeLiq", BooleantoString(noTakeLiq)))
    baseOrder.AlgoParams.Add(New TagValue("monetaryValue", monetaryValue.ToString()))
    End Sub
  • Order baseOrder = OrderSamples::LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams::FillTimeVariantPctVolParams(baseOrder, 0.2, 0.4, "12:00:00 EST", "14:00:00 EST", true, 100000);
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStockAtSmart(), baseOrder);
    ...
    void AvailableAlgoParams::FillTimeVariantPctVolParams(Order baseOrder, double startPctVol, double endPctVol, std::string startTime,
    std::string endTime, bool noTakeLiq, double monetaryValue){
    baseOrder.algoStrategy = "PctVolTm";
    baseOrder.algoParams.reset(new TagValueList());
    TagValueSPtr tag1(new TagValue("startPctVol", std::to_string(startPctVol)));
    TagValueSPtr tag2(new TagValue("endPctVol", std::to_string(endPctVol)));
    TagValueSPtr tag3(new TagValue("startTime", startTime));
    TagValueSPtr tag4(new TagValue("endTime", endTime));
    TagValueSPtr tag5(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    TagValueSPtr tag6(new TagValue("monetaryValue", std::to_string(monetaryValue)));
    baseOrder.algoParams->push_back(tag1);
    baseOrder.algoParams->push_back(tag2);
    baseOrder.algoParams->push_back(tag3);
    baseOrder.algoParams->push_back(tag4);
    baseOrder.algoParams->push_back(tag5);
    baseOrder.algoParams->push_back(tag6);
    }
  • 1  baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    1  AvailableAlgoParams.FillTimeVariantPctVolParams(baseOrder, 0.2, 0.4, "12:00:00 EST", "14:00:00 EST", True, 100000)
    2  self.placeOrder(self.nextOrderId(), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    1  @staticmethod
    2  def FillTimeVariantPctVolParams(baseOrder: Order, startPctVol: float,
    3  endPctVol: float, startTime: str,
    4  endTime: str, noTakeLiq: bool,
    5  monetaryValue: float):
    6  baseOrder.algoStrategy = "PctVolTm"
    7  baseOrder.algoParams = []
    8  baseOrder.algoParams.append(TagValue("startPctVol", startPctVol))
    9  baseOrder.algoParams.append(TagValue("endPctVol", endPctVol))
    10  baseOrder.algoParams.append(TagValue("startTime", startTime))
    11  baseOrder.algoParams.append(TagValue("endTime", endTime))
    12  baseOrder.algoParams.append(TagValue("noTakeLiq", int(noTakeLiq)))
    13  baseOrder.algoParams.append(TagValue("monetaryValue", monetaryValue))

VWAP

IB's best-efforts VWAP algo seeks to achieve the Volume-Weighted Average price (VWAP), calculated from the time you submit the order to the close of the market.

If you require a guaranteed VWAP, please refer to IB's Guaranteed VWAP order type.

Best-efforts VWAP algo is a lower-cost alternative to the Guaranteed VWAP that enables the user to attempt never to take liquidity while also trading past the end time. Because the order may not be filled on the bid or at the ask prices, there is a trade-off with this algo. The order may not fully fill if the user is attempting to avoid liquidity-taking fees and/or maximize liquidity-adding rebates, and may miss the benchmark by asking to stay on the bid or ask. The user can determine the maximum percentage of average daily volume (up to 50%) his order will comprise. The system will generate the VWAP from the time the order is entered through the close of trading, and the order can be limited to trading over a pre-determined period. The user can request the order to continue beyond its stated end time if unfilled at the end of the stated period. The best-efforts VWAP algo is available for all US equities.

ParameterDescriptionValues
maxPctVolMaximum percentage of average daily volume0.1 (10%) - 0.5 (50%)
startTimeAlgorithm starting timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
endTimeAlgorithm ending timehh:mm:ss TMZ or YYYYMMDD-hh:mm:ss TMZ
allowPastEndTimeAllow trading past end time1 (true) or 0 (false)
noTakeLiqAttempt to never take liquidity1 (true) or 0 (false)
speedUpCompensate for the decreased fill rate due to presence of limit price1 (true) or 0 (false)
monetaryValueCash Quantity


  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillVwapParams(baseOrder, 0.2, "09:00:00 CET", "16:00:00 CET", true, true, true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillVwapParams(Order baseOrder, double maxPctVol, string startTime, string endTime,
    bool allowPastEndTime, bool noTakeLiq, bool speedUp, double monetaryValue)
    {
    baseOrder.AlgoStrategy = "Vwap";
    baseOrder.AlgoParams = new List<TagValue>();
    baseOrder.AlgoParams.Add(new TagValue("maxPctVol", maxPctVol.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("startTime", startTime));
    baseOrder.AlgoParams.Add(new TagValue("endTime", endTime));
    baseOrder.AlgoParams.Add(new TagValue("allowPastEndTime", allowPastEndTime ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("speedUp", speedUp ? "1" : "0"));
    baseOrder.AlgoParams.Add(new TagValue("monetaryValue", monetaryValue.ToString()));
    }
  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillVwapParams(baseOrder, 0.2, "09:00:00 CET", "16:00:00 CET", true, true, true, 100000);
    client.placeOrder(nextOrderId++, ContractSamples.USStockAtSmart(), baseOrder);
    ...
    public static void FillVwapParams(Order baseOrder, double maxPctVol, String startTime, String endTime,
    boolean allowPastEndTime, boolean noTakeLiq, boolean speedUp, double monetaryValue) {
    baseOrder.algoStrategy("Vwap");
    baseOrder.algoParams(new ArrayList<>());
    baseOrder.algoParams().add(new TagValue("maxPctVol", String.valueOf(maxPctVol)));
    baseOrder.algoParams().add(new TagValue("startTime", startTime));
    baseOrder.algoParams().add(new TagValue("endTime", endTime));
    baseOrder.algoParams().add(new TagValue("allowPastEndTime", allowPastEndTime ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("speedUp", speedUp ? "1" : "0"));
    baseOrder.algoParams().add(new TagValue("monetaryValue", String.valueOf(monetaryValue)));
    }
  • Dim baseOrder As Order = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    AvailableAlgoParams.FillVwapParams(baseOrder, 0.20000000000000001, "09:00:00 CET", "16:00:00 CET", True, True, True, 100000)
    client.placeOrder(increment(nextOrderId), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    Public Shared Sub FillVwapParams(baseOrder As Order, maxPctVol As Double, startTime As String, endTime As String,
    allowPastEndTime As Boolean, noTakeLiq As Boolean, speedUp As Boolean, monetaryValue As Double)
    baseOrder.AlgoStrategy = "Vwap"
    baseOrder.AlgoParams = New List(Of TagValue)
    baseOrder.AlgoParams.Add(New TagValue("maxPctVol", maxPctVol.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("startTime", startTime))
    baseOrder.AlgoParams.Add(New TagValue("endTime", endTime))
    baseOrder.AlgoParams.Add(New TagValue("allowPastEndTime", BooleantoString(allowPastEndTime)))
    baseOrder.AlgoParams.Add(New TagValue("noTakeLiq", BooleantoString(noTakeLiq)))
    baseOrder.AlgoParams.Add(New TagValue("speedUp", BooleantoString(speedUp)))
    baseOrder.AlgoParams.Add(New TagValue("monetaryValue", monetaryValue.ToString()))
    End Sub
  • Order baseOrder = OrderSamples::LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams::FillBalanceImpactRiskParams(baseOrder, 0.1, "Aggressive", true);
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStockAtSmart(), baseOrder);
    ...
    void AvailableAlgoParams::FillVwapParams(Order& baseOrder, double maxPctVol, std::string startTime, std::string endTime, bool allowPastEndTime, bool noTakeLiq, bool speedUp, double monetaryValue){
    baseOrder.algoStrategy = "Vwap";
    baseOrder.algoParams.reset(new TagValueList());
    TagValueSPtr tag1(new TagValue("maxPctVol", std::to_string(maxPctVol)));
    TagValueSPtr tag2(new TagValue("startTime", startTime));
    TagValueSPtr tag3(new TagValue("endTime", endTime));
    TagValueSPtr tag4(new TagValue("allowPastEndTime", allowPastEndTime ? "1" : "0"));
    TagValueSPtr tag5(new TagValue("noTakeLiq", noTakeLiq ? "1" : "0"));
    TagValueSPtr tag6(new TagValue("speedUp", speedUp ? "1" : "0"));
    TagValueSPtr tag7(new TagValue("monetaryValue", std::to_string(monetaryValue)));
    baseOrder.algoParams->push_back(tag1);
    baseOrder.algoParams->push_back(tag2);
    baseOrder.algoParams->push_back(tag3);
    baseOrder.algoParams->push_back(tag4);
    baseOrder.algoParams->push_back(tag5);
    baseOrder.algoParams->push_back(tag6);
    baseOrder.algoParams->push_back(tag7);
    }
  • 1  baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    1  AvailableAlgoParams.FillVwapParams(baseOrder, 0.2, "09:00:00 CET", "16:00:00 CET", True, True, 100000)
    2  self.placeOrder(self.nextOrderId(), ContractSamples.USStockAtSmart(), baseOrder)
    ...
    1  @staticmethod
    2  def FillVwapParams(baseOrder: Order, maxPctVol: float, startTime: str,
    3  endTime: str, allowPastEndTime: bool, noTakeLiq: bool,
    4  monetaryValue: float):
    5  baseOrder.algoStrategy = "Vwap"
    6  baseOrder.algoParams = []
    7  baseOrder.algoParams.append(TagValue("maxPctVol", maxPctVol))
    8  baseOrder.algoParams.append(TagValue("startTime", startTime))
    9  baseOrder.algoParams.append(TagValue("endTime", endTime))
    10  baseOrder.algoParams.append(TagValue("allowPastEndTime",
    11  int(allowPastEndTime)))
    12  baseOrder.algoParams.append(TagValue("noTakeLiq", int(noTakeLiq)))
    13  baseOrder.algoParams.append(TagValue("monetaryValue", monetaryValue))
    14 

Balance Impact Risk

The Balance Impact Risk balances the market impact of trading the option with the risk of price change over the time horizon of the order. This strategy considers the user-assigned level of risk aversion to define the pace of the execution, along with the user-defined target percent of volume.

ParameterDescriptionValues
maxPctVolMaximum percentage of average daily volume0.1 (10%) - 0.5 (50%)
riskAversionUrgency/risk aversionGet Done, Aggressive, Neutral, Passive
forceCompletionAttempt completion by the end of the day1 (true) or 0 (false)


  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillBalanceImpactRiskParams(baseOrder, 0.1, "Aggressive", true);
    client.placeOrder(nextOrderId++, ContractSamples.USOptionContract(), baseOrder);
    ...
    public static void FillBalanceImpactRiskParams(Order baseOrder, double maxPctVol, string riskAversion, bool forceCompletion)
    {
    baseOrder.AlgoStrategy = "BalanceImpactRisk";
    baseOrder.AlgoParams = new List<TagValue>();
    baseOrder.AlgoParams.Add(new TagValue("maxPctVol", maxPctVol.ToString()));
    baseOrder.AlgoParams.Add(new TagValue("riskAversion", riskAversion));
    baseOrder.AlgoParams.Add(new TagValue("forceCompletion", forceCompletion ? "1" : "0"));
    }
  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillBalanceImpactRiskParams(baseOrder, 0.1, "Aggressive", true);
    client.placeOrder(nextOrderId++, ContractSamples.USOptionContract(), baseOrder);
    ...
    public static void FillBalanceImpactRiskParams(Order baseOrder, double maxPctVol, String riskAversion, boolean forceCompletion) {
    baseOrder.algoStrategy("BalanceImpactRisk");
    baseOrder.algoParams(new ArrayList<>());
    baseOrder.algoParams().add(new TagValue("maxPctVol", String.valueOf(maxPctVol)));
    baseOrder.algoParams().add(new TagValue("riskAversion", riskAversion));
    baseOrder.algoParams().add(new TagValue("forceCompletion", forceCompletion ? "1" : "0"));
    }
  • Dim baseOrder As Order = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    AvailableAlgoParams.FillBalanceImpactRiskParams(baseOrder, 0.10000000000000001, "Aggressive", True)
    client.placeOrder(increment(nextOrderId), ContractSamples.USOptionContract(), baseOrder)
    ...
    Public Shared Sub FillBalanceImpactRiskParams(baseOrder As Order, maxPctVol As Double, riskAversion As String, forceCompletion As Boolean)
    baseOrder.AlgoStrategy = "BalanceImpactRisk"
    baseOrder.AlgoParams = New List(Of TagValue)
    baseOrder.AlgoParams.Add(New TagValue("maxPctVol", maxPctVol.ToString()))
    baseOrder.AlgoParams.Add(New TagValue("riskAversion", riskAversion))
    baseOrder.AlgoParams.Add(New TagValue("forceCompletion", BooleantoString(forceCompletion)))
    End Sub
  • Order baseOrder = OrderSamples::LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams::FillBalanceImpactRiskParams(baseOrder, 0.1, "Aggressive", true);
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStockAtSmart(), baseOrder);
    ...
    void AvailableAlgoParams::FillBalanceImpactRiskParams(Order& baseOrder, double maxPctVol, std::string riskAversion, bool forceCompletion){
    baseOrder.algoStrategy = "BalanceImpactRisk";
    baseOrder.algoParams.reset(new TagValueList());
    TagValueSPtr tag1(new TagValue("maxPctVol", std::to_string(maxPctVol)));
    TagValueSPtr tag2(new TagValue("riskAversion", riskAversion));
    TagValueSPtr tag3(new TagValue("forceCompletion", forceCompletion ? "1" : "0"));
    baseOrder.algoParams->push_back(tag1);
    baseOrder.algoParams->push_back(tag2);
    baseOrder.algoParams->push_back(tag3);
    }
  • 1  baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    1  AvailableAlgoParams.FillBalanceImpactRiskParams(baseOrder, 0.1, "Aggressive", True)
    2  self.placeOrder(self.nextOrderId(), ContractSamples.USOptionContract(), baseOrder)
    ...
    1  @staticmethod
    2  def FillBalanceImpactRiskParams(baseOrder: Order, maxPctVol: float,
    3  riskAversion: str, forceCompletion: bool):
    4  baseOrder.algoStrategy = "BalanceImpactRisk"
    5  baseOrder.algoParams = []
    6  baseOrder.algoParams.append(TagValue("maxPctVol", maxPctVol))
    7  baseOrder.algoParams.append(TagValue("riskAversion", riskAversion))
    8  baseOrder.algoParams.append(TagValue("forceCompletion",
    9  int(forceCompletion)))
    10 

Minimise Impact

The Minimise Impact algo minimises market impact by slicing the order over time to achieve a market average without going over the given maximum percentage value.

ParameterDescriptionValues
maxPctVolMaximum percentage of average daily volume0.1 (10%) - 0.5 (50%)


  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillMinImpactParams(baseOrder, 0.3);
    client.placeOrder(nextOrderId++, ContractSamples.USOptionContract(), baseOrder);
    ...
    public static void FillMinImpactParams(Order baseOrder, double maxPctVol)
    {
    baseOrder.AlgoStrategy = "MinImpact";
    baseOrder.AlgoParams = new List<TagValue>();
    baseOrder.AlgoParams.Add(new TagValue("maxPctVol", maxPctVol.ToString()));
    }
  • Order baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams.FillMinImpactParams(baseOrder, 0.3);
    client.placeOrder(nextOrderId++, ContractSamples.USOptionContract(), baseOrder);
    ...
    public static void FillMinImpactParams(Order baseOrder, double maxPctVol) {
    baseOrder.algoStrategy("BalanceImpactRisk");
    baseOrder.algoParams(new ArrayList<>());
    baseOrder.algoParams().add(new TagValue("maxPctVol", String.valueOf(maxPctVol)));
    }
  • Dim baseOrder As Order = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    AvailableAlgoParams.FillMinImpactParams(baseOrder, 0.29999999999999999)
    client.placeOrder(increment(nextOrderId), ContractSamples.USOptionContract(), baseOrder)
    ...
    Public Shared Sub FillMinImpactParams(baseOrder As Order, maxPctVol As Double)
    baseOrder.AlgoStrategy = "MinImpact"
    baseOrder.AlgoParams = New List(Of TagValue)
    baseOrder.AlgoParams.Add(New TagValue("maxPctVol", maxPctVol.ToString()))
    End Sub
  • Order baseOrder = OrderSamples::LimitOrder("BUY", 1000, 1);
    ...
    AvailableAlgoParams::FillMinImpactParams(baseOrder, 0.3);
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStockAtSmart(), baseOrder);
    ...
    void AvailableAlgoParams::FillMinImpactParams(Order& baseOrder, double maxPctVol){
    baseOrder.algoStrategy = "MinImpact";
    baseOrder.algoParams.reset(new TagValueList());
    TagValueSPtr tag1(new TagValue("maxPctVol", std::to_string(maxPctVol)));
    baseOrder.algoParams->push_back(tag1);
    }
  • 1  baseOrder = OrderSamples.LimitOrder("BUY", 1000, 1)
    ...
    1  AvailableAlgoParams.FillMinImpactParams(baseOrder, 0.3)
    2  self.placeOrder(self.nextOrderId(), ContractSamples.USOptionContract(), baseOrder)
    ...
    1  @staticmethod
    2  def FillMinImpactParams(baseOrder: Order, maxPctVol: float):
    3  baseOrder.algoStrategy = "MinImpact"
    4  baseOrder.algoParams = []
    5  baseOrder.algoParams.append(TagValue("maxPctVol", maxPctVol))
    6