Skip to content

Commit 483bdbc

Browse files
authored
Read only client (#35)
* Make the client read only * Change the default to be read-only. * Remove subscriptions that cause errors.
1 parent 2dc26ac commit 483bdbc

File tree

5 files changed

+536
-13
lines changed

5 files changed

+536
-13
lines changed

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,26 @@ of Docker, `host` should be set to `host.docker.internal`.
219219
communicates on. This value can be found in the [IB Trader Workstation (TWS)](https://www.interactivebrokers.com/en/trading/tws.php)
220220
settings. By default, production trading uses port 7496, and paper trading uses port 7497. See [Setup](#setup) and [TWS Initial Setup](https://interactivebrokers.github.io/tws-api/initial_setup.html) for more details.
221221

222-
`order_id_strategy` is the strategy used for obtaining new order ids.
222+
`read_only` is a boolean value that is used to enable trading. By default `read_only=True`, preventing trading. Use `read_only=False` to enable trading.
223+
224+
`order_id_strategy` is the strategy used for obtaining new order ids. Order id algorithms have tradeoffs in execution time, support for multiple, concurrent sessions, and avoidance of TWS bugs.
223225
* `OrderIdStrategy.RETRY` (default) - Request a new order ID from TWS every time one is needed. Retry if TWS does not respond quickly. This usually avoids a TWS bug where it does not always respond.
224226
* `OrderIdStrategy.BASIC` - Request a new order ID from TWS every time one is needed. Does not retry, so it may deadlock if TWS does not respond.
225227
* `OrderIdStrategy.INCREMENT` - Use the initial order ID sent by TWS and increment the value upon every request. This is fast, but it may fail for multiple, concurrent sessions connected to TWS.
226228

229+
For a read-write session that allows trading:
230+
```python
231+
import deephaven_ib as dhib
232+
233+
client = dhib.IbSessionTws(host="host.docker.internal", port=7497, read_only=False)
234+
client.connect()
235+
```
236+
237+
For a read-only session that does not allow trading:
227238
```python
228239
import deephaven_ib as dhib
229240
230-
client = dhib.IbSessionTws(host="host.docker.internal", port=7497)
241+
client = dhib.IbSessionTws(host="host.docker.internal", port=7497, read_only=True)
231242
client.connect()
232243
```
233244

examples/example_all_functionality.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
print("==== Create a client and connect.")
1515
print("==============================================================================================================")
1616

17-
client = dhib.IbSessionTws(host="host.docker.internal", port=7497, client_id=0, download_short_rates=False)
17+
client = dhib.IbSessionTws(host="host.docker.internal", port=7497, client_id=0, download_short_rates=False, read_only=False)
1818
print(f"IsConnected: {client.is_connected()}")
1919

2020
client.connect()

0 commit comments

Comments
 (0)