📄 ewrappermsggenerator.java
字号:
package com.ib.client;import java.text.DateFormat;import java.util.Date;public class EWrapperMsgGenerator extends AnyWrapperMsgGenerator { public static final String SCANNER_PARAMETERS = "SCANNER PARAMETERS:"; public static final String FINANCIAL_ADVISOR = "FA:"; static public String tickPrice( int tickerId, int field, double price, int canAutoExecute) { return "id=" + tickerId + " " + TickType.getField( field) + "=" + price + " " + ((canAutoExecute != 0) ? " canAutoExecute" : " noAutoExecute"); } static public String tickSize( int tickerId, int field, int size) { return "id=" + tickerId + " " + TickType.getField( field) + "=" + size; } static public String tickOptionComputation( int tickerId, int field, double impliedVol, double delta, double modelPrice, double pvDividend) { String toAdd = "id=" + tickerId + " " + TickType.getField( field) + ": vol = " + ((impliedVol >= 0 && impliedVol != Double.MAX_VALUE) ? Double.toString(impliedVol) : "N/A") + " delta = " + ((Math.abs(delta) <= 1) ? Double.toString(delta) : "N/A"); if (field == TickType.MODEL_OPTION) { toAdd += ": modelPrice = " + ((modelPrice >= 0 && modelPrice != Double.MAX_VALUE) ? Double.toString(modelPrice) : "N/A"); toAdd += ": pvDividend = " + ((pvDividend >= 0 && pvDividend != Double.MAX_VALUE) ? Double.toString(pvDividend) : "N/A"); } return toAdd; } static public String tickGeneric(int tickerId, int tickType, double value) { return "id=" + tickerId + " " + TickType.getField( tickType) + "=" + value; } static public String tickString(int tickerId, int tickType, String value) { return "id=" + tickerId + " " + TickType.getField( tickType) + "=" + value; } static public String tickEFP(int tickerId, int tickType, double basisPoints, String formattedBasisPoints, double impliedFuture, int holdDays, String futureExpiry, double dividendImpact, double dividendsToExpiry) { return "id=" + tickerId + " " + TickType.getField(tickType) + ": basisPoints = " + basisPoints + "/" + formattedBasisPoints + " impliedFuture = " + impliedFuture + " holdDays = " + holdDays + " futureExpiry = " + futureExpiry + " dividendImpact = " + dividendImpact + " dividends to expiry = " + dividendsToExpiry; } static public String orderStatus( int orderId, String status, int filled, int remaining, double avgFillPrice, int permId, int parentId, double lastFillPrice, int clientId, String whyHeld) { return "order status: orderId=" + orderId + " clientId=" + clientId + " permId=" + permId + " status=" + status + " filled=" + filled + " remaining=" + remaining + " avgFillPrice=" + avgFillPrice + " lastFillPrice=" + lastFillPrice + " parent Id=" + parentId + " whyHeld=" + whyHeld; } static public String openOrder( int orderId, Contract contract, Order order, OrderState orderState) { String msg = "open order: orderId=" + orderId + " action=" + order.m_action + " quantity=" + order.m_totalQuantity + " symbol=" + contract.m_symbol + " exchange=" + contract.m_exchange + " secType=" + contract.m_secType + " type=" + order.m_orderType + " lmtPrice=" + order.m_lmtPrice + " auxPrice=" + order.m_auxPrice + " TIF=" + order.m_tif + " localSymbol=" + contract.m_localSymbol + " client Id=" + order.m_clientId + " parent Id=" + order.m_parentId + " permId=" + order.m_permId + " outsideRth=" + order.m_outsideRth + " hidden=" + order.m_hidden + " discretionaryAmt=" + order.m_discretionaryAmt + " triggerMethod=" + order.m_triggerMethod + " goodAfterTime=" + order.m_goodAfterTime + " goodTillDate=" + order.m_goodTillDate + " faGroup=" + order.m_faGroup + " faMethod=" + order.m_faMethod + " faPercentage=" + order.m_faPercentage + " faProfile=" + order.m_faProfile + " shortSaleSlot=" + order.m_shortSaleSlot + " designatedLocation=" + order.m_designatedLocation + " ocaGroup=" + order.m_ocaGroup + " ocaType=" + order.m_ocaType + " rule80A=" + order.m_rule80A + " allOrNone=" + order.m_allOrNone + " minQty=" + order.m_minQty + " percentOffset=" + order.m_percentOffset + " eTradeOnly=" + order.m_eTradeOnly + " firmQuoteOnly=" + order.m_firmQuoteOnly + " nbboPriceCap=" + order.m_nbboPriceCap + " auctionStrategy=" + order.m_auctionStrategy + " startingPrice=" + order.m_startingPrice + " stockRefPrice=" + order.m_stockRefPrice + " delta=" + order.m_delta + " stockRangeLower=" + order.m_stockRangeLower + " stockRangeUpper=" + order.m_stockRangeUpper + " volatility=" + order.m_volatility + " volatilityType=" + order.m_volatilityType + " deltaNeutralOrderType=" + order.m_deltaNeutralOrderType + " deltaNeutralAuxPrice=" + order.m_deltaNeutralAuxPrice + " continuousUpdate=" + order.m_continuousUpdate + " referencePriceType=" + order.m_referencePriceType + " trailStopPrice=" + order.m_trailStopPrice + " scaleNumComponents=" + Util.IntMaxString(order.m_scaleNumComponents) + " scaleComponentSize=" + Util.IntMaxString(order.m_scaleComponentSize) + " scalePriceIncrement=" + Util.DoubleMaxString(order.m_scalePriceIncrement) + " account=" + order.m_account + " settlingFirm=" + order.m_settlingFirm + " clearingAccount=" + order.m_clearingAccount + " clearingIntent=" + order.m_clearingIntent + " whatIf=" + order.m_whatIf ; if ("BAG".equals(contract.m_secType)) { if (contract.m_comboLegsDescrip != null) { msg += " comboLegsDescrip=" + contract.m_comboLegsDescrip; } if (order.m_basisPoints != Double.MAX_VALUE) { msg += " basisPoints=" + order.m_basisPoints; msg += " basisPointsType=" + order.m_basisPointsType; } } String orderStateMsg = " status=" + orderState.m_status + " initMargin=" + orderState.m_initMargin + " maintMargin=" + orderState.m_maintMargin + " equityWithLoan=" + orderState.m_equityWithLoan + " commission=" + Util.DoubleMaxString(orderState.m_commission) + " minCommission=" + Util.DoubleMaxString(orderState.m_minCommission) + " maxCommission=" + Util.DoubleMaxString(orderState.m_maxCommission) + " commissionCurrency=" + orderState.m_commissionCurrency + " warningText=" + orderState.m_warningText ; return msg + orderStateMsg; } static public String updateAccountValue(String key, String value, String currency, String accountName) { return "updateAccountValue: " + key + " " + value + " " + currency + " " + accountName; } static public String updatePortfolio(Contract contract, int position, double marketPrice, double marketValue, double averageCost, double unrealizedPNL, double realizedPNL, String accountName) { String msg = "updatePortfolio: " + contractMsg(contract) + position + " " + marketPrice + " " + marketValue + " " + averageCost + " " + unrealizedPNL + " " + realizedPNL + " " + accountName; return msg; } static public String updateAccountTime(String timeStamp) { return "updateAccountTime: " + timeStamp; } static public String nextValidId( int orderId) { return "Next Valid Order ID: " + orderId; } static public String contractDetails(ContractDetails contractDetails) { Contract contract = contractDetails.m_summary; String msg = " ---- Contract Details begin ----\n" + contractMsg(contract) + contractDetailsMsg(contractDetails) + " ---- Contract Details End ----\n"; return msg;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -