Closes all open positions for the specified symbol.

Namespace: RightEdge.Common
Assembly: Common (in Common.dll) Version: 2010.1.0.0 (2010.1.0.0)

Syntax

C#
public ReturnCode CloseAllPositions(
	Symbol symbol
)
Visual Basic
Public Function CloseAllPositions ( 
	symbol As Symbol
) As ReturnCode
Visual C++
public:
ReturnCode^ CloseAllPositions(
	Symbol^ symbol
)
F#
member CloseAllPositions : 
        symbol : Symbol -> ReturnCode 

Parameters

symbol
Type: RightEdge.Common..::..Symbol
Symbol instance.

Return Value

Type: ReturnCode
A ReturnCode indicating whether the positions could be closed.

Examples

The following code example demonstrates how to close all open positions if the number of open positions exceeds 2.
C# Copy imageCopy
public override void NewSymbolBar(Symbol symbol, BarData bar)
{
    // Get all open positions for this symbol
    IList<Position> openPositions = PositionManager.GetOpenPositions(symbol);

    // Check to see if we have more than 2 open positions.  If so, that's too
    // much exposure and we'd like to close them all.
    if (openPositions.Count > 2)
    {
        // Exit out of all positions for this symbol.
        CloseAllPositions(symbol);
    }
}
Visual Basic.Net Copy imageCopy
Public Overloads Overrides Sub NewSymbolBar(ByVal symbol As Symbol, ByVal bar As BarData) 
    ' Get all open positions for this symbol 
    Dim openPositions As IList(Of Position) = PositionManager.GetOpenPositions(symbol) 

    ' Check to see if we have more than 2 open positions. If so, that's too 
    ' much exposure and we'd like to close them all. 
    If openPositions.Count > 2 Then 
        ' Exit out of all positions for this symbol. 
        CloseAllPositions(symbol) 
    End If 
End Sub

See Also