Changes

Jump to navigation Jump to search

Portfolio Trader

124 bytes added, 13:14, 11 August 2022
no edit summary
== Portfolio Script Calculation Diagram ==
To see '''Portfolio Script Calculation Diagram''' please click '''[[Portfolio Script Calculation Diagram|here]]'''.
== Script Calculation and Raw Order Generation ==
# Before a portfolio is calculated, data from all instruments contained in the Instrument List are either gathered from MultiCharts database or downloaded from a data provider's server. The first instrument’s data range start date determines the start date for all instruments. The strategy is then applied to every instrument in the Portfolio Tree.
# During backtesting, a single bar of each symbol's data series is evaluated by the strategy's signal scripts, starting with the first (oldest) bar. The series’ bars are evaluated in the order that the symbols appear in the symbols table of Portfolio Trader. Based on evaluation of each series’ bar, a set of one or more orders may be generated by the scripts for each of the symbols. Order sets are generated in the same sequence as the series’ bars are evaluated.
# This process is illustrated in the Raw Order Generation section of the [[Portfolio Script Calculation Diagram|diagram]]: the first bar for symbol 1 is evaluated first, and a set of orders is generated based on that bar. Then the first bar for symbol 2 is evaluated, and a set of orders is generated based on that bar. The process is repeated until the first bar for the last symbol (Symbol N) is evaluated.
# After all of the strategies have been calculated, the PMM (Portfolio Money Management) signal is initiated (if any has been applied under Portfolio Properties). The PMM signal is used to apply money management settings to the entire portfolio. It can access all of the portfolio's strategies via pmms_keywords. (Calculation-wise, the PMM signal is not copied to every signal and is always calculated on the first instrument on the same bar on which all other signals are calculated).
# The PMM signal evaluates all of the portfolio’s strategies and affects generated orders (e.g., places orders which force positions to close, prevents opening positions or modifies the number of contracts). Raw orders that pass the PMM signal evaluation are then evaluated by the MONEY & RISK management system, with priority determined by MONEY & RISK's settings (priority is set by the PortfolioEntriesPriority keyword). If priority is set the same for all strategies, higher priority is given to the strategy located on top of the Portfolio Tree. <br><div style="background-color: #E3FBE5;"> '''Note''' that the PMM signal and the '''PortfolioEntriesPriority''' keyword are both applied to the portfolio. '''PortfolioEntriesPriority''' keyword is a legacy and it can interfere with the PMM signal. We do not recommend you use it.</div>
If the '''PortfolioEntriesPriority''' function is specified within a strategy, the sequence of the sets of orders is rearranged based on the criteria specified.
This process is illustrated in the Symbol Prioritization section of the [[Portfolio Script Calculation Diagram|diagram]]: the resulting sequence of sets of orders begins with the set of orders for the symbol 1, followed by the set of orders for symbol N, and ends with the set of orders for symbol 2.
The position of a set of orders in the sequence determines its relative priority: the set of orders for symbol 1 has the highest priority (3), set of orders for symbol N has the second highest priority (2), and the set of orders for symbol 2 has the least priority (3).
At the risk control stage, the sequence of sets of orders is treated as one long sequence of orders. Orders are executed one-by-one from the beginning of the sequence, until all orders are executed, or until the risk control limits defined in Portfolio Settings prevent the execution of remaining orders. Any remaining orders that could not be executed are discarded.
This process is illustrated in the Risk Control section of the [[Portfolio Script Calculation Diagram|diagram]]: all of the orders for symbol 1 and symbol N are executed, while only some of the orders for symbol 2, 100 shares Long @ 55, are executed, due to risk control limits; this prevents the execution of the rest of the orders for symbol 2.
The entire process is repeated for the next bar of each of the portfolio symbol's data series.

Navigation menu