Correlation Risk Manager - Check Fills

This version or the Correlation Risk Manager has the same functionality of the Correlation Risk Manager plus the addition of an ability check the process after the order has been filled.

 

Correlation Risk Manager - Check Fills Parameters:

Correlation Risk Manager - Check Fills Parameter

 

Parameter:

Description:

Max Closely Correlated Markets

Sets the max number of units the system can have on in closely correlated markets.

Maximum Loosely Correlated Markets

Sets the max number of units the system can have on in loosely correlated markets

Max Directional Units

Sets the max number of units the system can have on in each direction, Long or Short.

 

Correlation Risk Manager - Check Fills Control Logic - CAN ADD UNIT:

  ' ==============================================================
  ' Correlation Risk Mgr wFills
  ' CAN ADD UNIT SCRIPT - START
  ' ==============================================================
  ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ' Check LONG correlations, and Total LONG Position Count
  ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  If order.position = LONG THEN
    ' LONG ORDER Correlation Filter
    If instrument.closelyCorrelatedLongUnits >= maxCloselyCorrelatedMarkets OR
        instrument.looselyCorrelatedLongUnits >= maxLooselyCorrelatedMarkets THEN
        ' Remove Order and Send Rejection Msg to Filter Log
        order.Reject( "Too many correlated long units" )
    ENDIF
  ' -----------------------------------------------------------
    ' LONG Position Count Filter
    If system.totalLongUnits >= maxDirectionalUnits THEN
        ' Remove Order and Send Rejection Msg to Filter Log
        order.Reject( "Too many long directional units" )
    ENDIF
  ELSE' o.position = LONG
  ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ' Check SHORT correlations, and Total SHORT Position Count
  ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ' SHORT ORDER Correlation Filter
    If instrument.closelyCorrelatedShortUnits >= maxCloselyCorrelatedMarkets OR
        instrument.looselyCorrelatedShortUnits >= maxLooselyCorrelatedMarkets THEN
        ' Remove Order and Send Rejection Msg to Filter Log
        order.Reject( "Too many correlated short units" )
    ENDIF
  ' -----------------------------------------------------------
    ' SHORT Position Count Filter
    If system.totalShortUnits >= maxDirectionalUnits THEN
    ' Remove Order and Send Rejection Msg to Filter Log
    order.Reject( "Too many short directional units" )
    ENDIF
  ENDIF ' .position = SHORT
  ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ' ==============================================================
  ' CAN ADD UNIT - END
  ' Correlation Risk Mgr wFills
  ' =============================================================

CAN FILL ORDER:

  '  ==============================================================
  '  Correlation Risk Mgr wFills
  '  CAN FILL ORDER SCRIPT - START
  '  ==============================================================
  '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ' Check correlations, and total directional positions
  '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  '  Only filter Order Correlationons on Entry Fill.
  '  There are no count or Correlcation filter for exits
  If order.isEntry THEN
    '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ' Check LONG Order correlations, and Total LONG Position Count
    '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    If order.position = LONG THEN
        '  --------------------------------------------------------
        '  LONG Order-Filled Correlation Filter
        '  --------------------------------------------------------
        If instrument.closelyCorrelatedLongUnits >= maxCloselyCorrelatedMarkets OR
          instrument.looselyCorrelatedLongUnits >= maxLooselyCorrelatedMarkets THEN
          order.Reject( "Too many correlated long units" )
        ENDIF
        '  --------------------------------------------------------
        ' Check Total SHORT Position Count
        '  --------------------------------------------------------
        If system.totalLongUnits >= maxDirectionalUnits THEN
          order.Reject( "Too many long directional units" )
        ENDIF
    ELSE
        '  --------------------------------------------------------
        ' Check SHORT Order correlations
        '  --------------------------------------------------------
        If instrument.closelyCorrelatedShortUnits >= maxCloselyCorrelatedMarkets OR
          instrument.looselyCorrelatedShortUnits >= maxLooselyCorrelatedMarkets THEN
          order.Reject( "Too many correlated short units" )
        ENDIF
        '  --------------------------------------------------------
        ' Check Total SHORT Position Count
        '  --------------------------------------------------------
        If system.totalShortUnits >= maxDirectionalUnits THEN
          order.Reject( "Too many short directional units" )
        ENDIF
    ENDIF
  ENDIF
  '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  '  ==============================================================
  '  CAN FILL ORDER - END
  '  Correlation Risk Mgr wFills
  '  ==============================================================


Edit Time: 9/12/2020 9:50:00 AM


Topic ID#: 124

 

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