Script Language for PC-SPAN v.4.05 and SPAN Risk Manager

Scripting Utility



PC-SPAN version 4's scripting component is available as a separate utility, called spanit. You can call it from the command line or batch file by issuing the following command:



           spanit fileName



Where fileName is a fully specified pathname of the script file. Scripting component will attempt to execute commands in the script file and will return 0 if successful and 1 if any significant error is encountered.



If you have the SPAN Risk Manager-Clearing software, the scripting component is called spanitrm.  You work with this component in exactly the same manner as you do with spanit.  The only difference is that the script commands available in spanitrm are a superset of those available in spanit.

General Scripting Rules



Script should be written as a regular ASCII file. There are no restrictions on the naming of the file other than restrictions placed by the file system. Every command in the file should be on a separate line (CR serves as a delimiter). Parameters for commands are delimited by comma (any number of spaces between parameters is allowed). Any number of empty lines is allowed between commands. Comments should be placed on separate lines. Comment lines should start with “//”, though any line which starts with something other than one of command keywords will be considered a comment. Script language is case insensitive, however it is recommended that all commands are entered exactly as described in this document for clarity of the script. Any text after the last possible parameter for every command will be ignored. However it is not recommended to exploit this feature for writing comments – it might slow down script processing and can cause your scripts to stop working with future versions of PC-SPAN batch.

Command List


 

SPANIT and SpanitRM-Clearing

 

SpanitRM-Clearing Only

 

Calc

 

ApplyVolatilitySkew

 

CopyPointInTime

 

ApplyWhatIf

 

Delete

 

CalcCallPutAverage

 

Load

 

CalcImpliedVolatility

 

Log

 

CalcPrice

 

LogClear

 

CalcRiskArray

 

LogSave

 

CalcSeriesVolatility

 

ResetPointInTime

 

CalcValues

 

Save

 

DoMarketObservation

 

SaveCalcSummary

 

ReplicateBasePrices

 

SavePortfolios

 

ResetBFCC

 

SavePositions

 

ResetExchangeComplex

 

SelectPointInTime

 

ResetMarketPrices

 

Print

 

ResetPeriods

 

PC-SPAN + PC Credit and PC-SPAN RM Clearing + PC Credit

 

ResetPrices

 

SaveCDSPositions

 

ResetProductFamily

 

 

 

SaveVarSummary

 

 

 

SelectBFCC

 

 

 

SelectExchangeComplex

 

 

 

SelectProductFamily

 

 

 

SetStartPeriod

 

 

 

UpdateDividendYield

 

 

 

UpdatePrice

 

 

 

UpdatePriceScan

 

 

 

UpdateRiskFreeRate

 

 

 

UpdateTimeToExpiration

 

 

 

UpdateVolatility

 

 

 

UpdateVolScan


Commands Available in Both SPANIT and SPANITRM-Clearing

Load fileName [(NOREPLACE |,USEXTLAYOUT)][,busDate [,settleFlag [(,finalFlag | ,busTime)[, description]]]]



Description:

Load file specified in filename into SPAN Risk Manager



Parameters:



Ø     fileName           fully specified path name of the file to load (required)

Ø     busDate            business date in YYYYMMDD format (optional)

Ø     settleFlag         S(settle) or I(intraday) (optional)

Ø     finalFlag          E(early) or F(final) (optional)

Ø     busTime            business time in HHMM format (optional)

Ø     description       point in time description (optional)



Remarks:

Use this command to load files into SPAN Risk Manager. It supports all file formats: *.par, *.pa2, .txt (positions file), and XML. NOREPLACE flag specifies that PC-SPAN should not replace already loaded exchange complexes with the ones from the file (it replaces by default). Other optional parameters could be used if you are loading positions file (.txt or XML format - *.pos). USEXTLAYOUT flag is useful when you are loading a *.txt positions file with Span4 extended layout and want to use this layout (have risk parameter file in XML format). The rest of the parameters specify the point in time where positions should be loaded. If these parameters are not specified (by default) positions will be loaded into the point in time specified in the positions file. If this point in time is not present first available point in time will be used. It is not necessary to fully specify point in time – in most cases just date is sufficient to identify point in time.

Calc [busDate [,settleFlag [(,finalFlag | ,busTime)[, description]]]] [[,]PORTFOLIO [,firmCode [,acctCode [,segType]]]] 



Description:

Calculate portfolios loaded into SPAN Risk Manager.



Parameters:



Ø     busDate            business date in YYYYMMDD format (optional)

Ø     settleFlag         S(settle) or I(intraday) (optional)

Ø     finalFlag          E(early) or F(final) (optional)

Ø     busTime            business time in HHMM format (optional)

Ø     description       point in time description (optional)

Ø     firmCode          firm code for portfolio (optional)

Ø     acctCode          account code for portfolio (optional)

Ø     segType            segregation type for portfolio CUST or HOUS (optional)



Remarks:

Use this command to calculate portfolios loaded into SPAN Risk Manager. If no optional parameters are specified all portfolios will be calculated. If some of the parameters specifying point in time are present only portfolios for corresponding points in time will be calculated. Use this command to calculate portfolios loaded into SPAN Risk Manager. If no optional parameters are specified all portfolios will be calculated. If some of the parameters specifying point in time are present only portfolios for corresponding points in time will be calculated. It is not necessary to fully specify point in time – in most cases just date is sufficient to identify point in time. If, in addition to point in time, some parameters specifying particular portfolio are present only corresponding portfolios from the specified point in time will be calculated.



Delete [busDate [,settleFlag [(,finalFlag | ,busTime)[, description]]]] [[,]PORTFOLIO [,firmCode [,acctCode [,segType]]]] 



Description:

Calculate portfolios loaded into SPAN Risk Manager.



Parameters:



Ø     busDate            business date in YYYYMMDD format (required)

Ø     settleFlag         S(settle) or I(intraday) (optional)

Ø     finalFlag          E(early) or F(final) (optional)

Ø     busTime            business time in HHMM format (optional)

Ø     description       point in time description (optional)

Ø     firmCode          firm code for portfolio (optional)

Ø     acctCode          account code for portfolio (optional)

Ø     segType            segregation type for portfolio CUST or HOUS (optional)



Remarks:

Use this command to delete portfolios and risk parameters loaded into SPAN Risk Manager. If no optional parameters are specified all portfolios and risk arrays will be deleted. If some of the parameters specifying point in time are present only this points in time corresponding to these parameters will be deleted. It is not necessary to fully specify point in time – in most cases just date is sufficient to identify point in time. If, in addition to point in time, some parameters specifying particular portfolio are present only portfolios corresponding to these parameters in the specified (or first) point in time will be deleted.



Save fileName



Description:

Save  SPAN Risk Manager results into the file specified in filename



Parameters:



Ø     fileName            fully specified path name of the file (required)



Remarks:

Use this command to save SPAN Risk Manager calculation results into the file. Results will be saved in the XML file format.



SaveCalcSummary fileName



Description:

Save PB Calculation Summary file to the file specified in filename in .CSV format



Parameters:



Ø     fileName            fully specified path name of the file (required)



Remarks:

Use this command to save SPAN Performance Bond calculation results into the specified file. Results will be saved in the .CSV file format.



Log [processLimit][,priorityLimit



Description:

Specifies parameters for logging.



Parameters:



Ø     processLimit            upper limit for process id of the log message source (required)

Ø     priorityLimit            lower limit for the log message priority (optional)



Remarks:

Use this command to specify logging parameters for SPAN Risk Manager. You can issue this command in any place within your script. Possible values for parameters are:



For processLimit:



PROC_ID_LOAD_RISK                            = 10;

PROC_ID_LOAD_POS                              = 20;

PROC_ID_LOAD_XML                             = 30;

PROC_ID_OMNIBUS                                = 40;

PROC_ID_CALC_START                          = 51;

PROC_ID_CALC_PBOND                         = 60;

PROC_ID_CALC_SPREAD                       = 70;

PROC_ID_CALC_LIQ_RISK                     = 80;

PROC_ID_CALC_DETAIL_START          = 101;

PROC_ID_CALC_SPREAD_DETAIL        = 110;

PROC_ID_CALC_LIQ_RISK_DETAIL      = 120;

PROC_ID_CALC_POS_DETAIL                = 130;

PROC_ID_UPPER                                       = -1;



For priorityLimit:

PRIORITY_ID_LOW                                   = -1;

PRIORITY_ID_NORMAL                           = 10;

PRIORITY_ID_WARNING                         = 20;

PRIORITY_ID_ERROR                               = 30;

Default values are 0 and 30 (only errors are logged).

LogSave fileName



Description:

Saves log into specified file.

Parameters:

Ø     fileName            fully specified path name of the file for log (required)

Remarks:

Use this command to save SPAN Risk Manager log. You can issue this command in any place within your script.

SavePortfolios fileName



Description:

Saves portfolio into specified file in XML format.

Parameters:

Ø     fileName            fully specified path name of the file for portfolios (required)



Remarks:

Use this command to save SPAN portfolios to a file. Results will be saved in the XML format.



SavePositions fileName 



Description:

Saves positions into the specified file in XML format.

Parameters:

Ø     fileName            fully specified path name of the file for positions (required)

Remarks:

Use this command to save SPAN positions to a file. Results will be saved in the XML format.



LogClear



Description:

Clears out the SPAN log.



Parameters:


Remarks:

Use this command to clear out the log.



CopyPointInTime description [,busDate [,settleFlag [,finalFlag | ,busTime]]]



Description:

Copy selected Point In Time into the Point In Time specified by the command attributes.



Parameters:



Ø     description       point in time description, can be empty string

Ø     busDate            business date in YYYYMMDD format (optional)

Ø     settleFlag         S(settle) or I(intraday) (optional)

Ø     finalFlag          E(early) or F(final) (optional)

Ø     busTime            business time in HHMM format (optional)



Remarks:

Use this command to copy Point In Time. This command creates new Point In Time object exactly matching the selected Point In Time. Attributes of the newly created Point In Time will be changed using parameters specified for the command. If Point In Time with these attributes already exists an error will be generated. Point In Time should be selected prior to using this command. If no Point In Time is selected an error will be generated. This command does not affect selected Point In Time.

ResetPointInTime



Description:

Resets Point In Time selection.



Parameters:


Remarks:

Use this command to reset Point In Time selection. Also resets Exchange Complex, BFCC and Product Family.



SelectPointInTime [busDate [,settleFlag [(,finalFlag | ,busTime)[, description]]]]



Remarks:

Select Point In Time for use in the following Calc and Update commands.



Parameters:



Ø     busDate            business date in YYYYMMDD format (optional)

Ø     settleFlag         S(settle) or I(intraday) (optional)

Ø     finalFlag          E(early) or F(final) (optional)

Ø     busTime            business time in HHMM format (optional)

Ø     description       point in time description (optional)



Remarks:

Use this command to select Point In Time for use in the Calc and Update commands. If no optional parameters are specified first available Point In Time will be selected. It is not necessary to fully specify Point In Time – in most cases just date is sufficient to identify Point In Time.



Print [DateTime] [,SelPIT] [,AllPIT] [,SelExc] [,SelBFCC] [,SelPf] [,StartPeriod] [,EndPeriod]



Remarks:

Print a variable to the screen. Any of the following variables may be printed.



Parameters:



Ø     DateTime            Displays the current date and time.

Ø     SelPIT                 Displays the selected point in time.

Ø     AllPIT                 Displays all of the loaded points in time.

Ø     SelExc                (SpanitRM only) Displays the currently selected exchange.

Ø     SelBFCC            (SpanitRM only) Displays the currently selected BFCC.

Ø     SelPf                  (SpanitRM only) Displays the currently selected product family.

Ø     StartPeriod        (SpanitRM only) Displays the specified start period.

Ø     EndPeriod          (SpanitRM only) Displays the specified end period.



Remarks:

Use this command to display various points of data from within Spanit / SpanitRM to the screen. This command is more for diagnostic purposes only, and will not impact any data or calculations.


Additional commands available only in SPAN Risk Manager-Clearing:

SaveVarSummary fileName

Description:

Save Variation Calculation Summary file to the file specified in filename in .CSV format

SelectExchangeComplex excAcro 

Description:

Select Exchange Complex for use in the following Calc and Update commands.

Parameters:

Ø     excAcro            exchange complex acronym (required)

Remarks:

Use this command to select Exchange Complex for use in the Calc and Update commands. Point In Time should be already selected prior to using this command. If no Point In Time is selected an error will be generated.

SelectBFCC ccCode 

Description:

Select BFCC for use in the following Calc and Update commands.

Parameters:

Ø     ccCode                        combined commodity code (required)

Remarks:

Use this command to select BFCC for use in the Calc and Update commands. Exchange Complex should be already selected prior to using this command. If no Exchange Complex is selected an error will be generated.

SelectProductFamily exchCode ,pfCode ,pfType 

Description:

Select Product Family for use in the following Calc and Update commands.

Parameters:

Ø     exchCode        exchange code (required)

Ø     pfCode             product family code (required)

Ø     pfType             product family type (required)

Remarks:

Use this command to select Product Family for use in the Calc and Update commands. BFCC should be already selected prior to using this command. If no BFCC is selected an error will be generated.

Possible values for pfType:

PHY                - physical

FUT                 - future

CMB               - combination

EQTY              - equity (stock)

DEBT              - debt

EDEBT            - debt equivalence

OOP                - option on physical

OOF                - option on future

OOC                - option on combination

OOS                - option on stock

SetStartPeriod periodCode

Description:

Set Starting Period for the period range used in Update commands.

Parameters:

Ø     periodCode            period code in YYYYMM format (required)

Remarks:

Use this command to set Starting Period for the period range for use in Update commands. Product Family should be already selected prior to using this command. If no Product Family is selected an error will be generated.

SetEndPeriod periodCode

Description:

Set Ending Period for the period range used in Update commands.

Parameters:

Ø     periodCode            period code in YYYYMM format (required)

Remarks:

Use this command to set Ending Period for the period range for use in Update commands. Product Family should be already selected prior to using this command. If no Product Family is selected an error will be generated.

ReplicateBasePrices [busDate [,settleFlag [(,finalFlag | ,busTime)[, description]]]]

Remarks:

Replicate prices from a corresponding earlier point in time (presuming the earlier point in time is loaded).

Parameters:

Ø     busDate            business date in YYYYMMDD format (optional)

Ø     settleFlag         S(settle) or I(intraday) (optional)

Ø     finalFlag          E(early) or F(final) (optional)

Ø     busTime            business time in HHMM format (optional)

Ø     description       point in time description (optional)

Remarks:

Use this command to copy from an earlier point in time into the current point in time, assuming the earlier point in time is already loaded.

ResetExchangeComplex 

 Description:

Resets Exchange Complex selection.

 Parameters:


Remarks:

Use this command to reset Exchange Complex selection. Also resets BFCC and Product Family.

ResetBFCC

Description:

Resets BFCC selection.

Parameters:


Remarks:

Use this command to reset BFCC selection. Also resets Product Family.

ResetMarketPrices

Description:

Resets market prices.

Parameters:


Remarks:

Use this command to reset market prices.

ResetProductFamily

Description:

Resets Product Family selection.

Parameters:


Remarks:

Use this command to reset Product Family selection.

ResetPeriods

Description:

Resets Period Range selection.

Parameters:


Remarks:

Use this command to reset Period Range selection.

ResetPrices [productType

Description:

Place prices for option instruments in the SPAN file in an undefined state.

Parameters:

Ø     productType                        product type code (optional)

Remarks:

Use this command to place prices for option instruments in the SPAN file in an undefined state.

Possible values for productType:

-1 = Futures Only

-2 = Options Only

0 = All Products (default)

1 = PHY

2 = DEBT

3 = STOCK

11 = FUT

13 = FWDC

14 = FWD

15 = IRS

16 = EDEBT

17 = CDS

21 = OOP

22 = OOF

23 = OOS

24 = OOPC

25 = OOPD

31 = CMB

41 = OOC

CalcImpliedVolatility

Description:

Calculates Implied Volatilities for selected object.

Parameters:


Remarks:

Use this command to Calculate Implied Volatilities. It works on the lowest level object already selected (product family, bfcc, exchange complex, point in time). If point in time is not selected it will work on all loaded points in time.

CalcCallPutAverage

Description:

Does Call/Put Averaging for selected object.

Parameters:


Remarks:

Use this command to do Call/Put Averaging. It works on the lowest level object already selected (product family, bfcc, exchange complex, point in time). If point in time is not selected it will work on all loaded points in time.

CalcSeriesVolatility useZero,  minExpTime, maxIn, maxOut,  minAccept

Description:

Calculates Series Level Volatilities for selected object.

Parameters:

Ø  useZero           true means do not filter out zero implied volatilities during calculations (optional)

Ø  minExpTime    minimum time to expiration in years (optional)

Ø  maxIn              number of closest in the money options which volatilities will be used in calculations (optional)

Ø  maxOut           number of closest out of the money options which volatilities will be used in calculations (optional)

Ø minAccept       minimum sufficient number of around the money volatilities (optional)

Remarks:

Use this command to Calculate Series Level Volatilities. It works on the lowest level object already selected (product family, bfcc, exchange complex, point in time). If point in time is not selected it will work on all loaded points in time.

Possible values for useZero:

0                - FALSE

1                - TRUE, default

Possible values for minExpTime:

any positive number

0.0273973 (10 business days) - default

Possible values for maxIn:

any positive integer

1 - default

Possible values for maxOut:

any positive integer

3 - default

Possible values for minAccept:

any positive integer

5 - default

CalcPrice meth, resetAll

Description:

Calculates Theoretical Prices for selected object.

Parameters:

Ø     meth            calculation method code (optional)

Ø     resetAll       reset prices flag (optional)

Remarks:

Use this command to Calculate Theoretical Prices. It works on the lowest level object already selected (product family, bfcc, exchange complex, point in time). If point in time is not selected it will work on all loaded points in time.

Possible values for meth:

1                - use option/series level volatility, default

2                - use option level volatility only

3                - use series level volatility only

Possible values for resetAll:

0                - FALSE, reset prices only for contracts with undefined price

1                - TRUE, reset prices for all contracts, default

CalcRiskArray meth, limitAtOptValue

Description:

Calculates Risk Arrays for selected object.

Parameters:

Ø     meth                         calculation method code (optional)

Ø     limitAtOptValue       limit risk array values flag (optional)

Remarks:

Use this command to Calculate Risk Arrays. It works on the lowest level object already selected (product family, bfcc, exchange complex, point in time). If point in time is not selected it will work on all loaded points in time.

Possible values for meth:

1                - use option/series level volatility, default

2                - use option level volatility only

3                - use series level volatility only

Possible values for limitAtOptValue:

0                - FALSE, do not limit risk array values, default

1                - TRUE, limit risk array values at option value

CalcValues

Description:

Calculates a portfolios value.

Parameters:


Remarks:

Calculates a portfolio's value based upon current prices


DoMarketObservation

Description:

Performs a market observation.

Parameters


Remarks:

Use this command to do a market observation.

UpdatePrice value [,method

Description:

Updates Prices for selected object.

Parameters:

Ø     value               update value (required)

Ø     method             update method (optional)

Remarks:

Use this command to Update Prices. It works on the lowest level object already selected (product family, bfcc, exchange complex, point in time). If point in time is not selected it will work on all loaded points in time. It will update prices using value and one of the following methods:

Possible values for method:

SET                 - set price to value

CHG                - change price by value

PCNT              - change price by value %

SET is the default method

UpdateVolatility value [,method

Description:

Updates Volatilities for selected object.

Parameters:

Ø     value               update value (required)

Ø     method             update method (optional)

Remarks:

Use this command to Update Volatilities. It works on the lowest level object already selected (product family, bfcc, exchange complex, point in time). If point in time is not selected it will work on all loaded points in time. It will update volatilities using value and one of the following methods:

Possible values for method:

SET                 - set volatility to value

CHG                - change volatility by value

PCNT              - change volatility by value %

SET is the default method

UpdatePriceScan value [,method

Description:

Updates Price Scans for selected object.

Parameters:

Ø     value               update value (required)

Ø     method            update method (optional)

Remarks:

Use this command to Update Price Scans. It works on the lowest level object already selected (product family, bfcc, exchange complex, point in time). If point in time is not selected it will work on all loaded points in time. It will update price scans using value and one of the following methods:

Possible values for method:

SET                 - set price scan to value

CHG                - change price scan by value

PCNT              - change price scan by value %

SET is the default method

UpdateVolScan value [,method

Description:

Updates Volatility Scans for selected object.

Parameters:

Ø     value               update value (required)

Ø     method             update method (optional)

Remarks:

Use this command to Update Volatility Scans. It works on the lowest level object already selected (product family, bfcc, exchange complex, point in time). If point in time is not selected it will work on all loaded points in time. It will update volatility scans using value and one of the following methods:

Possible values for method:

SET                 - set volatility scan to value

CHG                - change volatility scan by value

PCNT              - change volatility scan by value %

SET is the default method

UpdateRiskFreeRate value [,method

Description:

Updates Risk-Free Rates for selected object.

Parameters:

Ø     value               update value (required)

Ø     method            update method (optional)

Remarks:

Use this command to Update Risk-Free Rates. It works on the lowest level object already selected (product family, bfcc, exchange complex, point in time). If point in time is not selected it will work on all loaded points in time. It will update risk-free rates using value and one of the following methods:

Possible values for method:

SET                 - set risk-free rate to value

CHG                - change risk-free rate by value

PCNT              - change risk-free rate by value %

SET is the default method

UpdateDividendYield value [,method

Description:

Updates Dividend Yields for selected object.

Parameters:

Ø     value               update value (required)

Ø     method            update method (optional)

Remarks:

Use this command to Update Dividend Yields. It works on the lowest level object already selected (product family, bfcc, exchange complex, point in time). If point in time is not selected it will work on all loaded points in time. It will update dividend yields using value and one of the following methods:

Possible values for method:

SET                 - set dividend yield to value

CHG                - change dividend yield by value

PCNT              - change dividend yield by value %

SET is the default method

UpdateTimeToExpiration value [,method

Description:

Updates Times To Expiration for selected object.

Parameters:

Ø     value               update value (required)

Ø     method            update method (optional)

Remarks:

Use this command to Update Times To Expiration. It works on the lowest level object already selected (product family, bfcc, exchange complex, point in time). If point in time is not selected it will work on all loaded points in time. It will update times to expiration using value and one of the following methods:

Possible values for method:

SET                 - set time to expiration to value

CHG                - change time to expiration by value

PCNT              - change time to expiration by value %

SET is the default method


ApplyWhatIf fileName [,DO_CALC]

Description:

Applies what-if scenario stored in the XML file fileName to the selected Point In Time. Requires Point In Time to be selected.

Parameters:

Ø     fileName            fully specified path name of the what-if scenario XML file (required)

Remarks:

Use this command to apply what-if  scenario stored in the XML file fileName to the selected Point In Time. Thtypical sequence of actions before using this command would include creation of a copy of a particular Point In Time. What-if scenario is applied to this copy:

SelectPointInTime

CopyPointInTime

SelectPointInTime

ApplyWhatIf

If DO_CALC flag is specified following actions are performed on the selected PointInTime after applying what-if scenario:

CalcPrice

CalcRiskArray

Calc

ApplyVolatilitySkew [SkewMethod]

Description:

Skew volatility curve following a particular skew method.

Parameters:

Ø     SkewMethod             skew method (optional)

Remarks:

Use this command to skew the volatility curve.

Possible values for SkewMethod:

0              - shifts the curve horizontally only

1              - shifts the curve horizontally, vertical shift by Call/Put

2              - shifts the curve horizontally, vertical shift by closest at the money or the average of Call/Put

0 is the default method


Additional commands available in PC-SPAN + PC Credit and PC-SPAN RM Clearing + PC Credit

SaveCDSPositions fileName

Description:

Saves CDS (Credit Default Swap) positions into the specified file in XML format.

Parameters:

Ø     fileName            fully specified path name of the file for CDS positions (required)

Remarks:

Use this command to save SPAN CDS positions to a file. Results will be saved in the XML format.




How was your SPAN Site Experience? Submit Feedback

Copyright © 2024 CME Group Inc. All rights reserved.