Skip to content

Commit

Permalink
Support historical data bar updates (#113)
Browse files Browse the repository at this point in the history
* Support historical data bar updates.

* Only log new bars that contain volume or bar count data

* Fixed when bars will be updated

* Updated bar processing to show only the latest bars to be consistent with the response from IB.

* readme update

* Fixed a comment

* Update README.md
  • Loading branch information
chipkent authored Dec 18, 2023
1 parent 095f4db commit f55a70a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ These tables include:
* `ticks_trade`: real-time tick market data of trade prices requested via `request_tick_data_historical` or `request_tick_data_realtime`.
* `ticks_bid_ask`: real-time tick market data of bid and ask prices requested via `request_tick_data_historical` or `request_tick_data_realtime`.
* `ticks_mid_point`: real-time tick market data of mid-point prices requested via `request_tick_data_historical` or `request_tick_data_realtime`.
* `bars_historical`: historical price bars requested via `request_bars_historical`.
* `bars_historical`: historical price bars requested via `request_bars_historical`. Real-time bars change as new data arrives.
* `bars_realtime`: real-time price bars requested via `request_bars_realtime`.
* Order Management System (OMS)
* `orders_submitted`: submitted orders **FOR THE THE CLIENT'S ID**. A client ID of 0 contains manually entered orders. Automatically populated.
Expand Down
4 changes: 2 additions & 2 deletions src/deephaven_ib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ class IbSessionTws:
* **ticks_trade**: real-time tick market data of trade prices requested via ``request_tick_data_historical`` or ``request_tick_data_realtime``.
* **ticks_bid_ask**: real-time tick market data of bid and ask prices requested via ``request_tick_data_historical`` or ``request_tick_data_realtime``.
* **ticks_mid_point**: real-time tick market data of mid-point prices requested via ``request_tick_data_historical`` or ``request_tick_data_realtime``.
* **bars_historical**: historical price bars requested via ``request_bars_historical``.
* **bars_historical**: historical price bars requested via ``request_bars_historical``. Real-time bars change as new data arrives.
* **bars_realtime**: real-time price bars requested via ``request_bars_realtime``.
####
Expand Down Expand Up @@ -638,7 +638,7 @@ def deephaven_ib_parse_note(note:str, key:str) -> Optional[str]:
"orders_status": tables_raw["raw_orders_status"] \
.last_by("PermId") \
.move_columns_up(["ReceiveTime", "PermId", "ClientId", "OrderId", "ParentId"]),
"bars_historical": annotate_ticks(tables_raw["raw_bars_historical"]),
"bars_historical": annotate_ticks(tables_raw["raw_bars_historical"]).last_by(["Request", "Timestamp", "ContractId"]),
"bars_realtime": annotate_ticks(tables_raw["raw_bars_realtime"]),
"ticks_efp": annotate_ticks(tables_raw["raw_ticks_efp"]),
"ticks_generic": annotate_ticks(tables_raw["raw_ticks_generic"]),
Expand Down
4 changes: 4 additions & 0 deletions src/deephaven_ib/_tws/tws_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,10 @@ def historicalDataEnd(self, reqId: int, start: str, end: str):
# do not ned to implement
EWrapper.historicalDataEnd(self, reqId, start, end)

def historicalDataUpdate(self, reqId: int, bar: BarData):
EWrapper.historicalDataUpdate(self, reqId, bar)
self._table_writers["bars_historical"].write_row([reqId, *logger_bar_data.vals(bar)])

####
# reqRealTimeBars
####
Expand Down

0 comments on commit f55a70a

Please sign in to comment.