erdewit / tws_async Goto Github PK
View Code? Open in Web Editor NEWMake the Python IB API from Interactive Brokers run inside an event loop
License: The Unlicense
Make the Python IB API from Interactive Brokers run inside an event loop
License: The Unlicense
I'm struggling to keep under the 100/req per second on reqMktData()
snapshots. I have tried
from PyQt5 import QtCore
...
class TWS(TWSClient):
def requestBulkMktData(self, contracts: [Contract]):
for contract in contracts:
nap = self.reqBucket.consume(1)
reqId = self.getReqId()
QtCore.QTimer.singleShot(nap, lambda: self.reqMktData(reqId, contract, '', True, False, []))
This is using a token bucket to throttle. Using time.sleep()
between will definitely not work with any of the event loops.
I am using the QT implementation on ubuntu 16.04, using both a jupyter notebook and a plain execution.
Compliments for the code! Instead running one TWS connection with one thread, I'd like to have more than one TWS instance (each one able to pass orders and downloading market data independently); ideally running in different processes but at the same time able to pass results between processes by using one of the IPC solutions. I have tried, without success, three solutions:
Hi Ewald,
Thanks a lot for sharing your implentation of the API with asyncio.
I'm quite new to asyncio, so it is a bit challenging to learn both about it and how to integrate it with the API.
Woult that be possible for you to post in the repo some simple test example of how to do a request (say for instance an historical data request) and another one to show how to do multiple requests?
Thank you,
Vincent
Thanks for this example. I was able to run the ipynb version with no issues but trying to run tws_async.py getting 'Connection lost'
On the IB Gateway Log it shows:
....
....
Start API message, ClientID=1
Ignoring API request 'jextend.a1' since API is not accepted.
Terminating async queue.
...
...
any advice would be great, thanks!
I'd like to just use the tws_async.py and asyncio. I ran tws.ipnb and it works. I then modified it by commenting out the %gui qt5
and changed the :
from tws_async_qt import TWSClient, iswrapper
tp
from tws_async import TWSClient, iswrapper
Now I get a :
ERROR:root:ERROR 0 504 Not connected
on the tws.reqHistoricalData' api call.
I was expecting it would work. I'm on a Mac OS X 12.10.5 , and anaconda3 with python 3.5.2 .
Am I missing something?
Hello I installed tws gateway the latest version and after installation when i run my bot i get this
Traceback (most recent call last): File "bottrader.py", line 1, in <module> from ib_insync import * File "/usr/local/lib/python3.5/dist-packages/ib_insync/__init__.py", line 14 f'Old version ({ibapi.__version__}) of ibapi package detected. '
What might be the issue?
@erdewit ,
as you know new version of ibapi has an updated signature for hsitoricaldata call. I figured i'd submit a patch for it. Please let me know.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.