Subversion Repositories Integrator Subversion

Rev

Rev 796 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
795 blopes 1
package br.com.kronus.ibkr.api;
2
 
3
import com.ib.client.Contract;
4
 
5
/**
6
 * Responsável por criar Contracts da IBKR a partir dos símbolos usados no sistema.
7
 * Ajuste conforme o universo de ativos que você for operar.
8
 */
9
public class IbkrMapper {
10
 
11
    /**
12
     * Exemplo para AÇÃO negociada na B3.
13
     */
14
        public static Contract contratoAcaoBrasil(String symbol) {
15
            Contract c = new Contract();
16
            c.symbol(symbol);          // "PETR4", "VALE3", etc.
17
            c.secType("STK");
18
            c.currency("BRL");
19
 
20
            // Forma mais comum que a IB documenta para B3:
21
            c.exchange("SMART");       // roteamento inteligente
22
            c.primaryExch("BVMF");     // B3
23
 
24
            return c;
25
        }
26
 
27
    /**
28
     * Exemplo para FUTURO de índice (mini índice, etc.).
29
     * Ajuste localSymbol/lastTradeDateOrContractMonth conforme a IBKR.
30
     */
31
    public static Contract contratoFuturoIndice(String localSymbol) {
32
        Contract c = new Contract();
33
        c.localSymbol(localSymbol); // ex: "WINZ25" (ajustar ao formato usado pela IBKR)
34
        c.secType("FUT");
35
        c.currency("BRL");
36
        c.exchange("BMFBOVESPA");
37
        return c;
38
    }
39
 
40
    public static Contract contratoAcaoUSA(String symbol) {
41
        Contract c = new Contract();
42
        c.symbol(symbol);        // "AAPL", por exemplo
43
        c.secType("STK");
44
        c.currency("USD");
45
        c.exchange("SMART");
46
        return c;
47
    }
48
}