Skip to content

Commit b5c547f

Browse files
authored
Fix request tickdata realtime exception (#96)
* Fix broken example. * Change bid ask sizes in bid ask ticks to floats.
1 parent cc77c4d commit b5c547f

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

examples/example_all_functionality.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,23 @@ def get_contracts() -> Dict[str, Contract]:
9090
contract.secType = "FUT"
9191
contract.exchange = "GLOBEX"
9292
contract.currency = "USD"
93-
contract.lastTradeDateOrContractMonth = "202209"
93+
contract.lastTradeDateOrContractMonth = "202212"
9494
rst["future_1"] = contract
9595

96+
# find more contracts at https://www.cmegroup.com/markets/equities/sp/e-mini-sandp500.quotes.html
9697
contract = Contract()
9798
contract.secType = "FUT"
9899
contract.exchange = "GLOBEX"
99100
contract.currency = "USD"
100-
contract.localSymbol = "MESU2"
101+
contract.localSymbol = "ESZ2"
101102
rst["future_2"] = contract
102103

103104
contract = Contract()
104105
contract.symbol = "DAX"
105106
contract.secType = "FUT"
106107
contract.exchange = "EUREX"
107108
contract.currency = "EUR"
108-
contract.lastTradeDateOrContractMonth = "202209"
109+
contract.lastTradeDateOrContractMonth = "202212"
109110
contract.multiplier = "1"
110111
rst["future_3"] = contract
111112

@@ -357,8 +358,8 @@ def get_contracts() -> Dict[str, Contract]:
357358
bar_type=dhib.BarDataType.ASK)
358359
client.request_bars_historical(rc, duration=dhib.Duration.days(10), bar_size=dhib.BarSize.MIN_5,
359360
bar_type=dhib.BarDataType.BID_ASK, keep_up_to_date=False)
360-
client.request_bars_historical(rc, duration=dhib.Duration.days(10), bar_size=dhib.BarSize.MIN_5,
361-
bar_type=dhib.BarDataType.AGGTRADES)
361+
# client.request_bars_historical(rc, duration=dhib.Duration.days(10), bar_size=dhib.BarSize.MIN_5,
362+
# bar_type=dhib.BarDataType.AGGTRADES)
362363
client.request_bars_historical(rc, duration=dhib.Duration.days(10), bar_size=dhib.BarSize.MIN_5,
363364
bar_type=dhib.BarDataType.ADJUSTED_LAST, keep_up_to_date=False)
364365

@@ -482,7 +483,7 @@ def get_contracts() -> Dict[str, Contract]:
482483
order.action = "BUY"
483484
order.orderType = "LIMIT"
484485
order.totalQuantity = 1
485-
order.lmtPrice = 3000
486+
order.lmtPrice = 100
486487

487488
print("Placing order: START")
488489
client.order_place(rc, order)
@@ -493,7 +494,7 @@ def get_contracts() -> Dict[str, Contract]:
493494
order.action = "BUY"
494495
order.orderType = "LIMIT"
495496
order.totalQuantity = 1
496-
order.lmtPrice = 2600
497+
order.lmtPrice = 90
497498

498499
print("Placing order: START")
499500
client.order_place(rc, order)
@@ -504,7 +505,7 @@ def get_contracts() -> Dict[str, Contract]:
504505
order.action = "BUY"
505506
order.orderType = "LIMIT"
506507
order.totalQuantity = 1
507-
order.lmtPrice = 2700
508+
order.lmtPrice = 91
508509

509510
print("Placing order: START")
510511
req = client.order_place(rc, order)

examples/example_read_only_functionality.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,23 @@ def get_contracts() -> Dict[str, Contract]:
8686
contract.secType = "FUT"
8787
contract.exchange = "GLOBEX"
8888
contract.currency = "USD"
89-
contract.lastTradeDateOrContractMonth = "202209"
89+
contract.lastTradeDateOrContractMonth = "202212"
9090
rst["future_1"] = contract
9191

92+
# find more contracts at https://www.cmegroup.com/markets/equities/sp/e-mini-sandp500.quotes.html
9293
contract = Contract()
9394
contract.secType = "FUT"
9495
contract.exchange = "GLOBEX"
9596
contract.currency = "USD"
96-
contract.localSymbol = "MESU2"
97+
contract.localSymbol = "ESZ2"
9798
rst["future_2"] = contract
9899

99100
contract = Contract()
100101
contract.symbol = "DAX"
101102
contract.secType = "FUT"
102103
contract.exchange = "EUREX"
103104
contract.currency = "EUR"
104-
contract.lastTradeDateOrContractMonth = "202209"
105+
contract.lastTradeDateOrContractMonth = "202212"
105106
contract.multiplier = "1"
106107
rst["future_3"] = contract
107108

@@ -353,8 +354,8 @@ def get_contracts() -> Dict[str, Contract]:
353354
bar_type=dhib.BarDataType.ASK)
354355
client.request_bars_historical(rc, duration=dhib.Duration.days(10), bar_size=dhib.BarSize.MIN_5,
355356
bar_type=dhib.BarDataType.BID_ASK, keep_up_to_date=False)
356-
client.request_bars_historical(rc, duration=dhib.Duration.days(10), bar_size=dhib.BarSize.MIN_5,
357-
bar_type=dhib.BarDataType.AGGTRADES)
357+
# client.request_bars_historical(rc, duration=dhib.Duration.days(10), bar_size=dhib.BarSize.MIN_5,
358+
# bar_type=dhib.BarDataType.AGGTRADES)
358359
client.request_bars_historical(rc, duration=dhib.Duration.days(10), bar_size=dhib.BarSize.MIN_5,
359360
bar_type=dhib.BarDataType.ADJUSTED_LAST, keep_up_to_date=False)
360361

@@ -478,7 +479,7 @@ def get_contracts() -> Dict[str, Contract]:
478479
order.action = "BUY"
479480
order.orderType = "LIMIT"
480481
order.totalQuantity = 1
481-
order.lmtPrice = 3000
482+
order.lmtPrice = 100
482483

483484
print("Placing order -- confirm fail: START")
484485
try:
@@ -495,7 +496,7 @@ def get_contracts() -> Dict[str, Contract]:
495496
order.action = "BUY"
496497
order.orderType = "LIMIT"
497498
order.totalQuantity = 1
498-
order.lmtPrice = 2600
499+
order.lmtPrice = 90
499500

500501
print("Placing order -- confirm fail: START")
501502
try:
@@ -512,7 +513,7 @@ def get_contracts() -> Dict[str, Contract]:
512513
order.action = "BUY"
513514
order.orderType = "LIMIT"
514515
order.totalQuantity = 1
515-
order.lmtPrice = 2700
516+
order.lmtPrice = 91
516517

517518
print("Placing order -- confirm fail: START")
518519
try:

src/deephaven_ib/_tws/ib_type_logger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ def _details_historical_tick_bid_ask() -> List[Tuple]:
362362
("Timestamp", dtypes.DateTime, lambda t: unix_sec_to_dh_datetime(t.time)),
363363
("BidPrice", dtypes.float64, lambda t: t.priceBid),
364364
("AskPrice", dtypes.float64, lambda t: t.priceAsk),
365-
("BidSize", dtypes.int64, lambda t: t.sizeBid),
366-
("AskSize", dtypes.int64, lambda t: t.sizeAsk),
365+
("BidSize", dtypes.float64, lambda t: t.sizeBid),
366+
("AskSize", dtypes.float64, lambda t: t.sizeAsk),
367367
*_include_details(_details_tick_attrib_bid_ask(), lambda t: t.tickAttribBidAsk),
368368
]
369369

0 commit comments

Comments
 (0)