Package com.ib.client

Examples of com.ib.client.Contract


            // Make connection
            connectToTWS();

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

            // Requests snapshot market data
            eClientSocket.reqMktData(requestId++, contract, null, true);

            while (!isSuccess && waitCount < MAX_WAIT_COUNT) {
View Full Code Here


       
    }

    protected Contract createContract(String symbol, String securityType, String exchange, String currency, String expiry, String right, double strike) {
        Contract contract = new Contract();

        contract.m_symbol = symbol;
        contract.m_secType = securityType;
        contract.m_exchange = exchange;
        contract.m_currency = currency;
View Full Code Here

            // Make connection
            connectToTWS();

            // Create a contract, with defaults...
            Contract contract =
            createContract( symbol, "STK", "SMART", "USD", null, null, 0.0);
            //IND, STK
            //SMART, "NYSE"
            // Requests snapshot market data
//            eClientSocket.reqMktData(requestId++, contract, null, true);
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(), "STK", "SMART", "USD");

        // 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");

        int requestId = RequestIDManager.singleton().getNextRequestId();
        eClientSocket.reqContractDetails(requestId, contract);

        while (!isSuccess && waitCount < MAX_WAIT_COUNT) {
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(), "STK", "SMART", "USD");

        // 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");

        int requestId = RequestIDManager.singleton().getNextRequestId();
        eClientSocket.reqContractDetails(requestId, contract);

        while (!isSuccess && waitCount < MAX_WAIT_COUNT) {
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.