Closed 0xdomrom closed 6 years ago
Also, in line with this, the orderbook history should be separated by model.time for future analysis/trading strategies and candlesticks
Looking at the use cases of having a sortedDict over a SortedList for bids/asks, the only benefit would be the cached quantity, so having two separate structures, one being the bid/ask sortedList, and a sortedDict for the cached quantities seems like the way to go
I feel like most of this was covered in #30
From small tests it seems that the orderbook bid/ask sorted lists are a bottleneck for the running of the model. An optimisation I would suggest would be changing the data structure to a sorted dictionary, that caches the total quantity at any given price.
i.e.
SortedDict.keys = SortedList([Decimal(1), ...])
SortedDict.dict = {Decimal(1) : (total_quantity, SortedList([Ask, Ask, ...]), ...}
Where the SortedList of asks is sorted by timeThere could also be two separate dicts for total quantity and the sorted asks