The ranking functions are usually used in the Portfolio Manager to set ranking values and to filter the instrument from the portfolio.  They can also be used in other script section when a custom portfolio process is needed, or when a ranking property needs to be changed.

 

Note that only instruments that are primed and ready to trade will be ranked. Other markets will be excluded from the ranking process.

 

Set the long ranking value and the short ranking value in the Rank Instruments script of the Portfolio Manager block. Then in the Filter Portfolio script the long rank and short rank will be available using the properties instrument.longRank and instrument.shortRank. The long ranking value is sorted highest to lowest to determine the long rank. The short ranking value is sorted lowest to highest to determine the short rank.

 

In the case of equal ranking values, the instruments will be sorted alphabetically.l

 

In the time between the execution of the Rank Instruments script and the Filter Portfolio script, the system sorts all the instruments based on the short and long ranking value.

 

Function Name:

Description:

SetLongRankingValue()

Sets the long ranking value. Sorted highest to lowest.

SetShortRankingValue()

Sets the short ranking value. Sorted lowest to highest.

SetCustomSortValue()

Set the value in the instrument.customSortValue.

 

An instrument's ranking values can also be set in others scripts, such as in a manual instrument loop in the Before Test, or Before Trading Day script sections.  These two scripts don't provide Automatic Instrument Context.  To work with an instrument in script sections where instrument context is not there automatically, you can use the LoadSymbol function and examples to update instruments.

 

When scripting is providing the updates, the following

Set the Long Ranking and/or Short Ranking values an each instrument until all instruments you want to update are processed.

Next, execute the system.RankInstruments function.

When the order of instruments need to be sorted, execute one of the system.SortInstrumentList( method# ) funtions.

Retrieve the Long Rank and Short Rank from each instrument

 

In addition, the custom sort value is available for use by the system.SortInstrumentList( method ) function.

Property: instrument.customSortValue

Function: instrument.SetCustomSortValue( value )

 

The Custom Sort Value can also be set in other scripts, just like the ranking Values.

-- Loop over each instrument setting the custom sort value

-- call system.sortInstrumentList(4)

-- Loop over each instrument and note how the instrument list has been sorted

 

Once the instrument list is sorted using the SortInstrumentList function, the Entry Orders script and other instrument scripts will execute in a new order.

 

Links:

Ranking Properties

See Also:

Instruments, System

 


Edit Time: 9/25/2017 09:09:58 AM


Topic ID#: 484

Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software