Package com.ib.client

Examples of com.ib.client.Contract


    {
        String symbols[] = getSymbols ();
        System.out.println ("ATTEMPTING TO MONITOR " + symbols.length + " SYMBOLS");
        for (int i=0; i<symbols.length; i++)
        {
            Contract contract = new Contract ();
            contract.m_symbol = symbols[i];
            contract.m_exchange = "SMART";
            contract.m_secType = "STK";
            DataHolder holder = new DataHolder (contract, getNextID ());
            try {Thread.sleep (300);} catch (Exception e) {};
View Full Code Here


            if (retrieveUnderlyingData()) {
                if (underlyingData.isOrderCriteriaMet()) {
                    // Retrieve option contracts for underlying
                    if (retrieveOptionContracts()) {
                        // Find the one that is 1) closest strike to underlying last price, 2) expiry not within 15 days
                        Contract callContract = filterContracts("C");
                        Contract putContract = filterContracts("P");
                       
                        if (RequestIDManager.singleton().isOrderIdInitialized()) {
                            // Place buy straddle for 1 contract as market order
                            Order callOrder = createOrder("BUY", 1, "MKT");
                            Order putOrder = createOrder("BUY", 1, "MKT");
View Full Code Here

    private boolean retrieveUnderlyingData() throws InterruptedException {
        boolean isSuccess = false;
        int waitCount = 0;

        // Create a contract, with defaults...
        Contract contract = createContract(underlyingData.getSymbol());

        // Requests market data
        int requestId = RequestIDManager.singleton().getNextRequestId();
        eClientSocket.reqMktData(requestId, contract, GENERIC_TICKS, false);
View Full Code Here

    private boolean retrieveOptionContracts() throws InterruptedException {
        boolean isSuccess = false;
        int waitCount = 0;

        // Find all option contracts for underlying, will filter strike and expiry later...
        Contract contract = createContract( underlyingData.getSymbol(), "OPT",
                "SMART", "USD", null, null, 0.0);

        int requestId = RequestIDManager.singleton().getNextRequestId();
        eClientSocket.reqContractDetails(requestId, contract);
View Full Code Here

        return isSuccess;
    }

    private Contract filterContracts(String right) {
        Contract c = null;

        // First by price
        double priceDiff = 0.0;
       
        for (Contract contract : optionContracts) {
View Full Code Here

            if (retrieveUnderlyingData()) {
                if (underlyingData.isOrderCriteriaMet()) {
                    // Retrieve option contracts for underlying
                    if (retrieveOptionContracts()) {
                        // Find the one that is 1) closest strike to underlying last price, 2) expiry not within 15 days
                        Contract callContract = filterContracts("C");
                        Contract putContract = filterContracts("P");
                       
                        if (RequestIDManager.singleton().isOrderIdInitialized()) {
                            // Place buy straddle for 1 contract as market order
                            Order callOrder = createOrder("BUY", 1, "MKT");
                            Order putOrder = createOrder("BUY", 1, "MKT");
View Full Code Here

    private boolean retrieveUnderlyingData() throws InterruptedException {
        boolean isSuccess = false;
        int waitCount = 0;

        // Create a contract, with defaults...
        Contract contract = createContract(underlyingData.getSymbol());

        // Requests market data
        int requestId = RequestIDManager.singleton().getNextRequestId();
        eClientSocket.reqMktData(requestId, contract, GENERIC_TICKS, false);
View Full Code Here

    private boolean retrieveOptionContracts() throws InterruptedException {
        boolean isSuccess = false;
        int waitCount = 0;

        // Find all option contracts for underlying, will filter strike and expiry later...
        Contract contract = createContract( underlyingData.getSymbol(), "OPT",
                "SMART", "USD", null, null, 0.0);

        int requestId = RequestIDManager.singleton().getNextRequestId();
        eClientSocket.reqContractDetails(requestId, contract);
View Full Code Here

        return isSuccess;
    }

    private Contract filterContracts(String right) {
        Contract c = null;

        // First by price
        double priceDiff = 0.0;
       
        for (Contract contract : optionContracts) {
View Full Code Here

    ArrayList<Date> datesToQuery = DateUtil.getFridays(
      lastFileDate, gc.getTime());
    datesToQuery.add(gc.getTime());

    // Create a contract, with defaults...
    Contract contract = createContract(symbol);

    // iterate through dates
    for (Iterator<Date> it = datesToQuery.iterator(); it.hasNext();) {
        Date queryDate = it.next();
        String queryDateString = sdf.format(queryDate) + " CST";
View Full Code Here

TOP

Related Classes of com.ib.client.Contract

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.