Subversion Repositories Integrator Subversion

Rev

Rev 796 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

package br.com.kronus.ibkr.api;

import com.ib.client.Contract;

/**
 * Responsável por criar Contracts da IBKR a partir dos símbolos usados no sistema.
 * Ajuste conforme o universo de ativos que você for operar.
 */

public class IbkrMapper {

    /**
     * Exemplo para AÇÃO negociada na B3.
     */

        public static Contract contratoAcaoBrasil2(String symbol) {
            Contract c = new Contract();
            c.symbol(symbol);          // "PETR4", "VALE3", etc.
            c.secType("STK");
            c.currency("BRL");

            // Forma mais comum que a IB documenta para B3:
            c.exchange("SMART");       // roteamento inteligente
            c.primaryExch("BVMF");     // B3

            return c;
        }
       
        public static Contract contratoAcaoBrasil(String symbol) {
            Contract c = new Contract();
            c.symbol(symbol);
            c.secType("STK");
            c.currency("BRL");
            c.exchange("B3");      // teste direto BVMF
            // c.primaryExch("BVMF"); // teste com e sem
            return c;
        }


    /**
     * Exemplo para FUTURO de índice (mini índice, etc.).
     * Ajuste localSymbol/lastTradeDateOrContractMonth conforme a IBKR.
     */

    public static Contract contratoFuturoIndice(String localSymbol) {
        Contract c = new Contract();
        c.localSymbol(localSymbol); // ex: "WINZ25" (ajustar ao formato usado pela IBKR)
        c.secType("FUT");
        c.currency("BRL");
        c.exchange("B3");
//        c.exchange("BMFBOVESPA");
        return c;
    }
   
    public static Contract contratoAcaoUSA(String symbol) {
        Contract c = new Contract();
        c.symbol(symbol);        // "AAPL", por exemplo
        c.secType("STK");
        c.currency("USD");
        c.exchange("SMART");
        return c;
    }

        public static Contract contratoForex() {
                Contract c = new Contract();
                c.symbol("EUR");
                c.secType("CASH");
                c.currency("USD");
                c.exchange("IDEALPRO");
                return c;
        }
}