Rev 795 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 795 | Rev 796 | ||
|---|---|---|---|
| Line 3... | Line 3... | ||
| 3 | import java.io.BufferedWriter; |
3 | import java.io.BufferedWriter; |
| 4 | import java.io.IOException; |
4 | import java.io.IOException; |
| 5 | import java.nio.file.Files; |
5 | import java.nio.file.Files; |
| 6 | import java.nio.file.Path; |
6 | import java.nio.file.Path; |
| 7 | import java.time.Instant; |
7 | import java.time.Instant; |
| - | 8 | import java.time.LocalDateTime; |
|
| 8 | import java.time.ZoneId; |
9 | import java.time.ZoneId; |
| 9 | import java.time.format.DateTimeFormatter; |
10 | import java.time.format.DateTimeFormatter; |
| 10 | 11 | ||
| 11 | import com.ib.client.Contract; |
12 | import com.ib.client.Contract; |
| 12 | 13 | ||
| Line 46... | Line 47... | ||
| 46 | writer.flush(); |
47 | writer.flush(); |
| 47 | }
|
48 | }
|
| 48 | 49 | ||
| 49 | ibkr.registrarRealtimeBarListener(reqId, (id, time, open, high, low, close, volume, wap, count) -> { |
50 | ibkr.registrarRealtimeBarListener(reqId, (id, time, open, high, low, close, volume, wap, count) -> { |
| 50 | try { |
51 | try { |
| 51 | Instant inst = Instant.ofEpochSecond(time); |
- | |
| - | 52 | Instant inst = Instant.ofEpochMilli(time); |
|
| 52 | String dataStr = DATA.format(inst.atZone(zoneId)); |
53 | String dataStr = DATA.format(inst.atZone(zoneId)); |
| 53 | String horaStr = HORA.format(inst.atZone(zoneId)); |
54 | String horaStr = HORA.format(inst.atZone(zoneId)); |
| 54 | 55 | ||
| 55 | String linha = String.join(";", |
56 | String linha = String.join(";", |
| 56 | dataStr, |
57 | dataStr, |
| Line 80... | Line 81... | ||
| 80 | null
|
81 | null
|
| 81 | ); |
82 | ); |
| 82 | 83 | ||
| 83 | return reqId; |
84 | return reqId; |
| 84 | }
|
85 | }
|
| - | 86 | ||
| - | 87 | public static LocalDateTime converterIbkrTime(long timeMillis) { |
|
| - | 88 | return Instant.ofEpochMilli(timeMillis) |
|
| - | 89 | .atZone(ZoneId.of("America/Sao_Paulo")) |
|
| - | 90 | .toLocalDateTime(); |
|
| - | 91 | }
|
|
| - | 92 | ||
| 85 | }
|
93 | }
|