本文整理汇总了Java中com.ib.client.Order类的典型用法代码示例。如果您正苦于以下问题:Java Order类的具体用法?Java Order怎么用?Java Order使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Order类属于com.ib.client包,在下文中一共展示了Order类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AdjustedPanel
import com.ib.client.Order; //导入依赖的package包/类
public AdjustedPanel(JDialog parentDlg, Order order) {
m_parentDlg = parentDlg;
m_order = order;
m_adjustedOrderType.setSelectedItem(m_order.adjustedOrderType());
m_triggerPrice.setText(m_order.triggerPrice());
m_adjustedStopPrice.setText(m_order.adjustedStopPrice());
m_adjustedStopLimitPrice.setText(m_order.adjustedStopLimitPrice());
m_adjustedTrailingAmount.setText(m_order.adjustedTrailingAmount());
m_adjustedTrailingAmountUnit.setSelectedItem(AmntUnit.fromInt(m_order.adjustableTrailingUnit()));
add("Adjust to order type", m_adjustedOrderType);
add("Trigger price", m_triggerPrice);
add("Adjusted stop price", m_adjustedStopPrice);
add("Adjusted stop limit price", m_adjustedStopLimitPrice);
add("Adjusted trailing amount", m_adjustedTrailingAmount);
add("Adjusted trailing amount unit", m_adjustedTrailingAmountUnit);
}
示例2: PegBenchPanel
import com.ib.client.Order; //导入依赖的package包/类
public PegBenchPanel(JDialog parentDlg, Order order, ContractLookuper lookuper) {
m_parentDlg = parentDlg;
m_order = order;
m_startingPrice.setText(m_order.startingPrice());
m_startingRefPrice.setText(m_order.stockRefPrice());
m_pegChangeAmount.setText(m_order.peggedChangeAmount());
m_refChangeAmount.setText(m_order.referenceChangeAmount());
m_pegChangeType.setSelectedIndex(m_order.isPeggedChangeAmountDecrease() ? 1 : 0);
m_refCon = new ContractLookupButton(m_order.referenceContractId(), m_order.referenceExchangeId(), lookuper) {
@Override
protected void actionPerformed(int refConId, String refExchId) {
PegBenchPanel.this.m_order.referenceContractId(refConId);
PegBenchPanel.this.m_order.referenceExchangeId(refExchId);
};
};
add("Starting price", m_startingPrice);
add("Reference contract", m_refCon);
add("Starting reference price", m_startingRefPrice);
add("Pegged change amount", m_pegChangeAmount);
add("Pegged change type", m_pegChangeType);
add("Reference change amount", m_refChangeAmount);
}
示例3: onAttachOrder
import com.ib.client.Order; //导入依赖的package包/类
protected void onAttachOrder() {
OrderRow row = getSelectedOrder();
if (row != null) {
Order parent = row.m_order;
Order child = new Order();
child.parentId( parent.orderId() );
child.action( parent.action() );
child.totalQuantity( parent.totalQuantity() );
child.orderType( OrderType.TRAIL);
child.auxPrice( 1);
TicketDlg dlg = new TicketDlg( row.m_contract.clone(), child);
dlg.setVisible( true);
}
}
示例4: getValueAt
import com.ib.client.Order; //导入依赖的package包/类
@Override public Object getValueAt(int row, int col) {
OrderRow fullOrder = m_orders.get( row);
Order order = fullOrder.m_order;
switch( col) {
case 0: return order.permId();
case 1: return order.clientId();
case 2: return order.orderId();
case 3: return order.account();
case 4: return order.modelCode();
case 5: return order.action();
case 6: return order.totalQuantity();
case 7: return fullOrder.m_contract.description();
case 8: return fullOrder.m_state.status();
default: return null;
}
}
示例5: placeOrder
import com.ib.client.Order; //导入依赖的package包/类
void placeOrder(boolean whatIf) {
// run m_orderDlg
m_orderDlg.init("Order Misc Options", true, "Order Misc Options", m_orderDlg.m_order.orderMiscOptions());
m_orderDlg.show();
if( !m_orderDlg.m_rc ) {
return;
}
Order order = m_orderDlg.m_order;
order.orderMiscOptions(m_orderDlg.getOptions());
// save old and set new value of whatIf attribute
boolean savedWhatIf = order.whatIf();
order.whatIf(whatIf);
// place order
m_client.placeOrder( m_orderDlg.m_id, m_orderDlg.m_contract, order );
// restore whatIf attribute
order.whatIf(savedWhatIf);
}
示例6: OcaSample
import com.ib.client.Order; //导入依赖的package包/类
private static void OcaSample(EClientSocket client, int nextOrderId) {
//OCA order
//! [ocasubmit]
List<Order> OcaOrders = new ArrayList<Order>();
OcaOrders.add(OrderSamples.LimitOrder("BUY", 1, 10));
OcaOrders.add(OrderSamples.LimitOrder("BUY", 1, 11));
OcaOrders.add(OrderSamples.LimitOrder("BUY", 1, 12));
OcaOrders = OrderSamples.OneCancelsAll("TestOCA_" + nextOrderId, OcaOrders, 2);
for (Order o : OcaOrders) {
client.placeOrder(nextOrderId++, ContractSamples.USStock(), o);
}
//! [ocasubmit]
}
示例7: conditionSamples
import com.ib.client.Order; //导入依赖的package包/类
private static void conditionSamples(EClientSocket client, int nextOrderId) {
//! [order_conditioning_activate]
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_conditioning_activate]
//Conditions can make the order active or cancel it. Only LMT orders can be conditionally canceled.
//! [order_conditioning_cancel]
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_conditioning_cancel]
}
示例8: hedgeSample
import com.ib.client.Order; //导入依赖的package包/类
private static void hedgeSample(EClientSocket client, int nextOrderId) throws InterruptedException {
//F Hedge order
//! [hedgesubmit]
//Parent order on a contract which currency differs from your base currency
Order parent = OrderSamples.LimitOrder("BUY", 100, 10);
parent.orderId(nextOrderId++);
//Hedge on the currency conversion
Order hedge = OrderSamples.MarketFHedge(parent.orderId(), "BUY");
//Place the parent first...
client.placeOrder(parent.orderId(), ContractSamples.EuropeanStock(), parent);
//Then the hedge order
client.placeOrder(nextOrderId++, ContractSamples.EurGbpFx(), hedge);
//! [hedgesubmit]
}
示例9: FillAccumulateDistributeParams
import com.ib.client.Order; //导入依赖的package包/类
public static void FillAccumulateDistributeParams(Order baseOrder, int componentSize, int timeBetweenOrders, boolean randomizeTime20, boolean randomizeSize55,
int giveUp, boolean catchUp, boolean waitOrFill, String startTime, String endTime) {
baseOrder.algoStrategy("AD");
baseOrder.algoParams(new ArrayList<TagValue>());
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("waitOrFill", waitOrFill ? "1" : "0"));
baseOrder.algoParams().add(new TagValue("startTime", startTime));
baseOrder.algoParams().add(new TagValue("endTime", endTime));
}
示例10: LimitOrderForComboWithLegPrices
import com.ib.client.Order; //导入依赖的package包/类
public static Order LimitOrderForComboWithLegPrices(String action, double quantity, boolean nonGuaranteed, double[] legPrices) {
// ! [limitordercombolegprices]
Order order = new Order();
order.action(action);
order.orderType("LMT");
order.totalQuantity(quantity);
order.orderComboLegs(new ArrayList<OrderComboLeg>());
for(double price : legPrices) {
OrderComboLeg comboLeg = new OrderComboLeg();
comboLeg.price(5.0);
order.orderComboLegs().add(comboLeg);
}
if (nonGuaranteed)
{
List<TagValue> smartComboRoutingParams = new ArrayList<TagValue>();
smartComboRoutingParams.add(new TagValue("NonGuaranteed", "1"));
}
// ! [limitordercombolegprices]
return order;
}
示例11: AttachAdjustableToStop
import com.ib.client.Order; //导入依赖的package包/类
public static Order AttachAdjustableToStop(Order parent, double attachedOrderStopPrice, double triggerPrice, double adjustStopPrice) {
//! [adjustable_stop]
Order order = new Order();
//Attached order is a conventional STP order in opposite direction
order.action(parent.action().equals("BUY") ? "SELL" : "BUY");
order.totalQuantity(parent.totalQuantity());
order.auxPrice(attachedOrderStopPrice);
order.parentId(parent.orderId());
//When trigger price is penetrated
order.triggerPrice(triggerPrice);
//The parent order will be turned into a STP order
order.adjustedOrderType(OrderType.STP);
//With the given STP price
order.adjustedStopPrice(adjustStopPrice);
//! [adjustable_stop]
return order;
}
示例12: AttachAdjustableToStopLimit
import com.ib.client.Order; //导入依赖的package包/类
public static Order AttachAdjustableToStopLimit(Order parent, double attachedOrderStopPrice, double triggerPrice, double adjustStopPrice, double adjustedStopLimitPrice) {
//! [adjustable_stop_limit]
Order order = new Order();
//Attached order is a conventional STP order
order.action(parent.action().equals("BUY") ? "SELL" : "BUY");
order.totalQuantity(parent.totalQuantity());
order.auxPrice(attachedOrderStopPrice);
order.parentId(parent.orderId());
//When trigger price is penetrated
order.triggerPrice(triggerPrice);
//The parent order will be turned into a STP LMT order
order.adjustedOrderType(OrderType.STP_LMT);
//With the given stop price
order.adjustedStopPrice(adjustStopPrice);
//And the given limit price
order.adjustedStopLimitPrice(adjustedStopLimitPrice);
//! [adjustable_stop_limit]
return order;
}
示例13: AttachAdjustableToTrail
import com.ib.client.Order; //导入依赖的package包/类
public static Order AttachAdjustableToTrail(Order parent, double attachedOrderStopPrice, double triggerPrice, double adjustStopPrice, double adjustedTrailAmount, int trailUnit) {
//! [adjustable_trail]
Order order = new Order();
//Attached order is a conventional STP order
order.action(parent.action().equals("BUY") ? "SELL" : "BUY");
order.totalQuantity(parent.totalQuantity());
order.auxPrice(attachedOrderStopPrice);
order.parentId(parent.orderId());
//When trigger price is penetrated
order.triggerPrice(triggerPrice);
//The parent order will be turned into a TRAIL order
order.adjustedOrderType(OrderType.TRAIL);
//With a stop price of...
order.adjustedStopPrice(adjustStopPrice);
//traling by and amount (0) or a percent (1)...
order.adjustableTrailingUnit(trailUnit);
//of...
order.adjustedTrailingAmount(adjustedTrailAmount);
//! [adjustable_trail]
return order;
}
示例14: isUnknownOrder
import com.ib.client.Order; //导入依赖的package包/类
private boolean isUnknownOrder(OrderRecord orderRecord) {
if (orderRecord == null
|| !orderRecord.isSubmitted()
|| orderRecord.isWorking()) {
return false;
}
int orderId = orderRecord.getOrderId();
for (Order order : openOrders) {
if (orderId == order.m_orderId) {
return false;
}
}
log(Level.WARNING, "Unknown order is found: #{0}", orderId);
return true;
}
示例15: main
import com.ib.client.Order; //导入依赖的package包/类
public static void main(String[] args) {
// create connection object for to communicate with TWS
EClientSocket eClientSocket = new EClientSocket(new TWSClientInterface());
// try to connect to TWS
eClientSocket.eConnect("127.0.0.1", 7496, 0);
// initialize a contract for symbols to BUY
Contract SPY = ContractFactory.GenericStockContract("SPY");
// create an order to specify account info, order type, price, etc
Order order = OrderFactory.GenericLimitOrder("DU207406", "BUY", 100, 198.5);
// place the order
eClientSocket.placeOrder(8840,SPY,order);
}