Filter out the sequence of items based on specified criteria
Filter out the sequence of items based on specified criteria
val sequenceOfPositions = this.selectPosition(positionID="2212") // only select positions which are profitable (gainLoss > 0) val profitablePositions = sequenceOfPositions.filter({ curPosition => curPosition.gainLoss > 0 })
Loop through the items in a sequence, and for each item, evaluate the function that was passed in as an argument
Loop through the items in a sequence, and for each item, evaluate the function that was passed in as an argument
val sequenceOfPositions = this.selectPosition(orderID="2212") // for each position, get the profit / loss for that position sequenceOfPositions.foreach ({ curPosition => val profitLoss = curPosition.gainLoss })
Get number of items in sequence
Get number of items in sequence
Transform the sequence of items (Type A) into a sequence of a different type (Type B)
Transform the sequence of items (Type A) into a sequence of a different type (Type B)
var positionSeq = this.selectPosition(orderID="myOrders1") // convert sequence of generic positions into a sequence of vertical spreads var verticalSeq = positionSeq.map({ curPosition => curPosition.asStrategy.vertical })
Convert the sequence into a Scala Seq object
Convert the sequence into a Scala Seq object
A sequence of zero or more objects.
To reference an index of the sequence, use parenthesis as follows:
To loop through a sequence of elements, use the foreach function:
To filter out the sequence of elements, use the filter function: