-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Deephaven 2 type annotations. * Ported table writer. * Ported times. * Ported PythonFunction. * Ported PythonFunction. * Ported NULL_DOUBLE. * Ported PythonFunction. * Ported Table import. * Ported dtypes. * Ported dtypes. * Ported StringSet. * Ported DateTime. * Ported Table import. * Debugging * Porting move_columns_up * Porting natural_join * Porting rename_columns, drop_columns * Porting select_distinct * Porting last_by * Porting update * Porting column names * Adding time parsing debugging. * Fix date time parsing * Improved time parsing error messages. * Ported example scripts. * Make thread tracing more robust to threads disappearing. * Updated readme.
- Loading branch information
Showing
16 changed files
with
536 additions
and
464 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import deephaven_ib as dhib | ||
|
||
print("==============================================================================================================") | ||
print("==== ** Accept the connection in TWS **") | ||
print("==============================================================================================================") | ||
|
||
client = dhib.IbSessionTws(host="host.docker.internal", port=7497) | ||
client.connect() | ||
|
||
from ibapi.contract import Contract | ||
|
||
c1 = Contract() | ||
c1.symbol = 'DIA' | ||
c1.secType = 'STK' | ||
c1.exchange = 'SMART' | ||
c1.currency = 'USD' | ||
|
||
rc1 = client.get_registered_contract(c1) | ||
print(rc1) | ||
|
||
c2 = Contract() | ||
c2.symbol = 'SPY' | ||
c2.secType = 'STK' | ||
c2.exchange = 'SMART' | ||
c2.currency = 'USD' | ||
|
||
rc2 = client.get_registered_contract(c2) | ||
print(rc2) | ||
|
||
client.set_market_data_type(dhib.MarketDataType.REAL_TIME) | ||
client.request_market_data(rc1) | ||
client.request_market_data(rc2) | ||
client.request_bars_realtime(rc1, bar_type=dhib.BarDataType.MIDPOINT) | ||
client.request_bars_realtime(rc2, bar_type=dhib.BarDataType.MIDPOINT) | ||
|
||
bars_realtime = client.tables["bars_realtime"] | ||
|
||
bars_dia = bars_realtime.where("Symbol=`DIA`") | ||
bars_spy = bars_realtime.where("Symbol=`SPY`") | ||
bars_joined = bars_dia.view(["Timestamp", "TimestampEnd", "Dia=Close"]) \ | ||
.natural_join(bars_spy, on="TimestampEnd", joins="Spy=Close") \ | ||
.update("Ratio = Dia/Spy") | ||
|
||
from deephaven.plot import Figure | ||
|
||
plot_prices = Figure().plot_xy("DIA", t=bars_dia, x="TimestampEnd", y="Close") \ | ||
.x_twin() \ | ||
.plot_xy("SPY", t=bars_dia, x="TimestampEnd", y="Close") \ | ||
.show() | ||
|
||
plot_ratio = Figure().plot_xy("Ratio", t=bars_joined, x="TimestampEnd", y="Ratio") \ | ||
.show() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.