当前位置: 首页>>代码示例>>Java>>正文


Java EClientSocket.eConnect方法代码示例

本文整理汇总了Java中com.ib.client.EClientSocket.eConnect方法的典型用法代码示例。如果您正苦于以下问题:Java EClientSocket.eConnect方法的具体用法?Java EClientSocket.eConnect怎么用?Java EClientSocket.eConnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ib.client.EClientSocket的用法示例。


在下文中一共展示了EClientSocket.eConnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.ib.client.EClientSocket; //导入方法依赖的package包/类
public static void main(String[] args){

        // create connection obj to TWS with noisy handler
        EClientSocket eClientSocket = new EClientSocket(new TWSClientInterface());

        // try to connect to TWS
        eClientSocket.eConnect("127.0.0.1", 7496, 0);

        // request the market depth
        eClientSocket.reqAllOpenOrders();

        // 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(8843,SPY,order);
    }
 
开发者ID:softwarespartan,项目名称:TWS,代码行数:21,代码来源:OpenOrders.java

示例2: main

import com.ib.client.EClientSocket; //导入方法依赖的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 watch
        Contract FB   = ContractFactory.GenericStockContract("FB");
        Contract BABA = ContractFactory.GenericStockContract("BABA");

        // request real-time bars
        eClientSocket.reqRealTimeBars(0,FB  ,0,"TRADES",false,new Vector<TagValue>());
        eClientSocket.reqRealTimeBars(1,BABA,0,"TRADES",false,new Vector<TagValue>());
    }
 
开发者ID:softwarespartan,项目名称:TWS,代码行数:17,代码来源:RealTimeBars.java

示例3: main

import com.ib.client.EClientSocket; //导入方法依赖的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);

        com.ib.client.ScannerSubscription scannerSubscription = new com.ib.client.ScannerSubscription();

        scannerSubscription.numberOfRows   (15);
        scannerSubscription.instrument("STK");
        scannerSubscription.scanCode("MOST_ACTIVE");
        //scannerSubscription.locationCode   ("STK.ARCA" );
        scannerSubscription.locationCode   ("STK.US");
        //scannerSubscription.stockTypeFilter("CORP,ADR,ETF,CEF,REIT");
        scannerSubscription.abovePrice              (1);
//        scannerSubscription.marketCapAbove          (0);
//        scannerSubscription.couponRateAbove         (0);
//        scannerSubscription.averageOptionVolumeAbove(0);
//        scannerSubscription.aboveVolume             (0);

        eClientSocket.reqScannerSubscription(0,scannerSubscription,null);
        //eClientSocket.reqScannerParameters();
    }
 
开发者ID:softwarespartan,项目名称:TWS,代码行数:26,代码来源:ScannerSubscription.java

示例4: main

import com.ib.client.EClientSocket; //导入方法依赖的package包/类
public static void main(String[] args) {

        // create connection obj to TWS with noisy handler
        EClientSocket eClientSocket = new EClientSocket(new TWSClientInterface());

        // try to connect to TWS
        eClientSocket.eConnect("127.0.0.1", 7496, 0);

        // initialize a contract for symbol
        Contract contract = ContractFactory.GenericStockContract("SPY");

        // set the exchange
        contract.m_exchange = "ISLAND";  contract.m_primaryExch = "ISLAND";

        // request the market depth
        eClientSocket.reqMktDepth(0, contract, 5, null);
    }
 
开发者ID:softwarespartan,项目名称:TWS,代码行数:18,代码来源:MarketDepth.java

示例5: main

import com.ib.client.EClientSocket; //导入方法依赖的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);

        // auto associate TWS order with API
        eClientSocket.reqAutoOpenOrders(true);

        // get all the execution entries so init empty filter
        ExecutionFilter filter = new ExecutionFilter();

        // request execution details
        eClientSocket.reqExecutions(0,filter);
    }
 
开发者ID:softwarespartan,项目名称:TWS,代码行数:18,代码来源:ExecutionDetails.java

示例6: main

import com.ib.client.EClientSocket; //导入方法依赖的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);
    }
 
开发者ID:softwarespartan,项目名称:TWS,代码行数:18,代码来源:OrderPlacement.java

示例7: doConnect

import com.ib.client.EClientSocket; //导入方法依赖的package包/类
protected synchronized void doConnect() {
	socket = new EClientSocket(this);
	socket.eConnect(hosts[currHost], ports[currHost], clientId);
	if (!socket.isConnected()) {
		int failedHost = currHost;
		currHost = (currHost + 1) % hosts.length;
		throw new JTradeException(String.format("Could not connect to TWS using %[email protected]%s:%s", clientId, hosts[failedHost], ports[failedHost]));
	}
	// IB Log levels: 1=SYSTEM 2=ERROR 3=WARNING 4=INFORMATION 5=DETAIL
	socket.setServerLogLevel(3);
	socket.reqNewsBulletins(true);
	serverVersion = socket.serverVersion();

	logger.info("Connected to TWS v{} using {}@{}:{}, data folder is {}",
			new Object[] { serverVersion, clientId, hosts[currHost], ports[currHost], dataDir.getAbsolutePath() });
}
 
开发者ID:klon,项目名称:jtrade,代码行数:17,代码来源:IBMarketFeed.java

示例8: main

import com.ib.client.EClientSocket; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
	EWrapperImpl wrapper = new EWrapperImpl();
	
	final EClientSocket m_client = wrapper.getClient();
	final EReaderSignal m_signal = wrapper.getSignal();
	//! [connect]
	m_client.eConnect("127.0.0.1", 7496, 0);
	//! [connect]
	//! [ereader]
	final EReader reader = new EReader(m_client, m_signal);        
       reader.start();        
       new Thread() {
       	public void run() {
       		while (m_client.isConnected()) {
    			m_signal.waitForSignal();
   				try {
   					reader.processMsgs();
   				} catch (Exception e) {
   					System.out.println("Exception: "+e.getMessage());
   				}
       		}
       	}
       }.start();
       //! [ereader]
       Thread.sleep(1000);
	
	//orderOperations(wrapper.getClient(), wrapper.getCurrentOrderId());
	//contractOperations(wrapper.getClient());
       //hedgeSample(wrapper.getClient(), wrapper.getCurrentOrderId());
       //testAlgoSamples(wrapper.getClient(), wrapper.getCurrentOrderId());
       //bracketSample(wrapper.getClient(), wrapper.getCurrentOrderId());
	//bulletins(wrapper.getClient());
       //reutersFundamentals(wrapper.getClient());
       //marketDataType(wrapper.getClient());
       //historicalDataRequests(wrapper.getClient());
       //accountOperations(wrapper.getClient());
	
	Thread.sleep(100000);
	m_client.eDisconnect();
}
 
开发者ID:qerio,项目名称:goib,代码行数:41,代码来源:Testbed.java

示例9: main

import com.ib.client.EClientSocket; //导入方法依赖的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 watch
        Contract contract = ContractFactory.GenericStockContract("SPY");

        // set the exchange
        contract.m_exchange = "ARCA"; contract.m_primaryExch = "ARCA";

        // specify all the generic tick data we're interested in
        String genericTickList = "100,101,105,106,107,125,165,166," +
                                 "225,232,221,233,236,258,47,291," +
                                 "293,294,295,318,370,370,377,377," +
                                 "381,384,384,387,388,391,407,411," +
                                 "428,439,439,456,59,459,460,499," +
                                 "506,511,512,104,513,514,515,516,517";

        // realistically maybe something like 100,101,106,233

        // start the market data subscription for the contract
        eClientSocket.reqMktData(0,contract,genericTickList,false,null);
    }
 
开发者ID:softwarespartan,项目名称:TWS,代码行数:28,代码来源:MarketData.java

示例10: main

import com.ib.client.EClientSocket; //导入方法依赖的package包/类
public static void main(String[] args){

        // create connection obj to TWS with noisy handler
        EClientSocket eClientSocket = new EClientSocket(new TWSClientInterface());

        // try to connect to TWS
        eClientSocket.eConnect("127.0.0.1", 7496, 0);

        // sign up for order info
        //eClientSocket.reqAllOpenOrders();

        // nuke all orders
        eClientSocket.reqGlobalCancel();
    }
 
开发者ID:softwarespartan,项目名称:TWS,代码行数:15,代码来源:CancelAllOrders.java

示例11: main

import com.ib.client.EClientSocket; //导入方法依赖的package包/类
public static void main(String[] args){
    // create connection obj to TWS with noisy handler
    EClientSocket eClientSocket = new EClientSocket(new TWSClientInterface());

    // try to connect to TWS
    eClientSocket.eConnect("127.0.0.1", 7496, 0);

    // request the market depth
    eClientSocket.reqNewsBulletins(true);
}
 
开发者ID:softwarespartan,项目名称:TWS,代码行数:11,代码来源:NewsBulletin.java

示例12: main

import com.ib.client.EClientSocket; //导入方法依赖的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);

        // request account summary
        eClientSocket.reqAccountUpdates(true,"DU207406");
    }
 
开发者ID:softwarespartan,项目名称:TWS,代码行数:12,代码来源:AccountUpdates.java

示例13: main

import com.ib.client.EClientSocket; //导入方法依赖的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);

        // ask for the next order id
        //eClientSocket.reqIds(1);
    }
 
开发者ID:softwarespartan,项目名称:TWS,代码行数:12,代码来源:NextOrderId.java

示例14: main

import com.ib.client.EClientSocket; //导入方法依赖的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);

        // request account summary
        eClientSocket.reqPositions();
    }
 
开发者ID:softwarespartan,项目名称:TWS,代码行数:12,代码来源:Positions.java

示例15: main

import com.ib.client.EClientSocket; //导入方法依赖的package包/类
public static void main(String[] args){

        // create TWS connection object linked to message handler interface
        EClientSocket eClientSocket = new EClientSocket(new TWSClientInterface());

        // try to connect to TWS
        eClientSocket.eConnect("127.0.0.1",7496,0);

        // create a generic contract for getting historical data
        Contract FB   = ContractFactory.GenericStockContract("FB");

        // make the request for some data for this contract
        eClientSocket.reqHistoricalData(1000001,FB,"20141128 16:00:00","1 Y","1 day","TRADES",0,1,null);
    }
 
开发者ID:softwarespartan,项目名称:TWS,代码行数:15,代码来源:HistoricalData.java


注:本文中的com.ib.client.EClientSocket.eConnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。