Trading Blox Builder has three Instrument and one System property that can be used to know the data class specified by the system's selected portfolio.
Instrument Object: .isForex, .isFuture, & .isStock
System Object: .portfolioType
These instrument properties and the system property return the asset class of the instrument. The instrument asset class is assigned during data load phase of a system/suite test. Result returned is based on which of the selected data class options is selected.
Instrument properties return a TRUE, " 1 ", or a FALSE, "0"
•For example, stocks can be loaded from the stock dictionary, or directly from the data file.
•Futures and Forex instruments are loaded from the Forex or Futures Dictionaries.
•Any instrument loaded from a dictionary will be assigned that dictionary's class designation.
The System object property called “.portfolioType” that returns the portfolio selection, stock, futures, or forex.
System property will return a string result
FX = "Forex"
F = "Future"
S = "Stock"
Syntax: - Class Data = Instrument Property
|
' When a Forex instrument is loaded so it is
' in context, use this to determine
If instrument.IsForex THEN
' Update Instrument Class
sInstrumentClass = "Forex"
ELSE
If instrument.IsFuture THEN
' Update Instrument Class
sInstrumentClass = "Future"
ELSE
If instrument.IsStock THEN
' Update Instrument Class
sInstrumentClass = "Stock"
ENDIF ' i.IsStock
ENDIF ' i.IsFuture
ENDIF ' i.isForex
|
Syntax: - Class Data = System Property
|
' Get System Portfolio Class
sPortfolioClass = system.portfolioType
' Or
PRINT "system.portfolioType :", system.portfolioType
|
Parameter:
|
Description:
|
<none>
|
|
Example: - Class Data: Instrument Context - System All Scripts
|
' =====================================================
' BEFORE TEST - START
' =====================================================
PRINT
PRINT
' Show Script Section name
PRINT "Script Name: ", block.scriptName
' Show System's Portfolio name
PRINT "Portfolio Name: ", system.portfolioName
' Show System Selected Instrument Class
PRINT "system.portfolioType :", system.portfolioType
PRINT " ---------------------------------"
' =====================================================
' BEFORE TEST - END
' =====================================================
================== Script_Change:
' =====================================================
' BEFORE INSTRUMENT DAY - START
' =====================================================
PRINT
' Show Script Section name
PRINT "Script Name: ", block.scriptName
' Show System's Portfolio name
PRINT "Portfolio Name: ", system.portfolioName
' Get System Portfolio Class
sPortfolioClass = system.portfolioType
PRINT "system.portfolioType :", system.portfolioType
' When a Forex instrument is loaded so it is
' in context, use this to determine
If instrument.IsForex THEN
' Update Instrument Class
sInstrumentClass = "Forex"
ELSE
If instrument.IsFuture THEN
' Update Instrument Class
sInstrumentClass = "Future"
ELSE
If instrument.IsStock THEN
' Update Instrument Class
sInstrumentClass = "Stock"
ENDIF ' i.IsStock
ENDIF ' i.IsFuture
ENDIF ' i.isForex
PRINT
PRINT "Instrument Portfolio Class is: ",
PRINT " ---------------------------------"
' =====================================================
' BEFORE INSTRUMENT DAY - END
' =====================================================
|
Returns: - Class Data: Instrument Context - System All Scripts
|
' -------------------------------------------------------------
' Example Output was created by changing the System Instrument
' Type selection and system portfolio from one available in
' of the three instrument type options.
' -------------------------------------------------------------
Script Name: Before Test
Portfolio Name: All Sample
system.portfolioType : FX:
---------------------------------
Script Name: Before Instrument Day
Portfolio Name: All Sample
system.portfolioType : FX:
Instrument Symbol: AUDUSD
Instrument Portfolio Class is: Forex
---------------------------------
Script Name: Before Test
Portfolio Name: Any Stock
system.portfolioType : S:
---------------------------------
Script Name: Before Instrument Day
Portfolio Name: Any Stock
system.portfolioType : S:
Instrument Symbol: AAPL
Instrument Portfolio Class is: Stock
---------------------------------
Script Name: Before Test
Portfolio Name: AnySelected
system.portfolioType : F:
---------------------------------
Script Name: Before Instrument Day
Portfolio Name: AnySelected
system.portfolioType : F:
Instrument Symbol: CT2
Instrument Portfolio Class is: Future
---------------------------------
|
Edit Time: 9/21/2020 2:29:35 PM
|
|
Topic ID#: 54
|