Hey All, I’m working to take my Python 3 programming skills to that next level. One of the best ways to improve is to read code of the masters. Can anyone recommend a good project with exemplary Python code for study? Thx, Keith :^)
In my opinion, ib_insync is an example of a project that makes decent compromises between using Python magic and readability. Worth checking out. Otherwise: The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!
Andreas Clenow has some great examples of Python usage (using Zipline) in his latest book, and he has put the source code up for all to use too: https://www.dropbox.com/s/tj85sufbsi820ya/Trading Evolved.zip My data provider (Norgte) has adapted this code to use their data (Zipline is a bit tricky to get data into otherwise) and will provide it on request. I can't tell you whether it's exemplary, but it certainly answers questions of "how would I program up a mean reversion system in Python/Zipline?"
Haven't actually read this book but... Matthew Scarpino - Algorithmic Trading with Interactive Brokers: Python and C++ (2019)
Zipline is difficult to modify and also the data management is very complicated. But I find the code very well written (Python only). Why do you think it is bad?
Although clearly useful and quite easy to follow, Andreas' python code certainly isn't exemplary. We are friends (I wrote a chapter for that book), and he wouldn't mind me saying this Actually, I wouldn't even hold my own code up as exemplary https://github.com/robcarver17/pysystemtrade if you want to see another example of how not to do it. +1 for ib_insync as a trading related exemplar. GAT