How to get realtime data using ib_insync, Django, Redis and Channels?

Hi there! Right now i’m trying to obtain a real time hour using ib.reqCurrentTimeAsync() method from ib_insync library that returns a coroutine object.

I’m doing this to display it on a HTML template in order to provide a realtime socket endpoint later on with Django Rest Framework.
107518879_10222696077820047_5995642844586485440_o|334x500

I don’t know how to do this using coroutines and async code without blocking the code using a while True: (It worked on Jupyter but it was sync code)

I provide my services.py, my consumer.py to ease the solution. I’m also providing my github.

https://github.com/juan9222/qsdb

Thanks in advance!

1 Like