This event driven backtester follows the general idea found in the event-driven with python tutorial found here. It is developed with python queue module as a shared data bus, with 4 major components ('engines'):
channel data from csv, sql, or other sources to this engine, responsible for generating a bar data for each traded contract/stock whenever the current queue becomes empty (which signifies the end of the processing of last bar data by the rest of the program)
takes bar data from the queue and give out signals to be used in trading. Note: This is a highly flexible interface so other operatiosn like generating csv data from datasource can also be done here
These classes are used by strategies involving a scoring mechanism. The heavy version stores data on its own, while the lite version rely on the strategy class to provide data and thus is more efficient.
takes in signal and market information, generate open order (in cash amount) and close position order (in real amount)
takes in order generated by portfolio, execute it in either simulated trading environment (when next market info bar is pushed) or via a real broker account. Generate a confirmation when it is done.
Here, I will continue developing more stategies implemented elsewhere. Also, I will continue increasing the performance by swicthing between various data structures
As per the snakeviz analysis I run, this backtester can run 2000+ rows of backtesting of 50+ contracts at a time in under 0.1 second, which is 20-40 times faster than what I used to do using a semi-vectorized approach in pandas.
Calculate an industrial index based on equal weighting all future contract's daily percentage change, store it in a csv file
Don-Chian breakout.
Score futures, long the highest scores, short the lowest scores.
Trade only selected contracts with Don-Chian strategy