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

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

real-time component interface 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.

For example, suppose a customer requests an order.  Using the component interface, your program can call PC-SPAN, specify the updated position that will result from the order, request that the performance bond be calculated, and receive back the updated performance bond requirement--all with extremely rapid execution times.

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.

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




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

#include <stdio.h>
#include <ole2.h>
#import "C:\Span4\Bin\SpanCom.tlb" no_namespace, named_guids

int main(int argc, char* argv[])
{

        if(FAILED(::CoInitialize(NULL))) return 1;

        ISpanCom* pSpanCom;
        if(SUCCEEDED(::CoCreateInstance(CLSID_SpanCom, NULL, CLSCTX_LOCAL_SERVER,
        __uuidof(ISpanCom), (LPVOID*) &pSpanCom)))
        {
                    printf( "Success\n");
                    // pSpanCom->Load("C:\\cme0216s.par",1,0);
                    pSpanCom->Release();
        }

        else printf("Fail\n");
        ::CoUninitialize();
        return 0;
}


dispinterface ISpanCom

methods:

short Load(BSTR fileName, boolean replaceExc, boolean useExtLayout);

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).

short SelectPIT(BSTR busDate, short isSettle, short isFinal, BSTR busTime, BSTR description);

Description:

Selects a specified point in time as current point in time. Once selected, a point in time remains selected until it is reset, a different point in time is selected, or until the point in time is cleared.

Parameters:

  • busDate - BSTR - The date of the point in time to select. The point in time must be in a "YYYYMMDD" format. Alternatively, the busDate string parameter may be empty to select the first point in time.

  • isSettle - short - Search for a point in time where the settlement is: '0' for non-settlement; '1' for settlement; or '-1' for no preference on settlement indication.

  • isFinal - short - Search for a point in time where the final flag is: '0' for not final; '1' for final; or '-1' for no preference on final indication.

  • busTime - BSTR - When the isSettle flag is 0, the busTime may be optionally specified. It is formatted as "HHMM". If isSettle flag is not 0, the busTime is ignored.

  • description - BSTR - When the isSettle flag is not -1, the description may be optionally specified to match the description of available points in time. If passed as an empty string, it is ignored.

Remarks:

If busDate is empty and the isSettle is -1, the rest of the parameters are ignored and first available point in time is selected. If either isSettle or isFinal is set to –1 this parameter and all parameters following it are ignored. If busTime or description is empty it is ignored.

Return Value:

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

short SelectPortfolio(BSTR firmCode, BSTR acctCode, BSTR segType);

Description:

Selects specified portfolio as current. This method searches for the specified portfolio in the currently selected point in time. If point in time is not selected it fails.

Parameters:

  • firmCode - BSTR - If not empty, it will be used to match the firm code to find the portfolio.

  • acctCode - BSTR - If not empty, it will be used to match the account code.

  • segType - BSTR - If not empty, it will be used to match the seg type code.

Remarks:

If all parameters are empty, the first portfolio will be selected. Any combination of parameters may be used.

Return Value:

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

void ResetPIT();

Description:

Sets currently selected point in time to NULL (removes selection). Also resets portfolio selection.

Parameters:

None

Remarks:

When the point in time selection is reset, the point in time is still available. It is merely no longer selected as the active point in time.

Return Value:

None

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

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 Delete();

Description:

Deletes currently selected object from PC-SPAN. If a portfolio selection has been made, it deletes only the selected portfolio. If it is not selected (NULL) and a point in time selection is selected (NULL) it deletes the selected point in time. If both neither a portfolio or a point in time are selected (both NULL), then the whole contents of the PC-SPAN is deleted.

Parameters:

None

Return Value:

None

double GetPortfLongFutValue();

Description:

Returns long futures value calculated for the selected portfolio. If portfolio is not selected (NULL) it returns 0.

Parameters:

None

Return Value:

double - Returns long futures value for selected portfolio.

double GetPortfShortFutValue();

Description:

Returns short futures value calculated for the selected portfolio. If portfolio is not selected (NULL) it returns 0.

Parameters:

None

Return Value:

double - Returns short futures value for selected portfolio.

double GetPortfLongOptValue();

Description:

Returns long options value calculated for the selected portfolio. If portfolio is not selected (NULL) it returns 0.

Parameters:

None

Return Value:

double - Returns long options value for selected portfolio.

double GetPortfShortOptValue();

Description:

Returns short options value calculated for the selected portfolio. If portfolio is not selected (NULL) it returns 0.

Parameters:

None

Return Value:

double - Returns short options value for selected portfolio.

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

void LogSave(BSTR fileName);

Description:

Saves PC-SPAN log into the file specified by fileName.

Parameters:

fileName - BSTR - The file name to save the log as.

Return Value:

None

void LogClear();

Description:

Clears the PC-SPAN Log.

Parameters:

None

Return Value:

None

short CreatePortfolio(BSTR firmCode, BSTR acctCode, BSTR segType);

Description:

Creates a new portfolio with specified parameters in the selected point in time and selects it as current. The call will fail if a point in time is not selected. If portfolio with given parameters already exist selects the existing portfolio as current (the call does not create a duplicate one).

Parameters:

  • firmCode - BSTR - The firm code to create a portfolio with.

  • acctCode - BSTR - The account code to create a portfolio with.

  • segType - BSTR - The segment type to create a portfolio with. If segType is empty, a “N/A” segment type is assumed.

Return Value:

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

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 SetPortfParent(BSTR firmCode, BSTR acctCode, BSTR segType);

Description:

Sets parent portfolio for the selected portfolio by finding a portfolio using the parameters provided. Used only for omnibus accounts. Only omnibus account can be a parent of another portfolio. Only one level of parents is supported. Fails if portfolio is not selected, parent portfolio can not be found or omnibus rules are violated.

Parameters:

  • firmCode - BSTR - The portfolio firmCode to search for the selected portfolio.

  • acctCode - BSTR - The portfolio acctCode to search for the selected portfolio.

  • segType - BSTR - The portfolio segType to search for the selected portfolio.

Return Value

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

short SetPortfCurrency(BSTR currencyCode);

Description:

Sets currency for the selected portfolio.

Parameters

  • currencyCode - BSTR - A three-letter ISO code for the currency (USD, EUR, GBP etc.).

Remarks

The call will fail if a portfolio is not selected or if the currency parameter is not defined in the organization master database.

Return Value

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

BSTR GetPortfCurrency();

Description:

Returns a three-letter ISO code for the currency of the selected portfolio. If a portfolio is not selected or the currency for it is not specified method returns an empty string.

Parameters:

None

Return Value:

BSTR - Returns an ISO code for the selected portfolio currency.

short SetPortfLedgerBalance(double value);

Description:

Sets ledger balance for the selected portfolio. Fails if portfolio is not selected.

Parameters:

  • value - double - The portfolio ledger balance to set.

Return Value:

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

double GetPortfLedgerBalance();

Description:

Returns ledger balance for the selected portfolio. If portfolio is not selected, the call will fail.

Parameters:

None

Return Value:

double - Returns the ledge balance or 0 if no portfolio is selected.

short SavePortfolios(BSTR filename);

Description:

Saves portfolios to a file.

Parameters:

  • fileName - BSTR - The name of the portfolio file to save.

Remarks:

If a portfolio is selected, only the selected portfolio will be saved. If a portfolio is not selected but a point in time is selected, all of the portfolios belonging to the selected point in time will be saved. A portfolio or a point in time must be selected, otherwise the call will fail.

Return Value:

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

short SetPortfOpenTradeEquity(double value);

Description:

Sets open trade equity for the selected portfolio. Fails if portfolio is not selected.

Parameters:

  • value- double - The open trade equity to set.

Return Value:

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

double GetPortfOpenTradeEquity();

Description:

Returns open trade equity for the selected portfolio. If a portfolio is not selected, the return will be 0.

Parameters:

None

Return Value:

double - Returns open trade equity or 0 if no portfolio is selected.

short SetPortfSecurityOnDeposit(double value);

Description:

Sets security on deposit for the selected portfolio. The call will fail if a portfolio is not selected.

Parameters:

  • value - double - The security on deposit value to set.

Return Value:

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

double GetPortfSecurityOnDeposit();

Description:

Returns security on deposit for the selected portfolio. If a portfolio is not selected returns 0.

Parameters:

None

Return Value:

double - Returns the security on deposit or 0 if no portfolio is selected.

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:




How was your Client Systems Wiki Experience? Submit Feedback

Copyright © 2024 CME Group Inc. All rights reserved.