Rev 796 | Details | Compare with Previous | 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 | */ |
||
| 796 | blopes | 14 | public static Contract contratoAcaoBrasil2(String symbol) { |
| 795 | blopes | 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 | } |
||
| 796 | blopes | 26 | |
| 27 | public static Contract contratoAcaoBrasil(String symbol) { |
||
| 28 | Contract c = new Contract(); |
||
| 29 | c.symbol(symbol); |
||
| 30 | c.secType("STK"); |
||
| 31 | c.currency("BRL"); |
||
| 32 | c.exchange("B3"); // teste direto BVMF |
||
| 33 | // c.primaryExch("BVMF"); // teste com e sem |
||
| 34 | return c; |
||
| 35 | } |
||
| 795 | blopes | 36 | |
| 796 | blopes | 37 | |
| 795 | blopes | 38 | /** |
| 39 | * Exemplo para FUTURO de índice (mini índice, etc.). |
||
| 40 | * Ajuste localSymbol/lastTradeDateOrContractMonth conforme a IBKR. |
||
| 41 | */ |
||
| 42 | public static Contract contratoFuturoIndice(String localSymbol) { |
||
| 43 | Contract c = new Contract(); |
||
| 44 | c.localSymbol(localSymbol); // ex: "WINZ25" (ajustar ao formato usado pela IBKR) |
||
| 45 | c.secType("FUT"); |
||
| 46 | c.currency("BRL"); |
||
| 796 | blopes | 47 | c.exchange("B3"); |
| 48 | // c.exchange("BMFBOVESPA"); |
||
| 795 | blopes | 49 | return c; |
| 50 | } |
||
| 51 | |||
| 52 | public static Contract contratoAcaoUSA(String symbol) { |
||
| 53 | Contract c = new Contract(); |
||
| 54 | c.symbol(symbol); // "AAPL", por exemplo |
||
| 55 | c.secType("STK"); |
||
| 56 | c.currency("USD"); |
||
| 57 | c.exchange("SMART"); |
||
| 58 | return c; |
||
| 59 | } |
||
| 797 | blopes | 60 | |
| 61 | public static Contract contratoForex() { |
||
| 62 | Contract c = new Contract(); |
||
| 63 | c.symbol("EUR"); |
||
| 64 | c.secType("CASH"); |
||
| 65 | c.currency("USD"); |
||
| 66 | c.exchange("IDEALPRO"); |
||
| 67 | return c; |
||
| 68 | } |
||
| 795 | blopes | 69 | } |