Last month I presented a detailed roadmap for the redevelopment of QSTrader, our open-source systematic trading simulation engine.
Today I want to discuss our progress in the month since that article was published and what still remains to be completed prior to the initial 0.1.0 alpha release.
Progress To Date
The internal QSTrader development version is now mature enough to carry out simple backtests on multiple equity tickers.
This means that the core
PortfolioConstructionModel class hierarchies are functional and work within a simplified daily event simulation engine.
SimulatedExchange entity now keeps track of asset prices through time using
PriceVolumeDataSource instances. The latter currently uses CSV files via pandas as the storage mechanism although the interface has been designed to allow RDBMS and other time series databases in the future.
SimulatedBroker now effectively keeps track of long and short positions throughout the duration of the backtest. It also provides multiple sub-accounts and cashflows in/out of these accounts, as well as the broker itself.
PortfolioConstructionModel hierarchies both function and have been tested with equal weighting of assets in an initial portfolio. While rebalancing is now supported, through the use of desired/actual portfolios, there is no mechanism as of yet to specify the rebalance frequency.
All of these classes are wrapped up in a
Backtest instance, which utilises a
SimulationEngine as an event "clock" that determines when the trading logic and associated market components, such as the broker and exchange, are updated.
Essentially this allows simple buy-and-hold backtests on daily equities data, albeit with considerable flexibility and modularity in system composition.
The major lacking feature is a mechanism for reporting performance. Performance reporting is composed of two aspects as far as QSTrader is concerned: Performance calculation and performance visualisation.
The former cannot simply be lifted from previous versions of QSTrader as the addition of cashflows complicates the way in which performance is reported. This can be seen by simply noting that if a portfolio receives a cash injection then the corresponding equity curve admits a discontinuous—albeit fictitious—rise in performance.
To account for this it is necessary to introduce the concept of "shares" in a "fund", which naturally allow for allocations and redemptions, without affecting the performance calculations of the underlying strategies employed. I will detail this procedure in a later post.
Performance visualisation currently functions in QSTrader as a Matplotlib output at the conclusion of a backtest. This is certainly sufficient for strategy-oriented backtesting but is less appropriate for portfolio-level analytics and risk tracking.
This provides three benefits. Firstly, it means that risk and performance reporting can be organised in a hierarchical manner. A dashboard will be the primary entry interface, which will allow drilldown into more detailed analytics for various aspects of the portfolio strategy.
Secondly, having a dedicated separate web server process allows continuous reporting when carrying out paper, or live, trading. The web app will be able to contact the trading app and glean performance results in real-time.
Thirdly, by virtue of being hosted on a remote server it will be possible to view these portfolio analytics from any location, rather than simply being constrained to the local desktop workstation.
Upcoming Release - What To Expect
The first alpha release of the new version of QSTrader will consist of the classic moving average crossover backtest example (as provided in the current release) along with a basic web-based reporting engine.
Development will proceed quickly after this, most likely with the
Broker hierarchy to simulate cash accounts in Interactive Brokers for realistic transaction costs.
Attention will then likely be turned to optimising the system to allow large-scale backtests across substantial equity universes.
As I mentioned in the previous post I will be providing more frequent updates on the team's development progress in the coming months.
It is anticipated that late Dec 2017 or early 2018 will be the likely release date for the first major version.