• C#
  • Java
  • VB
  • C++
  • Python
Contact us
Order Conditioning

Conditions allow to activate orders given a certain criteria...

  • Order mkt = OrderSamples.MarketOrder("BUY", 100);
    //Order will become active if conditioning criteria is met
    mkt.ConditionsCancelOrder = true;
    mkt.Conditions.Add(OrderSamples.PriceCondition(208813720, "SMART", 600, false, false));
    mkt.Conditions.Add(OrderSamples.ExecutionCondition("EUR.USD", "CASH", "IDEALPRO", true));
    mkt.Conditions.Add(OrderSamples.MarginCondition(30, true, false));
    mkt.Conditions.Add(OrderSamples.PercentageChangeCondition(15.0, 208813720, "SMART", true, true));
    mkt.Conditions.Add(OrderSamples.TimeCondition("20160118 23:59:59", true, false));
    mkt.Conditions.Add(OrderSamples.VolumeCondition(208813720, "SMART", false, 100, true));
    client.placeOrder(nextOrderId++, ContractSamples.EuropeanStock(), mkt);
  • Order mkt = OrderSamples.MarketOrder("BUY", 100);
    //Order will become active if conditioning criteria is met
    mkt.conditionsCancelOrder(true);
    mkt.conditions().add(OrderSamples.PriceCondition(208813720, "SMART", 600, false, false));
    mkt.conditions().add(OrderSamples.ExecutionCondition("EUR.USD", "CASH", "IDEALPRO", true));
    mkt.conditions().add(OrderSamples.MarginCondition(30, true, false));
    mkt.conditions().add(OrderSamples.PercentageChangeCondition(15.0, 208813720, "SMART", true, true));
    mkt.conditions().add(OrderSamples.TimeCondition("20160118 23:59:59", true, false));
    mkt.conditions().add(OrderSamples.VolumeCondition(208813720, "SMART", false, 100, true));
    client.placeOrder(nextOrderId++, ContractSamples.EuropeanStock(), mkt);
  • Dim mkt As Order = OrderSamples.MarketOrder("BUY", 100)
    'Order will become active if conditioning criteria Is met
    mkt.ConditionsCancelOrder = True
    mkt.Conditions.Add(OrderSamples.PriceCondition(208813720, "SMART", 600, False, False))
    mkt.Conditions.Add(OrderSamples.ExecutionCondition("EUR.USD", "CASH", "IDEALPRO", True))
    mkt.Conditions.Add(OrderSamples.MarginCondition(30, True, False))
    mkt.Conditions.Add(OrderSamples.PercentageChangeCondition(15.0, 208813720, "SMART", True, True))
    mkt.Conditions.Add(OrderSamples.TimeCondition("20160118 23:59:59", True, False))
    mkt.Conditions.Add(OrderSamples.VolumeCondition(208813720, "SMART", False, 100, True))
    client.placeOrder(increment(nextOrderId), ContractSamples.EuropeanStock(), mkt)
  • Order lmt = OrderSamples::LimitOrder("BUY", 100, 10);
    //Order will become active if conditioning criteria is met
    PriceCondition* priceCondition = dynamic_cast<PriceCondition *>(OrderSamples::Price_Condition(208813720, "SMART", 600, false, false));
    ExecutionCondition* execCondition = dynamic_cast<ExecutionCondition *>(OrderSamples::Execution_Condition("EUR.USD", "CASH", "IDEALPRO", true));
    MarginCondition* marginCondition = dynamic_cast<MarginCondition *>(OrderSamples::Margin_Condition(30, true, false));
    PercentChangeCondition* pctChangeCondition = dynamic_cast<PercentChangeCondition *>(OrderSamples::Percent_Change_Condition(15.0, 208813720, "SMART", true, true));
    TimeCondition* timeCondition = dynamic_cast<TimeCondition *>(OrderSamples::Time_Condition("20160118 23:59:59", true, false));
    VolumeCondition* volumeCondition = dynamic_cast<VolumeCondition *>(OrderSamples::Volume_Condition(208813720, "SMART", false, 100, true));
    lmt.conditions.push_back(ibapi::shared_ptr<PriceCondition>(priceCondition));
    lmt.conditions.push_back(ibapi::shared_ptr<ExecutionCondition>(execCondition));
    lmt.conditions.push_back(ibapi::shared_ptr<MarginCondition>(marginCondition));
    lmt.conditions.push_back(ibapi::shared_ptr<PercentChangeCondition>(pctChangeCondition));
    lmt.conditions.push_back(ibapi::shared_ptr<TimeCondition>(timeCondition));
    lmt.conditions.push_back(ibapi::shared_ptr<VolumeCondition>(volumeCondition));
    m_pClient->placeOrder(m_orderId++, ContractSamples::USStock(),lmt);
  • 1  mkt = OrderSamples.MarketOrder("BUY", 100)
    2  # Order will become active if conditioning criteria is met
    3  mkt.conditionsCancelOrder = True
    4  mkt.conditions.append(
    5  OrderSamples.PriceCondition(PriceCondition.TriggerMethodEnum.Default,
    6  208813720, "SMART", 600, False, False))
    7  mkt.conditions.append(OrderSamples.ExecutionCondition("EUR.USD", "CASH", "IDEALPRO", True))
    8  mkt.conditions.append(OrderSamples.MarginCondition(30, True, False))
    9  mkt.conditions.append(OrderSamples.PercentageChangeCondition(15.0, 208813720, "SMART", True, True))
    10  mkt.conditions.append(OrderSamples.TimeCondition("20160118 23:59:59", True, False))
    11  mkt.conditions.append(OrderSamples.VolumeCondition(208813720, "SMART", False, 100, True))
    12  self.placeOrder(self.nextOrderId(), ContractSamples.EuropeanStock(), mkt)

Or cancel them

  • Order lmt = OrderSamples.LimitOrder("BUY", 100, 20);
    //The active order will be cancelled if conditioning criteria is met
    lmt.ConditionsCancelOrder = true;
    lmt.Conditions.Add(OrderSamples.PriceCondition(208813720, "SMART", 600, false, false));
    client.placeOrder(nextOrderId++, ContractSamples.EuropeanStock(), lmt);
  • Order lmt = OrderSamples.LimitOrder("BUY", 100, 20);
    //The active order will be cancelled if conditioning criteria is met
    lmt.conditionsCancelOrder(true);
    lmt.conditions().add(OrderSamples.PriceCondition(208813720, "SMART", 600, false, false));
    client.placeOrder(nextOrderId++, ContractSamples.EuropeanStock(), lmt);
  • Dim lmt As Order = OrderSamples.LimitOrder("BUY", 100, 20)
    'The active order will be cancelled if conditioning criteria Is met
    lmt.ConditionsCancelOrder = True
    lmt.Conditions.Add(OrderSamples.PriceCondition(208813720, "SMART", 600, False, False))
    client.placeOrder(increment(nextOrderId), ContractSamples.EuropeanStock(), lmt)
  • Order lmt2 = OrderSamples::LimitOrder("BUY", 100, 20);
    //The active order will be cancelled if conditioning criteria is met
    lmt2.conditionsCancelOrder = true;
    PriceCondition* priceCondition2 = dynamic_cast<PriceCondition *>(OrderSamples::Price_Condition(208813720, "SMART", 600, false, false));
    lmt2.conditions.push_back(ibapi::shared_ptr<PriceCondition>(priceCondition2));
    m_pClient->placeOrder(m_orderId++, ContractSamples::EuropeanStock(), lmt2);
  • 1  lmt = OrderSamples.LimitOrder("BUY", 100, 20)
    2  # The active order will be cancelled if conditioning criteria is met
    3  lmt.conditionsCancelOrder = True
    4  lmt.conditions.append(
    5  OrderSamples.PriceCondition(PriceCondition.TriggerMethodEnum.Last,
    6  208813720, "SMART", 600, False, False))
    7  self.placeOrder(self.nextOrderId(), ContractSamples.EuropeanStock(), lmt)

Price Conditions

  • //Conditions have to be created via the OrderCondition.Create
    PriceCondition priceCondition = (PriceCondition)OrderCondition.Create(OrderConditionType.Price);
    //When this contract...
    priceCondition.ConId = conId;
    //traded on this exchange
    priceCondition.Exchange = exchange;
    //has a price above/below
    priceCondition.IsMore = isMore;
    //this quantity
    priceCondition.Price = price;
    //AND | OR next condition (will be ignored if no more conditions are added)
    priceCondition.IsConjunctionConnection = isConjunction;
  • //Conditions have to be created via the OrderCondition.Create
    PriceCondition priceCondition = (PriceCondition)OrderCondition.create(OrderConditionType.Price);
    //When this contract...
    priceCondition.conId(conId);
    //traded on this exchange
    priceCondition.exchange(exchange);
    //has a price above/below
    priceCondition.isMore(isMore);
    //this quantity
    priceCondition.price(price);
    //AND | OR next condition (will be ignored if no more conditions are added)
    priceCondition.conjunctionConnection(isConjunction);
  • 'Conditions have to be created via the OrderCondition.Create
    Dim _priceCondition As PriceCondition = OrderCondition.Create(OrderConditionType.Price) 'cast to priceCondition
    'When this contract...
    _priceCondition.ConId = conId
    'traded on this exchange
    _priceCondition.Exchange = exchange
    'has a price above/below
    _priceCondition.IsMore = isMore
    'this quantity
    _priceCondition.Price = price
    'And | Or next condition (will be ignored if no more conditions are added)
    _priceCondition.IsConjunctionConnection = isConjunction
  • //Conditions have to be created via the OrderCondition.Create
    PriceCondition* priceCondition = dynamic_cast<PriceCondition *>(OrderCondition::create(OrderCondition::OrderConditionType::Price));
    //When this contract...
    priceCondition->conId(conId);
    //traded on this exchange
    priceCondition->exchange(exchange);
    //has a price above/below
    priceCondition->isMore(isMore);
    //this quantity
    priceCondition->price(price);
    //AND | OR next condition (will be ignored if no more conditions are added)
    priceCondition->conjunctionConnection(isConjunction);
  • 1  #Conditions have to be created via the OrderCondition.create
    2  priceCondition = order_condition.Create(OrderCondition.Price)
    3  #When this contract...
    4  priceCondition.conId = conId
    5  #traded on this exchange
    6  priceCondition.exchange = exchange
    7  #has a price above/below
    8  priceCondition.isMore = isMore
    9  priceCondition.triggerMethod = triggerMethod
    10  #this quantity
    11  priceCondition.price = price
    12  #AND | OR next condition (will be ignored if no more conditions are added)
    13  priceCondition.isConjunctionConnection = isConjunction

Execution Conditions

  • ExecutionCondition execCondition = (ExecutionCondition)OrderCondition.Create(OrderConditionType.Execution);
    //When an execution on symbol
    execCondition.Symbol = symbol;
    //at exchange
    execCondition.Exchange = exchange;
    //for this secType
    execCondition.SecType = secType;
    //AND | OR next condition (will be ignored if no more conditions are added)
    execCondition.IsConjunctionConnection = isConjunction;
  • ExecutionCondition execCondition = (ExecutionCondition)OrderCondition.create(OrderConditionType.Execution);
    //When an execution on symbol
    execCondition.symbol(symbol);
    //at exchange
    execCondition.exchange(exchange);
    //for this secType
    execCondition.secType(secType);
    //AND | OR next condition (will be ignored if no more conditions are added)
    execCondition.conjunctionConnection(isConjunction);
  • Dim execCondition As ExecutionCondition = OrderCondition.Create(OrderConditionType.Execution) ' cast to (ExecutionCondition)
    'When an execution on symbol
    execCondition.Symbol = symbol
    'at exchange
    execCondition.Exchange = exchange
    'for this secType
    execCondition.SecType = secType
    'And | Or next condition (will be ignored if no more conditions are added)
    execCondition.IsConjunctionConnection = isConjunction
  • ExecutionCondition* execCondition = dynamic_cast<ExecutionCondition *>(OrderCondition::create(OrderCondition::OrderConditionType::Execution));
    //When an execution on symbol
    execCondition->symbol(symbol);
    //at exchange
    execCondition->exchange(exchange);
    //for this secType
    execCondition->secType(secType);
    //AND | OR next condition (will be ignored if no more conditions are added)
    execCondition->conjunctionConnection(isConjunction);
  • 1  execCondition = order_condition.Create(OrderCondition.Execution)
    2  #When an execution on symbol
    3  execCondition.symbol = symbol
    4  #at exchange
    5  execCondition.exchange = exchange
    6  #for this secType
    7  execCondition.secType = secType
    8  #AND | OR next condition (will be ignored if no more conditions are added)
    9  execCondition.isConjunctionConnection = isConjunction

Margin Conditions

  • MarginCondition marginCondition = (MarginCondition)OrderCondition.Create(OrderConditionType.Margin);
    //If margin is above/below
    marginCondition.IsMore = isMore;
    //given percent
    marginCondition.Percent = percent;
    //AND | OR next condition (will be ignored if no more conditions are added)
    marginCondition.IsConjunctionConnection = isConjunction;
  • MarginCondition marginCondition = (MarginCondition)OrderCondition.create(OrderConditionType.Margin);
    //If margin is above/below
    marginCondition.isMore(isMore);
    //given percent
    marginCondition.percent(percent);
    //AND | OR next condition (will be ignored if no more conditions are added)
    marginCondition.conjunctionConnection(isConjunction);
  • Dim _MarginCondition As MarginCondition = OrderCondition.Create(OrderConditionType.Margin) ' cast to (MarginCondition)
    'If margin Is above/below
    _MarginCondition.IsMore = isMore
    'given percent
    _MarginCondition.Percent = percent
    'And | Or next condition (will be ignored if no more conditions are added)
    _MarginCondition.IsConjunctionConnection = isConjunction
  • MarginCondition* marginCondition = dynamic_cast<MarginCondition *>(OrderCondition::create(OrderCondition::OrderConditionType::Margin));
    //If margin is above/below
    marginCondition->percent(percent);
    //given percent
    marginCondition->isMore(isMore);
    //AND | OR next condition (will be ignored if no more conditions are added)
    marginCondition->conjunctionConnection(isConjunction);
  • 1  marginCondition = order_condition.Create(OrderCondition.Margin)
    2  #If margin is above/below
    3  marginCondition.isMore = isMore
    4  #given percent
    5  marginCondition.percent = percent
    6  #AND | OR next condition (will be ignored if no more conditions are added)
    7  marginCondition.isConjunctionConnection = isConjunction

Percentage Conditions

  • PercentChangeCondition pctChangeCondition = (PercentChangeCondition)OrderCondition.Create(OrderConditionType.PercentCange);
    //If there is a price percent change measured against last close price above or below...
    pctChangeCondition.IsMore = isMore;
    //this amount...
    pctChangeCondition.ChangePercent = pctChange;
    //on this contract
    pctChangeCondition.ConId = conId;
    //when traded on this exchange...
    pctChangeCondition.Exchange = exchange;
    //AND | OR next condition (will be ignored if no more conditions are added)
    pctChangeCondition.IsConjunctionConnection = isConjunction;
  • PercentChangeCondition pctChangeCondition = (PercentChangeCondition)OrderCondition.create(OrderConditionType.PercentChange);
    //If there is a price percent change measured against last close price above or below...
    pctChangeCondition.isMore(isMore);
    //this amount...
    pctChangeCondition.changePercent(pctChange);
    //on this contract
    pctChangeCondition.conId(conId);
    //when traded on this exchange...
    pctChangeCondition.exchange(exchange);
    //AND | OR next condition (will be ignored if no more conditions are added)
    pctChangeCondition.conjunctionConnection(isConjunction);
  • Dim pctChangeCondition As PercentChangeCondition = OrderCondition.Create(OrderConditionType.PercentCange) 'cast (PercentChangeCondition)
    'If there Is a price percent change measured against last close price above Or below...
    pctChangeCondition.IsMore = isMore
    'this amount...
    pctChangeCondition.ChangePercent = pctChange
    'on this contract
    pctChangeCondition.ConId = conId
    'when traded on this exchange...
    pctChangeCondition.Exchange = exchange
    'And | Or next condition (will be ignored if no more conditions are added)
    pctChangeCondition.IsConjunctionConnection = isConjunction
  • PercentChangeCondition* pctChangeCondition = dynamic_cast<PercentChangeCondition *>(OrderCondition::create(OrderCondition::OrderConditionType::PercentChange));
    //If there is a price percent change measured against last close price above or below...
    pctChangeCondition->isMore(isMore);
    //this amount...
    pctChangeCondition->changePercent(pctChange);
    //on this contract
    pctChangeCondition->conId(conId);
    //when traded on this exchange...
    pctChangeCondition->exchange(exchange);
    //AND | OR next condition (will be ignored if no more conditions are added)
    pctChangeCondition->conjunctionConnection(isConjunction);
  • 1  pctChangeCondition = order_condition.Create(OrderCondition.PercentChange)
    2  #If there is a price percent change measured against last close price above or below...
    3  pctChangeCondition.isMore = isMore
    4  #this amount...
    5  pctChangeCondition.changePercent = pctChange
    6  #on this contract
    7  pctChangeCondition.conId = conId
    8  #when traded on this exchange...
    9  pctChangeCondition.exchange = exchange
    10  #AND | OR next condition (will be ignored if no more conditions are added)
    11  pctChangeCondition.isConjunctionConnection = isConjunction

Time Conditions

  • TimeCondition timeCondition = (TimeCondition)OrderCondition.Create(OrderConditionType.Time);
    //Before or after...
    timeCondition.IsMore = isMore;
    //this time..
    timeCondition.Time = time;
    //AND | OR next condition (will be ignored if no more conditions are added)
    timeCondition.IsConjunctionConnection = isConjunction;
  • TimeCondition timeCondition = (TimeCondition)OrderCondition.create(OrderConditionType.Time);
    //Before or after...
    timeCondition.isMore(isMore);
    //this time...
    timeCondition.time(time);
    //AND | OR next condition (will be ignored if no more conditions are added)
    timeCondition.conjunctionConnection(isConjunction);
  • Dim _TimeCondition As TimeCondition = OrderCondition.Create(OrderConditionType.Time) 'cast (timeCondition)
    'Before Or after...
    _TimeCondition.IsMore = isMore
    'this time..
    _TimeCondition.Time = time
    'And | Or next condition (will be ignored if no more conditions are added)
    _TimeCondition.IsConjunctionConnection = isConjunction
  • TimeCondition* timeCondition = dynamic_cast<TimeCondition *>(OrderCondition::create(OrderCondition::OrderConditionType::Time));
    //Before or after...
    timeCondition->isMore(isMore);
    //this time..
    timeCondition->time(time);
    //AND | OR next condition (will be ignored if no more conditions are added)
    timeCondition->conjunctionConnection(isConjunction);
  • 1  timeCondition = order_condition.Create(OrderCondition.Time)
    2  #Before or after...
    3  timeCondition.isMore = isMore
    4  #this time..
    5  timeCondition.time = time
    6  #AND | OR next condition (will be ignored if no more conditions are added)
    7  timeCondition.isConjunctionConnection = isConjunction

Volume Conditions

  • VolumeCondition volCond = (VolumeCondition)OrderCondition.Create(OrderConditionType.Volume);
    //Whenever contract...
    volCond.ConId = conId;
    //When traded at
    volCond.Exchange = exchange;
    //reaches a volume higher/lower
    volCond.IsMore = isMore;
    //than this...
    volCond.Volume = volume;
    //AND | OR next condition (will be ignored if no more conditions are added)
    volCond.IsConjunctionConnection = isConjunction;
  • VolumeCondition volCon = (VolumeCondition)OrderCondition.create(OrderConditionType.Volume);
    //Whenever contract...
    volCon.conId(conId);
    //When traded at
    volCon.exchange(exchange);
    //reaches a volume higher/lower
    volCon.isMore(isMore);
    //than this...
    volCon.volume(volume);
    //AND | OR next condition (will be ignored if no more conditions are added)
    volCon.conjunctionConnection(isConjunction);
  • Dim volCond As VolumeCondition = OrderCondition.Create(OrderConditionType.Volume) 'cast (VolumeCondition)
    'Whenever contract...
    volCond.ConId = conId
    'When traded at
    volCond.Exchange = exchange
    'reaches a volume higher/lower
    volCond.IsMore = isMore
    'than this...
    volCond.Volume = volume
    'And | Or next condition (will be ignored if no more conditions are added)
    volCond.IsConjunctionConnection = isConjunction
  • VolumeCondition* volCondition = dynamic_cast<VolumeCondition *>(OrderCondition::create(OrderCondition::OrderConditionType::Volume));
    //Whenever contract...
    volCondition->conId(conId);
    //When traded at
    volCondition->exchange(exchange);
    //reaches a volume higher/lower
    volCondition->isMore(isMore);
    //than this...
    volCondition->volume(volume);
    //AND | OR next condition (will be ignored if no more conditions are added)
    volCondition->conjunctionConnection(isConjunction);
  • 1  volCond = order_condition.Create(OrderCondition.Volume)
    2  #Whenever contract...
    3  volCond.conId = conId
    4  #When traded at
    5  volCond.exchange = exchange
    6  #reaches a volume higher/lower
    7  volCond.isMore = isMore
    8  #than this...
    9  volCond.volume = volume
    10  #AND | OR next condition (will be ignored if no more conditions are added)
    11  volCond.isConjunctionConnection = isConjunction