Skip to content

Commit d94df01

Browse files
authored
Fix historical bar timestamp parsing (#57)
* Add a docker command to build images and then launch the system. * Parse multiple timestamp formats for bars. * Support new bar sizes.
1 parent 74d56eb commit d94df01

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

docker/deephaven_ib_docker.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function help() {
3434
echo "------"
3535
echo "build - build Docker images for the system"
3636
echo "up - launch the system"
37+
echo "build_up - build the Docker images for the system and launch the system"
3738
echo "down - shut down the system"
3839
echo "help - print a help message"
3940
echo ""
@@ -89,6 +90,10 @@ case "$ACTION" in
8990
"up")
9091
up
9192
;;
93+
"build_up")
94+
build
95+
up
96+
;;
9297
"down")
9398
down
9499
;;

src/deephaven_ib/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ class BarSize(Enum):
149149
"""1 second bar."""
150150
SEC_5 = "5 secs"
151151
"""5 second bar."""
152+
SEC_10 = "10 secs"
153+
"""10 second bar."""
152154
SEC_15 = "15 secs"
153155
"""15 second bar."""
154156
SEC_30 = "30 secs"
@@ -161,14 +163,30 @@ class BarSize(Enum):
161163
"""3 minute bar."""
162164
MIN_5 = "5 mins"
163165
"5 minute bar."
166+
MIN_10 = "10 mins"
167+
"10 minute bar."
164168
MIN_15 = "15 mins"
165169
"""15 minute bar."""
170+
MIN_20 = "20 mins"
171+
"20 minute bar."
166172
MIN_30 = "30 mins"
167173
"""30 minute bar."""
168174
HOUR_1 = "1 hour"
169175
"""1 hour bar."""
176+
HOUR_2 = "2 hour"
177+
"""2 hour bar."""
178+
HOUR_3 = "3 hour"
179+
"""3 hour bar."""
180+
HOUR_4 = "4 hour"
181+
"""4 hour bar."""
182+
HOUR_8 = "8 hour"
183+
"""8 hour bar."""
170184
DAY_1 = "1 day"
171185
"""1 day bar."""
186+
WEEK_1 = "1W"
187+
"""1 week bar."""
188+
MONTH_1 = "1M"
189+
"""1 month bar."""
172190

173191

174192
class Duration:

src/deephaven_ib/_tws/ib_type_logger.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,20 @@ def map_null(val):
200200

201201
return val
202202

203+
def parse_timestamp(bd):
204+
if len(bd.date) is 8:
205+
# bd.date is a date string
206+
year = bd.date[0:4]
207+
month = bd.date[4:6]
208+
day = bd.date[6:]
209+
time_string = f"{year}{month}{day} 23:59:59"
210+
return ib_to_dh_datetime(time_string)
211+
else:
212+
# bd.date is unix sec
213+
return unix_sec_to_dh_datetime(int(bd.date))
214+
203215
return [
204-
("Timestamp", dtypes.DateTime, lambda bd: unix_sec_to_dh_datetime(int(bd.date))),
216+
("Timestamp", dtypes.DateTime, parse_timestamp),
205217
("Open", dtypes.float64, lambda bd: bd.open),
206218
("High", dtypes.float64, lambda bd: bd.high),
207219
("Low", dtypes.float64, lambda bd: bd.low),

0 commit comments

Comments
 (0)