How A Trading Specification Is Executed
RuleTrader executes your automated investment system in essentially the same way, whether you’re back-testing it in RuleTrader Test or using it for live investments in RuleTrader Live. The process happens in stages throughout the day and the back-testing system has been carefully designed to ensure your Trading Spec can only see the data that would be available to your Live system, at any particular time in the day. The following help topics provide a simplified explanation of these stages.
Daily Rollover
At the very beginning of the day (nominally 1 second past midnight) the system:
- checks that the linked cash-accounts and portfolios in ShareScope are still available and syncs the Live session’s trading account data with ShareScope. This also occurs any time there is a change in RuleTrader’s account data.
- checks for dividends that came in the previous day
- calculates the mark to market value of your positions at close the previous day
- clears the lists of triggered rules, trading signals and newly added trading list securities
- updates the time-weighted average spreads
- checks if any of the Trading Strategies‘ List Selectors are due to reselect their trading lists
List Selection
If a List Selector is due to reselect its trading list, then the list selection is performed according to the list selector definition. The lists selected by a strategy’s list selectors are then combined and de-duplicated to create the strategy’s trading List.
If any shares were deselected then the system checks if they have an open position associated with the strategy. If they do, then the share is automatically reinstated in the strategy’s trading list, so it can continue to monitor the position for possible sell signals. Evaluation of any further buy rules (i.e. that would increase the position) are suppressed. If the position is closed later on, then the reinstated share will be automatically removed from that strategy’s trading list.
In the Live system, if a share has been designated as a permanent member of the trading list (see Live Session > Managing Trading Lists & Trading Signals), then it will be automatically continued to the new trading list, while barred shares are automatically excluded.
Once all required lists have been reselected, all strategies’ trading lists are combined and de-duplicated to form your Spec’s overall trading list. List selection always happens first, before any trading rules are evaluated.
Backfilling Shares
If any shares have been added to a trading list, then they are backfilled over the longest period of data required by your Spec’s components. This ensures those components are ‘fully loaded’ with data and so give accurate results on the first day the share is selected for the list and its Trading Rules are evaluated.
Components that are backfilled include price-indicators, statistics (e.g. averages, trends, correlations, etc.) and the AutoTrend Price-Channels. You’ll see the effect of this when you run a back-test and review the charts for each involved share – their channels will be displayed for the length of the backfill period prior to the start of the test or the date they were selected for the trading list.
Usually the backfill period is the larger of the longest price-indicators or statistic period, and the price-channel backfill period (which is set in AutoTrend Settings). However, if a share was recently in a trading list then its data will be up to date to the point it was deselected from the list, so it will only be backfilled from there.
The system jumps back to the start of the backfill period and works forwards, day by day, to the present day (today in Live sessions, or the day that has been reached in a back-test). On each day it updates each price-indicator, statistic, price-channel and overlay, so they are fully up-to-date by the time the share is selected and the process of evaluating its Trading Rules begins.
While there is no point in evaluating trading rules during backfill, you have the option, when defining an Action Rule that updates a Persistent Term, of requiring that action rule to be evaluated during backfill. This can be useful if, for example, you want a count of events during the backfill period, prior to the start of trading rule evaluation.
Trading Rule Evaluation
Please refer to the separate topic: How Trading Rules Are Evaluated
After Market Close
Once ShareScope’s OHLC end-of-day database update has occurred, RuleTrader uses that data to advance the AutoTrend Price-Channels by one day and to roll-over all ‘yesterday’ and ‘today’ values for the channel data. It also updates all statistics and price-indicators used by your Spec that are based on this data