Member-only story
Tutorial — making a trading bot asynchronous using Python’s “unsync” library
7 min readJun 14, 2020
The Python “unsync” library is a very easy way to create async code. This gives a practical example of how to use on a simple trading bot.
There are many ways to skin the async cat
In Python there are many valid ways of parallelising your code, including:
- The older way — using the threading and multiprocessing libraries
- The newer way — using
async
andawait
from the asyncio library embedded into core Python from 3.7 onwards - The easier way (I think)— using the
@unsync
decorator from the Python unsync library
What is so great about ‘unsync’?
I’ve used all the above methods on different projects and they all work fine. But for me, unsync seems to be the easiest to use.
If you have code that is synchronous today and you want to make it asynchronous quickly and easily, then try the unsync library.
Simple example using unsync
The current unsync documentation is on the GitHub repo.