📄 ereader.java
字号:
order.m_allOrNone = readBoolFromInt(); order.m_minQty = readInt(); order.m_ocaType = readInt(); order.m_eTradeOnly = readBoolFromInt(); order.m_firmQuoteOnly = readBoolFromInt(); order.m_nbboPriceCap = readDouble(); } if ( version >= 10) { order.m_parentId = readInt(); order.m_triggerMethod = readInt(); } if (version >= 11) { order.m_volatility = readDouble(); order.m_volatilityType = readInt(); if (version == 11) { int receivedInt = readInt(); order.m_deltaNeutralOrderType = ( (receivedInt == 0) ? "NONE" : "MKT" ); } else { // version 12 and up order.m_deltaNeutralOrderType = readStr(); order.m_deltaNeutralAuxPrice = readDouble(); } order.m_continuousUpdate = readInt(); if (m_parent.serverVersion() == 26) { order.m_stockRangeLower = readDouble(); order.m_stockRangeUpper = readDouble(); } order.m_referencePriceType = readInt(); } if (version >= 13) { order.m_trailStopPrice = readDouble(); } if (version >= 14) { order.m_basisPoints = readDouble(); order.m_basisPointsType = readInt(); contract.m_comboLegsDescrip = readStr(); } if (version >= 15) { order.m_scaleNumComponents = readIntMax(); order.m_scaleComponentSize = readIntMax(); order.m_scalePriceIncrement = readDoubleMax(); } if (version >= 19) { order.m_clearingAccount = readStr(); order.m_clearingIntent = readStr(); } OrderState orderState = new OrderState(); if (version >= 16) { order.m_whatIf = readBoolFromInt(); orderState.m_status = readStr(); orderState.m_initMargin = readStr(); orderState.m_maintMargin = readStr(); orderState.m_equityWithLoan = readStr(); orderState.m_commission = readDoubleMax(); orderState.m_minCommission = readDoubleMax(); orderState.m_maxCommission = readDoubleMax(); orderState.m_commissionCurrency = readStr(); orderState.m_warningText = readStr(); } eWrapper().openOrder( order.m_orderId, contract, order, orderState); break; } case NEXT_VALID_ID: { int version = readInt(); int orderId = readInt(); eWrapper().nextValidId( orderId); break; } case SCANNER_DATA: { ContractDetails contract = new ContractDetails(); int version = readInt(); int tickerId = readInt(); int numberOfElements = readInt(); for (int ctr=0; ctr < numberOfElements; ctr++) { int rank = readInt(); if (version >= 3) { contract.m_summary.m_conId = readInt(); } contract.m_summary.m_symbol = readStr(); contract.m_summary.m_secType = readStr(); contract.m_summary.m_expiry = readStr(); contract.m_summary.m_strike = readDouble(); contract.m_summary.m_right = readStr(); contract.m_summary.m_exchange = readStr(); contract.m_summary.m_currency = readStr(); contract.m_summary.m_localSymbol = readStr(); contract.m_marketName = readStr(); contract.m_tradingClass = readStr(); String distance = readStr(); String benchmark = readStr(); String projection = readStr(); String legsStr = null; if (version >= 2) { legsStr = readStr(); } eWrapper().scannerData(tickerId, rank, contract, distance, benchmark, projection, legsStr); } eWrapper().scannerDataEnd(tickerId); break; } case CONTRACT_DATA: { int version = readInt(); ContractDetails contract = new ContractDetails(); contract.m_summary.m_symbol = readStr(); contract.m_summary.m_secType = readStr(); contract.m_summary.m_expiry = readStr(); contract.m_summary.m_strike = readDouble(); contract.m_summary.m_right = readStr(); contract.m_summary.m_exchange = readStr(); contract.m_summary.m_currency = readStr(); contract.m_summary.m_localSymbol = readStr(); contract.m_marketName = readStr(); contract.m_tradingClass = readStr(); contract.m_summary.m_conId = readInt(); contract.m_minTick = readDouble(); contract.m_summary.m_multiplier = readStr(); contract.m_orderTypes = readStr(); contract.m_validExchanges = readStr(); if (version >= 2) { contract.m_priceMagnifier = readInt(); } eWrapper().contractDetails( contract); break; } case BOND_CONTRACT_DATA: { int version = readInt(); ContractDetails contract = new ContractDetails(); contract.m_summary.m_symbol = readStr(); contract.m_summary.m_secType = readStr(); contract.m_cusip = readStr(); contract.m_coupon = readDouble(); contract.m_maturity = readStr(); contract.m_issueDate = readStr(); contract.m_ratings = readStr(); contract.m_bondType = readStr(); contract.m_couponType = readStr(); contract.m_convertible = readBoolFromInt(); contract.m_callable = readBoolFromInt(); contract.m_putable = readBoolFromInt(); contract.m_descAppend = readStr(); contract.m_summary.m_exchange = readStr(); contract.m_summary.m_currency = readStr(); contract.m_marketName = readStr(); contract.m_tradingClass = readStr(); contract.m_summary.m_conId = readInt(); contract.m_minTick = readDouble(); contract.m_orderTypes = readStr(); contract.m_validExchanges = readStr(); if (version >= 2) { contract.m_nextOptionDate = readStr(); contract.m_nextOptionType = readStr(); contract.m_nextOptionPartial = readBoolFromInt(); contract.m_notes = readStr(); } eWrapper().bondContractDetails( contract); break; } case EXECUTION_DATA: { int version = readInt(); int orderId = readInt(); // read contract fields Contract contract = new Contract(); if (version >= 5) { contract.m_conId = readInt(); } contract.m_symbol = readStr(); contract.m_secType = readStr(); contract.m_expiry = readStr(); contract.m_strike = readDouble(); contract.m_right = readStr(); contract.m_exchange = readStr(); contract.m_currency = readStr(); contract.m_localSymbol = readStr(); Execution exec = new Execution(); exec.m_orderId = orderId; exec.m_execId = readStr(); exec.m_time = readStr(); exec.m_acctNumber = readStr(); exec.m_exchange = readStr(); exec.m_side = readStr(); exec.m_shares = readInt(); exec.m_price = readDouble(); if ( version >= 2 ) { exec.m_permId = readInt(); } if ( version >= 3) { exec.m_clientId = readInt(); } if ( version >= 4) { exec.m_liquidation = readInt(); } eWrapper().execDetails( orderId, contract, exec); break; } case MARKET_DEPTH: { int version = readInt(); int id = readInt(); int position = readInt(); int operation = readInt(); int side = readInt(); double price = readDouble(); int size = readInt(); eWrapper().updateMktDepth(id, position, operation, side, price, size); break; } case MARKET_DEPTH_L2: { int version = readInt(); int id = readInt(); int position = readInt(); String marketMaker = readStr(); int operation = readInt(); int side = readInt(); double price = readDouble(); int size = readInt(); eWrapper().updateMktDepthL2(id, position, marketMaker, operation, side, price, size); break; } case NEWS_BULLETINS: { int version = readInt(); int newsMsgId = readInt(); int newsMsgType = readInt(); String newsMessage = readStr(); String originatingExch = readStr(); eWrapper().updateNewsBulletin( newsMsgId, newsMsgType, newsMessage, originatingExch); break; } case MANAGED_ACCTS: { int version = readInt(); String accountsList = readStr(); eWrapper().managedAccounts( accountsList); break; } case RECEIVE_FA: { int version = readInt(); int faDataType = readInt(); String xml = readStr(); eWrapper().receiveFA(faDataType, xml); break; } case HISTORICAL_DATA: { int version = readInt(); int reqId = readInt(); String startDateStr; String endDateStr; String completedIndicator = "finished"; if (version >= 2) { startDateStr = readStr(); endDateStr = readStr(); completedIndicator += "-" + startDateStr + "-" + endDateStr; } int itemCount = readInt(); for (int ctr = 0; ctr < itemCount; ctr++) { String date = readStr(); double open = readDouble(); double high = readDouble(); double low = readDouble(); double close = readDouble(); int volume = readInt(); double WAP = readDouble(); String hasGaps = readStr(); int barCount = -1; if (version >= 3) { barCount = readInt(); } eWrapper().historicalData(reqId, date, open, high, low, close, volume, barCount, WAP, Boolean.valueOf(hasGaps).booleanValue()); } // send end of dataset marker eWrapper().historicalData(reqId, completedIndicator, -1, -1, -1, -1, -1, -1, -1, false); break; } case SCANNER_PARAMETERS: { int version = readInt(); String xml = readStr(); eWrapper().scannerParameters(xml); break; } case CURRENT_TIME: { /*int version =*/ readInt(); long time = readLong(); eWrapper().currentTime(time); break; } case REAL_TIME_BARS: { /*int version =*/ readInt(); int reqId = readInt(); long time = readLong(); double open = readDouble(); double high = readDouble(); double low = readDouble(); double close = readDouble(); long volume = readLong(); double wap = readDouble(); int count = readInt(); eWrapper().realtimeBar(reqId, time, open, high, low, close, volume, wap, count); break; } default: { m_parent.error( EClientErrors.NO_VALID_ID, EClientErrors.UNKNOWN_ID.code(), EClientErrors.UNKNOWN_ID.msg()); return false; } } return true; } protected String readStr() throws IOException { StringBuffer buf = new StringBuffer(); while( true) { byte c = m_dis.readByte(); if( c == 0) { break; } buf.append( (char)c); } String str = buf.toString(); return str.length() == 0 ? null : str; } boolean readBoolFromInt() throws IOException { String str = readStr(); return str == null ? false : (Integer.parseInt( str) != 0); } protected int readInt() throws IOException { String str = readStr(); return str == null ? 0 : Integer.parseInt( str); } protected int readIntMax() throws IOException { String str = readStr(); return (str == null || str.length() == 0) ? Integer.MAX_VALUE : Integer.parseInt( str); } protected long readLong() throws IOException { String str = readStr(); return str == null ? 0l : Long.parseLong(str); } protected double readDouble() throws IOException { String str = readStr(); return str == null ? 0 : Double.parseDouble( str); } protected double readDoubleMax() throws IOException { String str = readStr(); return (str == null || str.length() == 0) ? Double.MAX_VALUE : Double.parseDouble( str); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -