Skip to content

Commit

Permalink
Use fixed max client version
Browse files Browse the repository at this point in the history
  • Loading branch information
erdewit committed Sep 27, 2018
1 parent e255dcf commit 1b6ff9c
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions ib_insync/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,45 @@
class Client(EClient):
"""
Modification of ``ibapi.client.EClient`` that uses asyncio.
The client is fully asynchronous and has its own
event-driven networking code that replaces the
networking code of the standard EClient.
It also replaces the infinite loop of ``EClient.run()``
with the asyncio event loop. It can be used as a drop-in
replacement for the standard EClient as provided by IBAPI.
Compared to the standard EClient this client has the following
additional features:
* ``client.connect()`` will block until the client is ready to
serve requests; It is not necessary to wait for ``nextValidId``
to start requests as the client has already done that.
The reqId is directly available with :py:meth:`.getReqId()`.
* ``client.connectAsync()`` is a coroutine for connecting asynchronously.
* When blocking, ``client.connect()`` can be made to time out with
the timeout parameter (default 2 seconds).
* Optional ``wrapper.priceSizeTick(reqId, tickType, price, size)`` that
combines price and size instead of the two wrapper methods
priceTick and sizeTick.
* Automatic request throttling.
* Optional ``wrapper.tcpDataArrived()`` method;
If the wrapper has this method it is invoked directly after
a network packet has arrived.
A possible use is to timestamp all data in the packet with
the exact same time.
* Optional ``wrapper.tcpDataProcessed()`` method;
If the wrapper has this method it is invoked after the
network packet's data has been handled.
A possible use is to write or evaluate the newly arrived data in
one batch instead of item by item.
* Events:
* ``apiStart()``
* ``apiEnd()``
Expand Down Expand Up @@ -141,7 +141,7 @@ def connect(self, host, port, clientId, timeout=2):
"""
Connect to TWS/IBG at given host and port and with a clientId
that is not in use elsewhere.
When timeout is not zero, asyncio.TimeoutError
is raised if the connection is not established within the timeout period.
"""
Expand Down Expand Up @@ -205,9 +205,7 @@ def _onSocketConnected(self):
self._logger.info('Connected')
# start handshake
msg = b'API\0'
msg += self._prefix(b'v%d..%d' % (
ibapi.server_versions.MIN_CLIENT_VER,
ibapi.server_versions.MAX_CLIENT_VER))
msg += self._prefix(b'v%d..%d' % (100, 142))
self.conn.sendMsg(msg)
self.decoder = ibapi.decoder.Decoder(self.wrapper, None)

Expand Down

0 comments on commit 1b6ff9c

Please sign in to comment.