I’m writing a Django stock trading app and I’m at the point at creating the Strategy
model. I want to be able to configure a strategy via the web gui (<-- details regarding the model don’t matter) and then start the strategy with a click on Start
. Now Django needs to start a new Python process (process, not thread, because I need a dedicated CPU core per strategy), but how can Django do that? How to start a process and let it run in (kind of) real-time in the background? There will be a data-stream from a stock broker and therefore the strategy needs to run a loop for each new value received via the data-stream. I also want to store the data in the database. The strategy also needs to communicate with the other Django models, so read and write with the Django ORM needs to be possible.
Do you know any tools, videos or articles that will point me into the right direction? Tools that I already heard of:
django-q2
: GitHub - django-q2/django-q2: A multiprocessing distributed task queue for Django based on Django-Qcelery
withdjango-celery-beat
: GitHub - celery/celery: Distributed Task Queue (development branch), GitHub - celery/django-celery-beat: Celery Periodic Tasks backed by the Django ORM
…but as far as I understood these tools are needed for non-time-critical tasks as these are like a scheduler like e.g. the Linux cron
.
Do you have any other ideas I can follow up?