Class
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 Summary

Attributes Name and Description
caplin.trading.trademodel.LegManager()

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

Method Summary

Attributes Name and Description
caplin.trading.trademodel.StructureChangedEvent addLeg(caplin.trading.trademodel.TradeLeg oLeg, String sEventSource)

Adds a TradeLeg to this LegManager.

void clearPendingStructureChanges()

Clears the pending structure changes.

caplin.trading.trademodel.TradeLeg getLegById(Number the)

Gets the leg by its Id

caplin.trading.trademodel.TradeLeg getLegByIndex(Number the)

Gets the leg by its index.

int getLegCount()

Gets the number of legs

Array getLegs()

Gets an array of the legs.

Number getNextLegId()

Gets the next free leg id.

Array getPendingStructureChanges()

Gets an array of the pending structure changes.

caplin.trading.trademodel.StructureChangedEvent removeLeg(caplin.trading.trademodel.TradeLeg oLeg, String sEventSource)

Removes a TradeLeg from this LegManager.

Array revertStructureChanges()

Reverts all changes that took place since the last clearPendingStructureChanges call.

Constructor Detail

caplin.trading.trademodel.LegManager()

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

Method Detail

caplin.trading.trademodel.StructureChangedEvent addLeg(caplin.trading.trademodel.TradeLeg oLeg, String sEventSource)

Adds a TradeLeg to this LegManager.

Parameters
caplin.trading.trademodel.TradeLeg oLeg the TradeLeg to add. May not be null.
String sEventSource the source of this add event. Should be one of caplin.trading.statemachine.TransitionSource
Throws
caplin.core.Error
if the sEventSource is not a valid caplin.trading.statemachine.TransitionSource
caplin.core.Error
if the oLeg is not being managed by this LegManager
Returns
the add event for this action.

void clearPendingStructureChanges()

Clears the pending structure changes.

caplin.trading.trademodel.TradeLeg getLegById(Number the)

Gets the leg by its Id

Parameters
Number the id of the trade leg.
Returns
the leg corresponding to the passed id, or undefined.

caplin.trading.trademodel.TradeLeg getLegByIndex(Number the)

Gets the leg by its index.

Parameters
Number the index of the trade leg within its trade.
Returns
the leg at the corresponding index, or undefined.

int getLegCount()

Gets the number of legs

Returns
the number of legs this LegManager is holding.

Array getLegs()

Gets an array of the legs.

Returns
an array of all TradeLegs managed by this LegManager.

Number getNextLegId()

Gets the next free leg id.

Returns
the next free leg id.

Array getPendingStructureChanges()

Gets an array of the pending structure changes.

Returns
an Array of 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.

caplin.trading.trademodel.StructureChangedEvent removeLeg(caplin.trading.trademodel.TradeLeg oLeg, String sEventSource)

Removes a TradeLeg from this LegManager.

Parameters
caplin.trading.trademodel.TradeLeg oLeg the TradeLeg to remove. May not be null.
String sEventSource the source of this add event. Should be one of caplin.trading.statemachine.TransitionSource
Throws
caplin.core.Error
if the sEventSource is a valid caplin.trading.statemachine.TransitionSource
caplin.core.Error
if the oLeg is not being managed by this LegManager
Returns
the remove event for this action.

Array revertStructureChanges()

Reverts all changes that took place since the last clearPendingStructureChanges call. After this call, there will be no pendingStructureChanges.

Returns
an array containing StructureChangeEvents for all the events that took place during the reversion.