Child pages
  • Component Interface for Version 4 of PC-SPAN, SPAN Risk Manager, and SPAN Risk Manager Clearing

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

real-time component interface is is available for PC-SPAN version 4.   With this additional software module, licensed separately as SPAN Real-Time Component Interface (SPAN RTCI), you can develop programs which interface to PC-SPAN in real-time.

...

The SPAN Risk Manager Clearing software also has a real-time component interface.   With this software module, in addition to everything you can do with the component interface to PC-SPAN, you can develop programs which execute the functions of the SPAN Risk Manager Clearing in real-time.

For example, you could programmatically update market prices for futures and physicals, and then recalculate volatilities, theoretical prices and risk arrays, with extremely fast.

This topic provides a technical reference to the real-time component interfaces for PC-SPAN, SPAN Risk Manager, and SPAN Risk Manager Clearing.

Table of Contents
 


...

Below is an example of calling the component interface from Visual C++ code. 

...

Description:

Load any SPAN recognized file into PC-SPAN, including SPAN files (*.SPN), classic "flat-files" (*.PA2), position files (*.txt and *.pos), etc. All position files (*.txt and *.pos) require corresponding risk parameter files to be already loaded. Positions are loaded into the currently selected point in time. If this point in time is not present positions are loaded into the first available point in time. 

For more details on supported file formats, click here.

Parameters:

  • fileName - BSTR - The document to be loaded.
  • replaceExc - bool - Specifies whether PC-SPAN should replace already loaded exchange complexes with the ones from the file (true) or leave them intact (false)
  • useExtLayout - bool - Specifies whether PC-SPAN should use extended file layout when loading positions. It is only used for loading old format position files (*.txt).

Return Value:

short - Return value can be 0 (success) or non-zero (failure).

short Save(BSTR fileName);

Description:

Saves all the information from PC-SPAN into a file.

Parameters:

  • fileName - BSTR - The name of document to be saved, in the SPAN XML format.

Return Value:

short - Return value can be 0 (success) or non-zero (failure).

...

void ResetPortfolio();

Description:

Sets currently selected portfolio to NULL (removes selection).

Parameters:

None

Remarks:

When this call is made, the portfolio is still available. It is no longer selected as the active portfolio. The point in time selection is not affected by this call.

Return Value:

None

Anchor
Calculate
Calculate
short Calculate();

Description:

Performs SPAN requirements calculations for the currently selected object. If portfolio selection is not NULL it does calculations only for the selected portfolio. If it is NULL and point in time selection is not NULL it does calculations for all portfolios in the selected point in time. If both selected portfolio and selected point in time are NULL it does calculations for all points in time and portfolios loaded into PC-SPAN.

Parameters:

None

Return Value:

short - Return value can be 0 (success) or non-zero (failure).

double GetPortfSpanReq(short pbClass, boolean isInitial);

Description:

Returns SPAN requirement calculated for the selected portfolio. If a portfolio is not selected (NULL) or if Calculate has not been called, the return is 0.

Parameters:

  • pbClass - short - Specifies the class of the requirement. It can be 1(CORE) or 2(RESERVE).
  • isInitial - boolean - Indicates maintenance (false) or initial (true) requirement.

Return Value:

double - Returns SPAN requirement calculated for the selected portfolio.

double GetPortfTotalReq(short pbClass, boolean isInitial);

Description:

Returns Total requirement calculated for the selected portfolio. If a portfolio is not selected (NULL) or if Calculate has not been called, the return is 0.

Parameters:

  • pbClass - short - Specifies the class of the requirement. It can be 1(CORE) or 2(RESERVE).
  • isInitial - boolean - Indicates maintenance (false) or initial (true) requirement.

Return Value:

double - Returns Total requirement calculated for the selected portfolio.

double GetCurPortfSpanReq(short pbClass, boolean isInitial, BSTR curCode);

Description:

Returns SPAN requirement calculated for the selected portfolio for the specified currency. If a portfolio is not selected (NULL), or if an invalid curCode is passed, or if Calculate has not been called, the return is 0.

Parameters:

  • pbClass - short - Specifies the class of the requirement. It can be 1(CORE) or 2(RESERVE).
  • isInitial - boolean - Indicates maintenance (false) or initial (true) requirement.
  • curCode - BSTR - Specifies the currency code to get the Span requirement in.

Return Value:

double - Returns SPAN requirement calculated for the selected portfolio for the specified currency.

double GetCurPortfTotalReq(short pbClass, boolean isInitial, BSTR curCode);

Description:

Returns Total requirement calculated for the selected portfolio for the specified currency. If a portfolio is not selected (NULL), or if an invalid curCode is passed, or if Calculate has not been called, the return is 0.

Parameters:

  • pbClass - short - Specifies the class of the requirement. It can be 1(CORE) or 2(RESERVE).
  • isInitial - boolean - Indicates maintenance (false) or initial (true) requirement.
  • curCode - BSTR - Specifies the currency code to get the Total requirement in.
  • curCode - BSTR - Specifies the currency code to get the Total requirement in.

Return Value:

double - Returns Total requirement calculated for the selected portfolio for the specified currency.

...

void SetLogLevel(short processId, short priorityId);

Description:

Use this method to specify logging level for PC-SPAN.

Parameters

  • processId - short - The upper limit for process id of the log message source. Possible values for processLimits are:
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;
  • priorityId - short - The lower limit for the log message priority. Possible values for the priorityId are:
PRIORITY_ID_LOW= -1;
PRIORITY_ID_NORMAL= 10;
PRIORITY_ID_WARNING= 20;
PRIORITY_ID_ERROR= 30;

Remarks:

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

Return Value:

None

...

short SetPortfAcctType(BSTR acctType, boolean isClearing);

Description:

Sets account type for the selected portfolio. If portfolio is not selected the call will fail. If the specified account type is not found in the organization master database the call will fail. The selected portfolio can not have positions already defined otherwise the call will fail.

Parameters:

  • acctType - BSTR - The account type for the selected portfolio. The following values are currently defined for the acctType:
N- normal
M- member
H- hedge
S- speculator
O- omnibus (speculator)
Q- omnibus (hedge).
  • isClearing - boolean - specifies whether account is customer(false) or clearing(true).

Return Value:

short - Returns 0 (success) or non-zero (failure).

...

short SetPortfPosition(BSTR exchCmplxAcro, BSTR exchAcro, BSTR pfCode, short pfType, BSTR futPeriod, BSTR optPeriod, boolean isPut, double strike, long totalLong, long totalShort, long intraLong, long intraShort, long interLong, long interShort, long nakedLong, longnakedShort);

Description:

Sets positions in the selected portfolio in the specified contract. If portfolio is not selected or contract can not be found the method will fail.

Parameters:

  • exchCmplxAcro - BSTR - The exchange complex acronym (“CME”, “BOTCC”, etc.)
  • exchAcro - BSTR - The exchange acronym (“CME”, “CBT”, etc.)
  • pfCode - BSTR - The product family code (“SP”, “BP”, etc.)
  • pfType - short - The product family type. Possible values are:
1- physical
2- debt
3- stock
11- future
12- equivalence debt
14- forward
15- interest rate swap
16- E-Debt
17- credit rate swap
21- option on physical
22- option on future
23- option on equity
31- combination
41- option on combination
  • futPeriod - BSTR - The period code for future contract (period code for the underlying contract for options). Format is usually YYYYMM, there are special cases like weeklies and flexes when some characters are added to this format (for example “200002W3”). For physicals, equity and options on physicals/equity this parameter should be set to “000000”.
  • optPeriod - BSTR - The period code for option contract. This parameter and following contract identification parameters are ignored for non-option contracts. Same format as futPeriod.
  • isPut - boolean - The put (true) or call (false) flag for options.
  • strike - double - The strike price for options. For CDS products, this is the coupon.
  • totalLong - long - The new value for total long positions. If portfolio is net based this value will be used for calculating net positions (Net = totalLong – totalShort)
  • totalShort - long - The new value for total short positions. If portfolio is net based this value will be used for calculating net positions (Net = totalLong – totalShort)
  • intraLong - long - The new value for intra long positions. If portfolio is net based this value is ignored. It is used for calculating number of naked positions (NakedLong = totalLong – intraLong - interLong)
  • intraShort - long - The new value for intra short positions. If portfolio is net based this value is ignored. It is used for calculating number of naked positions (NakedShort = totalShort – intraShort - interShort)
  • interLong - long - The new value for inter long positions. If portfolio is net based this value is ignored. It is used for calculating number of naked positions (NakedLong = totalLong – intraLong - interLong)
  • interShort - long - The new value for inter short positions. If portfolio is net based this value is ignored. It is used for calculating number of naked positions (NakedShort = totalShort – intraShort - interShort)
  • nakedLong - long - The new value for naked long positions. If portfolio is net based this value is ignored.
  • nakedShort - long - The new value in naked short positions. If portfolio is net based this value is ignored.

Remarks:

If number of positions specified is inconsistent totalLong < intraLong + intraShort or totalShort < intraShort + interShort, then method fails. If a portfolio hasn't been selected, the method will fail.

Return Value:

short - Returns 0 (success) or non-zero (failure).

short ChangePortfPosition(BSTR exchCmplxAcro, BSTR exchAcro, BSTR pfCode, short pfType, BSTR futPeriod, BSTR optPeriod, boolean isPut, double strike, long totalLong, long totalShort, long intraLong, long intraShort, long interLong, long interShort, long nakedLong, longnakedShort);

Description:

Modifies positions in the selected portfolio in the specified contract. If portfolio is not selected or contract can not be found method fails.

Parameters:

  • exchCmplxAcro - BSTR - The exchange complex acronym (“CME”, “BOTCC”, etc.)
  • exchAcro - BSTR - The exchange acronym (“CME”, “CBT”, etc.)
  • pfCode - BSTR - The product family code (“SP”, “BP”, etc.)
  • pfType - short - The product family type. Possible values are:
1- physical
2- debt
3- stock
11- future
12- equivalence debt
14- forward
15- interest rate swap
16- E-Debt
17- credit rate swap
21- option on physical
22- option on future
23- option on equity
31- combination
41- option on combination
  • futPeriod - BSTR - The period code for future contract (period code for the underlying contract for options). Format is usually YYYYMM, there are special cases like weeklies and flexes when some characters are added to this format (for example “200002W3”). For physicals, equity and options on physicals/equity this parameter should be set to “000000”.
  • optPeriod - BSTR - The period code for option contract. This parameter and following contract identification parameters are ignored for non-option contracts. Same format as futPeriod.
  • isPut - boolean - The put (true) or call (false) flag for options.
  • strike - double - The strike price for options. For CDS products, this is the coupon.
  • totalLong - long - The change in total long positions. If portfolio is net based this value will be used for calculating change in net positions (Net = totalLong – totalShort)
  • totalShort - long - The change in total short positions. If portfolio is net based this value will be used for calculating net positions (Net = totalLong – totalShort)
  • intraLong - long - The change in intra long positions. If portfolio is net based this value is ignored. It is used for calculating number of naked positions (NakedLong = totalLong – intraLong - interLong)
  • intraShort - long - The change in intra short positions. If portfolio is net based this value is ignored. It is used for calculating number of naked positions (NakedShort = totalShort – intraShort - interShort)
  • interLong - long - The change in inter long positions. If portfolio is net based this value is ignored. It is used for calculating number of naked positions (NakedLong = totalLong – intraLong - interLong)
  • interShort - long - The change in inter short positions. If portfolio is net based this value is ignored. It is used for calculating number of naked positions (NakedShort = totalShort – intraShort - interShort)
  • nakedLong - long - The change in naked long. If portfolio is net based this value is ignored.
  • nakedShort - long - The change in naked short. If portfolio is net based this value is ignored.

Remarks:

If number of positions specified is inconsistent totalLong < intraLong + intraShort or totalShort < intraShort + interShort, then method fails. If a portfolio hasn't been selected, the method will fail.

Return Value:

short - Returns 0 (success) or non-zero (failure).

...

short LoadStream(SAFEARRAY(BYTE) data);

Description:

Similar to the Load method, this method will load document passed directly in through the data parameter byte array. This method can bypass the need to save a newly constructed document to disk for the sole purpose of loading it in to SPAN.

Parameters:

  • data - SAFEARRAY(BYTE) - The stream of data representing a SPAN data document, such as a position file, to load in to SPAN.

Return Value:

short - Returns 0 (success) or non-zero (failure).

...

...


dispinterface ISpanComRM

methods:

...

short SelectProductFamily(BSTR exchCode, BSTR pfCode, short pfType);

Description:

Selects specified product family as current.

Parameters:

  • exchAcro - BSTR - The exchange acronym (“CME”, “CBT”, etc.)
  • pfCode - BSTR - The product family code (“SP”, “BP”, etc.)
  • pfType - short - The product family type. Possible values are:
1- physical
2- debt
3- stock
11- future
12- equivalence debt
14- forward
15- interest rate swap
16- E-Debt
17- credit rate swap
21- option on physical
22- option on future
23- option on equity
31- combination
41- option on combination

Remarks:

BFCC should be already selected prior to calling this method.

Return Value:

short - Returns 0 (success) or non-zero (failure).

...

short CalcPrice(short meth, boolean resetAll);

Description:

Calculates Theoretical Prices for selected object. 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.

Parameters:

  • meth - boolean - The calculation method code:
1- Use option/series level volatility
2- Use option level volatility only
3- Use series level volatility only
  • resetAll - An indication of true will reset prices for all contracts, false will reset prices only for contracts with undefined price

Return Value:

short - Returns 0 (success) or non-zero (failure).

short CalcRiskArray(short meth, short limitMeth, boolean useTheorPrice);

Description:

Calculates Risk Arrays for selected object. 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.

Parameters:

  • meth - short - The calculation method code:
1- Use option/series level volatility
2- Use option level volatility only
3- Use series level volatility only
  • limitMeth - short - The method of how risk array values will be limited:
0- Regular limit
1- Limit Loss Option
2- Limit Gain Option
3- Limit Option
4- Limit Range
5- Limit Loss Option Range
6- Limit Gain Option Range
7- Limit Option Range
  • useTheorPrice - boolean - An indication of true means to use theoretical prices.

Return Value:

short - Returns 0 (success) or non-zero (failure).

void UpdatePrice(double value, short meth);

Description:

Use this method 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 price using value and one of the methods below.

Parameters:

  • value - double - The price value
  • meth - short - The method to use for updating the price. Possible values for meth:
0(SET) - Set price to value.
1(CHG) - Change price by value
2(PCNT) - Change price by value %

Return Value:

None

void UpdateVolatility(double value, short meth);

Description:

Use this method 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 methods below.

Parameters:

  • value - double - The volatility value
  • meth - short - The method to use for updating the volatility. Possible values for meth:
0(SET) - Set volatility to value.
1(CHG) - Change volatility by value
2(PCNT) - Change volatility by value %

Return Value:

None

void UpdatePriceScan(double value, short meth);

Description:

Use this method 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 methods below.

Parameters:

  • value - double - The price scan value
  • meth - short - The method to use for updating the price scans. Possible values for meth:
0(SET) - Set price scan to value.
1(CHG) - Change price scan by value
2(PCNT) - Change price scan by value %

Return Value:

None

void UpdateVolScan(double value, short meth);

Description:

Use this method 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 methods below.

Parameters:

  • value - double - The volatility scan value
  • meth - short - The method to use for updating the volatility scans. Possible values for meth:
0(SET) - Set volatility scan to value.
1(CHG) - Change volatility scan by value
2(PCNT) - Change volatility scan by value %

Return Value:

None

void UpdateRiskFreeRate(double value, short meth);

Description:

Use this method 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 methods below.

Parameters:

  • value - double - The risk free rate value
  • meth - short - The method to use for updating the risk free rates. Possible values for meth:
0(SET) - Set risk free rate to value.
1(CHG) - Change risk free rate by value
2(PCNT) - Change risk free rate by value %

Return Value:

None

void UpdateDividendYield(double value, short meth);

Description:

Use this method 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 methods below.

Parameters:

  • value - double - The dividend yield value
  • meth - short - The method to use for updating the dividend yields. Possible values for meth:
0(SET) - Set dividend yield to value.
1(CHG) - Change dividend yield by value
2(PCNT) - Change dividend yield by value %

Return Value:

None

void UpdateTimeToExpiration(double value, short meth);

Description:

Use this method 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 time to expiration using value and one of the methods below.

Parameters:

  • value - double - The time to expiration value
  • meth - short - The method to use for updating the times to expiration. Possible values for meth:
0(SET) - Set time to expiration to value.
1(CHG) - Change time to expiration by value
2(PCNT) - Change time to expiration by value %

Return Value:

None

short UpdateCDSValue(short valueType, double value, short meth);

Description:

Use this method to Update credit default swap values. 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 a credit default swap value using value and one of the methods below.

Parameters:

  • valueType - short - The specific credit default swap shock to update. Possible values for valueType:
1- Systematic shock - Applies to combined commodity level
2- Convergence shock (IG_COMP) - Applies to Exchange Complex level
3- Divergence shock (HY_COMP) - Applies to Exchange Complex level
5- Sector shock - Applies to combined commodity level
  • value - double - The credit default swap value
  • meth - short - The method to use for updating the credit default swap values. Possible values for meth:
0(SET) - Set dividend yield to value.
1(CHG) - Change dividend yield by value
2(PCNT) - Change dividend yield by value %

Return Value:

short - Returns 0 (a value was successfully updated) or non-zero (failure).

...

short CalcGreeks(short meth);

Description:

Calculate greeks. 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.

Parameters:

  • meth - short - The calculation method code:
1- Use option/series level volatility
2- Use option level volatility only
3- Use series level volatility only

Return Value:

short - Return value can be 0 (success) or non-zero (failure).

...

short ApplyVolatilitySkew(short meth);

Description:

Skew volitility curve folowing a particular skew method. It works on the lowest level object already selected (exchange complex or point in time). If neither an exchange complex nor a point in time is selected, the call will fail.

Parameters:

  • meth - short - The skew method code:
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

Return Value:

short - Return value can be 0 (success) or non-zero (failure).

short PostTrade(BSTR timeStamp, long tradeId, BSTR exchCmplxAcro, BSTR exchAcro, BSTR pfCode, short pfType, BSTR futPeriod, BSTR optPeriod, boolean isPut, double strike, double price, long tradeQty);

Description:

Post a trade to the selected portfolio. If a portfolio isn't selected, the call will fail. After a trade is posted to the portfolio, margin will be recalculated.

Parameters:

  • timeStamp - BSTR - The timestamp of the trade in a "YYYYMMDDHHMMSS" format.
  • tradeId - long - The trade ID which will be written to the trade register.
  • exchCmplxAcro - BSTR - The exchange complex acronym (“CME”, “BOTCC”, etc.)
  • exchAcro - BSTR - The exchange acronym (“CME”, “CBT”, etc.)
  • pfCode - BSTR - The product family code (“SP”, “BP”, etc.)
  • pfType - short - The product family type. Possible values are:
1- physical
2- debt
3- stock
11- future
12- equivalence debt
14- forward
15- interest rate swap
16- E-Debt
17- credit rate swap
21- option on physical
22- option on future
23- option on equity
31- combination
41- option on combination
  • futPeriod - BSTR - The period code for future contract (period code for the underlying contract for options). Format is usually YYYYMM, there are special cases like weeklies and flexes when some characters are added to this format (for example “200002W3”). For physicals, equity and options on physicals/equity this parameter should be set to “000000”.
  • optPeriod - BSTR - The period code for option contract. This parameter and following contract identification parameters are ignored for non-option contracts. Same format as futPeriod.
  • isPut - boolean - The put (true) or call (false) flag for options.
  • strike - double - The strike price for options. For CDS products, this is the coupon.
  • price - double - The price.
  • tradeQty - long - The trade quantity.

Return Value:

short - Return value can be 0 (success) or non-zero (failure).

short ResetPrices(short prodType);

Description:

Reset prices for a given product type. It works on the lowest level object already selected (portfolio or point in time). If neither an exchange complex nor a point in time is selected, the call will fail.

Parameters:

  • prodType - short - The product type to reset prices for. Possible values are:
-1- All future based products
-2- All Option based products
1- physical
2- debt
3- stock
11- future
12- equivalence debt
14- forward
15- interest rate swap
16- E-Debt
17- credit rate swap
21- option on physical
22- option on future
23- option on equity
31- combination
41- option on combination

Return Value:

short - Return value can be 0 (success) or non-zero (failure).