Caplin Trader 4.7.1

Class: module:caplin/trading/trademodel/LegManager

module:caplin/trading/trademodel/LegManager

The LegManager class keeps track of the TradeLegs for a Trade. It remembers changes to the Legs as StructureChangedEvents, which can be retrieved with getPendingStructureChanges and clear when processed with clearPendingStructureChanges.

Constructor

new module:caplin/trading/trademodel/LegManager()

Constructs an instance of caplin.trading.trademodel.LegManager.

Methods

addLeg(oLeg, sEventSource) → {module:caplin/trading/trademodel/StructureChangedEvent}

Adds a TradeLeg to this LegManager.
Parameters:
Name Type Description
oLeg module:caplin/trading/trademodel/TradeLeg the TradeLeg to add. May not be null.
sEventSource String the source of this add event. Should be one of TransitionSource
Throws:
Returns:
the add event for this action.
Type
module:caplin/trading/trademodel/StructureChangedEvent

clearPendingStructureChanges()

Clears the pending structure changes.

getLegById(the) → {module:caplin/trading/trademodel/TradeLeg}

Gets the leg by its Id
Parameters:
Name Type Description
the Number id of the trade leg.
Returns:
the leg corresponding to the passed id, or undefined.
Type
module:caplin/trading/trademodel/TradeLeg

getLegByIndex(legIndex) → {module:caplin/trading/trademodel/TradeLeg}

Gets the leg by its index.
Parameters:
Name Type Description
legIndex Number the index of the trade leg within its trade.
Returns:
the leg at the corresponding index, or undefined.
Type
module:caplin/trading/trademodel/TradeLeg

getLegCount() → {int}

Gets the number of legs
Returns:
the number of legs this LegManager is holding.
Type
int

getLegs() → {Array}

Gets an array of the legs.
Returns:
The TradeLegs managed by this LegManager.
Type
Array

getNextLegId() → {int}

Gets the next free leg id.
Returns:
the next free leg id.
Type
int

getPendingStructureChanges() → {Array}

Gets an array of the pending structure changes.
Returns:
The StructureChangedEvents representing all the changes to this LegManager since clearPendingStructureChanges was last called or the class was constructed. Will return an empty array if there have been no events. The array is not a copy.
Type
Array

removeLeg(oLeg, sEventSource) → {module:caplin/trading/trademodel/StructureChangedEvent}

Removes a TradeLeg from this LegManager.
Parameters:
Name Type Description
oLeg module:caplin/trading/trademodel/TradeLeg the TradeLeg to remove. May not be null.
sEventSource String the source of this add event. Should be one of TransitionSource.
Throws:
Returns:
the remove event for this action.
Type
module:caplin/trading/trademodel/StructureChangedEvent

revertStructureChanges() → {Array}

Reverts all changes that took place since the last clearPendingStructureChanges call. After this call, there will be no pendingStructureChanges.
Returns:
The StructureChangeEvents for all the events that took place during the reversion.
Type
Array