Replies: 2 comments 3 replies
-
this is not realliy addressing your point directly, but it might help have you tried with uvloop |
Beta Was this translation helpful? Give feedback.
-
I tried with an algo i'm running on paper account and indeed uvloop did not work. however if i run a simple test it works. import asyncio
import uvloop
import ib_async
uvloop.install()
#asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
async def main():
ib = await ib_async.IB().connectAsync("tws", 7499, clientId=210)
await asyncio.sleep(1)
print('I'm connected!')
pos = ib.positions()
print(len(pos), pos[-1])
await asyncio.sleep(1)
ib.disconnect()
print('bye bye')
if __name__ == '__main__':
print('before start')
asyncio.run(main())
print("the end") I would need to test more, but i think it should work. in theory i read https://github.com/Marco-Sulla/python-frozendict#benchmarks |
Beta Was this translation helpful? Give feedback.
-
I have spent time optimizing my code for faster execution. Currently the slowest link in is the updateMktDepthL2 function in the ib_async.
A single call at decoder level takes 56us in my measurements. There are so many updates to the order book that with a
numRows=40
, a usual update loop takes around 10-15 ms.This is not the end of the world, but when I have subscribed to order book from 3 stocks, it starts to add up to the latency.
I have been thinking of moving the order book updating to a separate process, but maybe there's some optimizations that could be done on the update logic or data structures being used?
Beta Was this translation helpful? Give feedback.
All reactions