The Portfolio Manager is used to filter the instruments available to the system. This is analogous to a screen process used often in stock trading. Each Portfolio Manager contains the Rank Instrument and Filter Portfolio script sections. These script sections can only be in the a Portfolio Manager blox.
A Portfolio Manager blox applies its logic to each instruments data record. As each instrument record is reviewed the instrument's ability to create an order can be allowed or denied, and it can also be assigned a ranking value. When an instrument is filtered from trading it can be prevented from being allowed to trade in a Long, Short, or in both Long and Short direction. This directional or bi-directional filtering option is built-in Trade Direction Portfolio Manager blox installed during Trading Blox installation. Only the Portfolio Manager can contain the Rank Instrument script section. This script section sees every instrument with a record for each date in the instrument file. Each date is passed through this script as that date is incremented during testing or order generation.
Ranking an instrument is most often a process by which an instrument is given a numerical value for each date processed by the Rank Instrument script section. A ranking value is applied as the Rank Instrument script is called for each record once in each instrument. This allows the blox logic to use the Ranking Functions available in the Instrument Object (i.e. instrument.SetLongRankingValue and instrument.SetShortRankingValue, etc.).
After all of the instruments have been ranked in the Rank Instrument script section, the Filter Portfolio script section is called once for each instrument. In this script section is used to determine the Instrument filtering. Filtering is performed by one or more of the Instrument Object Trade Control Functions that allow or deny order generation based upon the logic in the Filter Portfolio script section.
After all the portfolio's instruments have been assigned a ranking value the portfolio can be sorted. Sorting in the Portfolio Manager is performed automatically right after all the instruments have been processed by the Filter Portfolio script section as long as there is code in the Filter Portfolio script section. Sorting changes the order in which the instruments are sequenced during testing and order generation.
Ranking, Filtering and Sorting methods can easily be performed in other script sections. Ranking and Filtering can be performed in other script sections. For example script sections that also process each instrument for each record in a data series like Before Instrument Day, Update Indicators and After Instrument Day they get the same exposure that is provided by the Rank Instrument script section. In addition script section Before Trading Day and After Trading Day script section.
Ranking, Filtering and Sorting can also be performed in each of the Before Trading Day and After Trading Day script sections. When sorting is performed in either of these two scripts they can use any of the many System Object's sorting functions to change how instruments are sorted. When no code is listed in the Filter Portfolio section and the rules of the system require the portfolio to be sorted, sorting can be performed in the Before Trading Day script section the Rank Instrument script was used to provide a ranking value. When a ranking is performed in Update Indicators or After Instrument Day script sections instead of in Rank Instrument script, ranking can also be performed in the After Instrument Day script section
These scripts section will execute for a test date where an instrument date record is not available. This means when a test date is being processed and an instrument does not have a matching instrument data date record on which an order can be filled, or a position can be adjusted this script section will process the last know instrument date.
Edit Time: 5/10/2017 7:31:04 AM
Topic ID#: 464