本文整理汇总了Java中com.ib.client.EClientSocket类的典型用法代码示例。如果您正苦于以下问题:Java EClientSocket类的具体用法?Java EClientSocket怎么用?Java EClientSocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EClientSocket类属于com.ib.client包,在下文中一共展示了EClientSocket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIBSocket
import com.ib.client.EClientSocket; //导入依赖的package包/类
public static IBSocket getIBSocket(IBConnectionInfo info) {
synchronized (connectionMap) {
IBSocket savedSocket = connectionMap.get(info);
if (savedSocket == null) {
IBConnection connection = new IBConnection();
connection.setClientId(info.getClientId());
connection.setHost(info.getHost());
connection.setPort(info.getPort());
EClientSocket clientSocket = new EClientSocket(connection);
savedSocket = new IBSocket(connection, clientSocket);
connectionMap.put(info, savedSocket);
}
return savedSocket;
}
}
示例2: testTickPrice
import com.ib.client.EClientSocket; //导入依赖的package包/类
@Test
@Ignore
public void testTickPrice() throws Exception {
final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
final int tickerId = 1;
final int field = 2;
final double price = 1.23;
final int canAutoExecute = 1;
final Ticker ticker = new StockTicker("LUT");
// IBQuoteEngine ibQuoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
//
// ibQuoteEngine.idToTickerMap.put(tickerId, ticker);
// ibQuoteEngine.tickPrice(tickerId, field, price, canAutoExecute);
// Level1QuoteData quote = ibQuoteEngine.level1QuoteQueue.take();
// assertEquals( ticker, quote.getTicker() );
// assertEquals( field, quote.getField() );
// assertEquals( price, quote.getPrice(), 0 );
// assertEquals( canAutoExecute, quote.getCanAutoExecute() );
// assertEquals( 0, quote.getSize());
// mockery.assertIsSatisfied();
fail();
}
示例3: testTickSize_NullTicker
import com.ib.client.EClientSocket; //导入依赖的package包/类
@Test
@Ignore
public void testTickSize_NullTicker() throws Exception {
final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
final int tickerId = 1;
final int field = 99;
final int size = 5;
// IBQuoteEngine ibQuoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
//
// ibQuoteEngine.tickSize(tickerId, field, size);
// assertEquals( 0, ibQuoteEngine.level1QuoteQueue.size() );
//
//
// mockery.assertIsSatisfied();
fail();
}
示例4: testOverloadedTickPrice
import com.ib.client.EClientSocket; //导入依赖的package包/类
@Test
@Ignore
public void testOverloadedTickPrice() throws Exception {
final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
final int tickerId = 1;
final int field = 99;
final int size = 5;
final int canAutoExecute = 1;
final double price = 4.00;
Ticker ticker = new StockTicker("ABC");
// IBQuoteEngine ibQuoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
// ibQuoteEngine.idToTickerMap.put(tickerId, ticker);
// ibQuoteEngine.tickPrice(tickerId, field, price , 1);
// assertEquals( 1, ibQuoteEngine.level1QuoteQueue.size() );
// Level1QuoteData data = ibQuoteEngine.level1QuoteQueue.take();
// assertEquals( canAutoExecute, data.getCanAutoExecute() );
// assertEquals( field, data.getField());
// assertEquals( price, data.getPrice(), 0 );
// assertEquals( 0, data.getSize() );
// assertEquals( ticker, data.getTicker());
fail();
}
示例5: testErrorException
import com.ib.client.EClientSocket; //导入依赖的package包/类
@Test
@Ignore
public void testErrorException() throws Exception {
final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
Exception e = new Exception("Bogus Exception");
int id = 1;
int code = 1;
String message = "foo";
QuoteError quoteError = new QuoteError(id, code, message);
//
// IBQuoteEngine ibQuoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
// ibQuoteEngine.error( id, code, message );
// assertEquals( quoteError, ibQuoteEngine.quoteErrorQueue.take() );
// assertEquals( 0, ibQuoteEngine.quoteErrorQueue.size() );
fail();
}
示例6: testErrorString
import com.ib.client.EClientSocket; //导入依赖的package包/类
@Test
@Ignore
public void testErrorString() throws Exception {
final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
final String errorString = "Bogus Error";
QuoteError quoteError = new QuoteError(errorString);
//
// IBQuoteEngine ibQuoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
// ibQuoteEngine.error( errorString );
// assertEquals( quoteError, ibQuoteEngine.quoteErrorQueue.take() );
// assertEquals( 0, ibQuoteEngine.quoteErrorQueue.size() );
fail();
}
示例7: testErrorCode_Exception
import com.ib.client.EClientSocket; //导入依赖的package包/类
@Test
@Ignore
public void testErrorCode_Exception() throws Exception {
final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
final int id = 1;
final int errorCode = 2;
Exception ex = new IllegalAccessException();
QuoteError quoteError = new QuoteError(ex);
//
// IBQuoteEngine ibQuoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
// ibQuoteEngine.error( ex );
// assertEquals( quoteError, ibQuoteEngine.quoteErrorQueue.take() );
// assertEquals( 0, ibQuoteEngine.quoteErrorQueue.size() );
fail();
}
示例8: testSubscribeLevel1_alreadySubscribed
import com.ib.client.EClientSocket; //导入依赖的package包/类
@Test
@Ignore
public void testSubscribeLevel1_alreadySubscribed() {
final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
final Level1QuoteListener mockQuoteListener = mockery.mock(Level1QuoteListener.class);
final Ticker ticker = new StockTicker("LUT");
final int requestId = 1;
final Contract contract = ContractBuilderFactory.getContractBuilder(ticker).buildContract(ticker);
// IBQuoteEngine quoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
// quoteEngine.tickerMap.put(ticker, requestId);
// quoteEngine.subscribeLevel1(ticker, mockQuoteListener);
// mockery.assertIsSatisfied();
fail();
}
示例9: testUnsubscribeLevel1_NoRequestIdFound
import com.ib.client.EClientSocket; //导入依赖的package包/类
@Test
@Ignore
public void testUnsubscribeLevel1_NoRequestIdFound() {
final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
final Level1QuoteListener mockQuoteListener = mockery.mock(Level1QuoteListener.class);
final Ticker ticker = new StockTicker("LUT");
final int requestId = 1;
final Contract contract = ContractBuilderFactory.getContractBuilder(ticker).buildContract(ticker);
// IBQuoteEngine quoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
// quoteEngine.unsubscribeLevel1(ticker, mockQuoteListener);
//
// assertNull( quoteEngine.tickerMap.get(ticker) );
// assertNull( quoteEngine.idToTickerMap.get( requestId ) );
//
// mockery.assertIsSatisfied();
fail();
}
示例10: testUnsubscribeLevel1_EmptyListenerList
import com.ib.client.EClientSocket; //导入依赖的package包/类
@Test
@Ignore
public void testUnsubscribeLevel1_EmptyListenerList() {
final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
final Level1QuoteListener mockQuoteListener = mockery.mock(Level1QuoteListener.class);
final Ticker ticker = new StockTicker("LUT");
final int requestId = 1;
final Contract contract = ContractBuilderFactory.getContractBuilder(ticker).buildContract(ticker);
//
// IBQuoteEngine quoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
// quoteEngine.getLevel1ListenerMap().put(ticker, new ArrayList<Level1QuoteListener>() );
// quoteEngine.tickerMap.put(ticker, requestId);
// quoteEngine.unsubscribeLevel1(ticker, mockQuoteListener);
//
// assertNull( quoteEngine.tickerMap.get(ticker) );
// assertNull( quoteEngine.idToTickerMap.get( requestId ) );
//
// mockery.assertIsSatisfied();
fail();
}
示例11: testGetServerTime
import com.ib.client.EClientSocket; //导入依赖的package包/类
@Test
@Ignore
public void testGetServerTime() {
final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
// IBQuoteEngine quoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
// try {
// quoteEngine.getServerTime();
// fail();
// } catch( UnsupportedOperationException ex ) {
// //this should happen
// }
// mockery.assertIsSatisfied();
fail();
}
示例12: testStartEngine
import com.ib.client.EClientSocket; //导入依赖的package包/类
@Test
@Ignore
public void testStartEngine() {
final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
// IBQuoteEngine quoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
// try {
// quoteEngine.startEngine(null);
// fail();
// } catch( UnsupportedOperationException ex ) {
// //this should happen
// }
// mockery.assertIsSatisfied();
fail();
}
示例13: testStartEngine_NoArgs
import com.ib.client.EClientSocket; //导入依赖的package包/类
@Test
@Ignore
public void testStartEngine_NoArgs() {
final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
// IBQuoteEngine quoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
// quoteEngine.startEngine();
// assertTrue( quoteEngine.level1QuoteProcessor.isRunning() );
// assertTrue( quoteEngine.level2QuoteProcessor.isRunning() );
// assertTrue( quoteEngine.errorQuoteProcessor.isRunning() );
//
// mockery.assertIsSatisfied();
fail();
}
示例14: testStopEngine
import com.ib.client.EClientSocket; //导入依赖的package包/类
@Test
@Ignore
public void testStopEngine() {
final EClientSocket mockSocketInterface = mockery.mock(EClientSocket.class);
final IBConnectionInterface mockConnectionInterface = mockery.mock(IBConnectionInterface.class);
// IBQuoteEngine quoteEngine = new IBQuoteEngine(mockSocketInterface, mockConnectionInterface);
// try {
// quoteEngine.stopEngine();
// fail();
// } catch( UnsupportedOperationException ex ) {
// //this should happen
// }
// mockery.assertIsSatisfied();
fail();
}
示例15: setUp
import com.ib.client.EClientSocket; //导入依赖的package包/类
@Before
public void setUp() {
mockIbSocket = mock(IBSocket.class);
mockConnectionInterface = mock(IBConnectionInterface.class);
mockClientSocketInterface = mock(EClientSocket.class);
mockOrderEventQueue = mock(BlockingQueue.class);
when(mockIbSocket.getClientSocket()).thenReturn(mockClientSocketInterface);
when(mockIbSocket.getConnection()).thenReturn(mockConnectionInterface);
InteractiveBrokersBroker.logger = mockLogger;
broker = new InteractiveBrokersBroker(mockIbSocket);
broker.orderEventQueue = mockOrderEventQueue;
}