com.optstack.api.strategies

ButterflyT

class ButterflyT extends OrderFiltersT[ButterflyT]

Define a butterfly spread.

For example:

var ndx = this.getInstrument ("^NDX")

// define an put butterfly
val putButterfly = ndx.strategies.butterflies.PutButterfly

// select put butterfly with 1 - 4 days to expiration
// and risk / reward ratio between 0.4 and 0.6
putButterfly.selectBy.
		daysToExpiration(minDays=1,maxDays=4).
		riskReward(min=0.4,max=0.6)

// get middle strike of butterfly
val middleStrike = putButterfly.selectMiddleStrikeBy(false)

// select at-the-money (ATM) butterflies by selecting the middle strike of butterfly to be 45 - 55 delta
middleStrike.deltaAbs(minDelta=45,maxDelta=55)

// size the butterfly such that margin req is about 2000 dollars
putButterfly.sizeBy.margin(targetMargin=2000)

// select butterfly with highest risk / reward
putButterfly.rankBy.max.riskReward

// sell put butterfly
putButterfly.sell(1)
Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ButterflyT
  2. OrderFiltersT
  3. Logging2
  4. AutoCompleteVisibility
  5. SizeByTrait
  6. RankByTrait
  7. AnyRef
  8. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ButterflyT(_security: SecurityT, _callOrPut: InstrumentType, _numContractsLowestStrike: Double = 1, _numContractsMiddleStrike: Double = 2, _numContractsHighestStrike: Double = 1, requireEquidistantStrikes: Boolean = true, enableDefaultFilters: Boolean = true, parentPosition: <error> = null)(implicit scriptCtx: <error>)

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final val SET_INIT_FN: String("setInintFn")

    Attributes
    protected
    Definition Classes
    OrderFiltersT
  7. final var SET_INIT_FN2: String

    Attributes
    protected
    Definition Classes
    OrderFiltersT
  8. final def addCustomOrderFunction(orderFunc: (OrderT) ⇒ Boolean, name: String = ...): ButterflyT

    Attributes
    protected
    Definition Classes
    OrderFiltersT
    Annotations
    @FunctionInfo()
  9. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  10. final def buy(): OrderFiltersT[ButterflyT]

    Buy the specified spread.

    Buy the specified spread. To set the quantity, use the sizeBy () method

    var ndx = this.getSecurity("^NDX")
    val butterfly = ndx.strategies.butterflies.IronButterfly
    butterfly.buy().sizeBy.risk(targetRisk=10000)
    Definition Classes
    OrderFiltersT
    Annotations
    @FunctionInfo()
  11. final def buy(orderID: String, comments: String): OrderFiltersT[ButterflyT]

    Buy the spread.

    Buy the spread. Specify an orderID in order to reference this position in the future. To set the quantity, use the sizeBy method.

    To reference position using the orderID, use the selectPosition() API.

    var ndx = this.getSecurity("^NDX")
    val butterfly = ndx.strategies.butterflies.IronButterfly
    butterfly.buy ("MyButterfly", "MyComments").sizeBy.risk(targetRisk=10000)
    
    this.selectPosition("MyButterfly");
    Definition Classes
    OrderFiltersT
    Annotations
    @FunctionInfo()
    See also

    StrategyRunnerT#selectPosition

  12. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  13. def createInitFunc(spreadQuantity: Int = 1, orderID: String = "", comments: String = "", shouldReverse: Boolean = false): (OrderT) ⇒ Boolean

    Attributes
    protected
    Definition Classes
    ButterflyTOrderFiltersT
  14. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  16. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  18. def getLegsInDescendingStrikeOrder: Seq[<error>]

    Attributes
    protected
    Definition Classes
    OrderFiltersT
  19. def getOptionableLegs: Seq[<error>]

    Attributes
    protected
    Definition Classes
    ButterflyTOrderFiltersT
  20. def getStrategyID(): String

    Definition Classes
    ButterflyTOrderFiltersT
  21. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  22. def initDefaultFilters(): Unit

    Attributes
    protected
    Definition Classes
    ButterflyTOrderFiltersT
  23. def initGlobalScope(): Unit

    Attributes
    protected
    Definition Classes
    ButterflyTOrderFiltersT
  24. final def isBuyOrder(): Boolean

    Definition Classes
    OrderFiltersT
  25. var isInDescendingStrikeOrder: Boolean

    Attributes
    protected
    Definition Classes
    OrderFiltersT
  26. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  27. var isSameExpirationForAllLegs: Boolean

    Attributes
    protected
    Definition Classes
    OrderFiltersT
  28. var isSameStrikeForAllLegs: Boolean

    Attributes
    protected
    Definition Classes
    OrderFiltersT
  29. def logError(message: ⇒ Any): Unit

    Definition Classes
    Logging2
  30. var maxConcurrentPositions: Int

    Attributes
    protected
    Definition Classes
    OrderFiltersT
  31. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  32. final def notify(): Unit

    Definition Classes
    AnyRef
  33. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  34. implicit final val orderCriteria: <error>

    Attributes
    protected
    Definition Classes
    OrderFiltersT
  35. def println(logLevel: Int, message: ⇒ Any): Unit

    Definition Classes
    Logging2
  36. def println(message: ⇒ Any): Unit

    Definition Classes
    Logging2
  37. final def rankBy(): RankOrderT

    Rank all matching spreads by criteria such as cost, risk / reward, etc.

    Rank all matching spreads by criteria such as cost, risk / reward, etc..

    Definition Classes
    OrderFiltersTRankByTrait
    Annotations
    @FunctionInfo()
  38. final def rollFrom(pos: PosT, comments: String = ""): Unit

    Select the prior position to close.

    Select the prior position to close. Roll into this new position after prior position is closed. If prior position is already closed, no rolling will take place.

    Definition Classes
    OrderFiltersT
    Annotations
    @FunctionInfo()
  39. def selectBy(scaleByQuantity: Boolean): OrderFilterScope3T[ButterflyT]

    Select the entire position in order to add specific criteria for overall position.

    Select the entire position in order to add specific criteria for overall position.

    Certain metrics will change based on the size of the position. For example, max risk / max reward / option greeks will scale up or down based on the size of the position.

    If you don't want these metrics to be affected by the size of the position, set "scaleByQuantity=false"

    If scaleByQuantity = false, metrics will be evaluated assuming quantity is 1.

    Otherwise, metrics will be evaluated based on full position size.

    Definition Classes
    ButterflyTOrderFiltersT
    Annotations
    @FunctionInfo()
  40. final def selectHighestStrikeBy(scaleByQuantity: Boolean = false): OrderFilterScopeT[ButterflyT]

    Select the highest strike of the butterfly in order to add specific criteria for this strike

    Select the highest strike of the butterfly in order to add specific criteria for this strike

    // get highest strike of butterfly
     val highestStrike = putButterfly.selectHighestStrikeBy(false)
    
    	// select highest strike to be between 45 to 55 delta
     highestStrike.deltaAbs(minDelta=45,maxDelta=55)
    Annotations
    @FunctionInfo()
  41. final def selectLowestStrikeBy(scaleByQuantity: Boolean = false): OrderFilterScopeT[ButterflyT]

    Select the lowest strike of the butterfly in order to add specific criteria for this strike

    Select the lowest strike of the butterfly in order to add specific criteria for this strike

    // get lowest strike of butterfly
     val lowestStrike = putButterfly.selectLowestStrikeBy(false)
    
    	// select lowest strike to be between 45 to 55 delta
     lowestStrike.deltaAbs(minDelta=45,maxDelta=55)
    Annotations
    @FunctionInfo()
  42. final def selectMiddleStrikeBy(scaleByQuantity: Boolean = false): OrderFilterScopeT[ButterflyT]

    Select the middle strike of the butterfly in order to add specific criteria for this strike

    Select the middle strike of the butterfly in order to add specific criteria for this strike

    // get middle strike of butterfly
    val middleStrike = putButterfly.selectMiddleStrikeBy(false)
    
    // select at-the-money (ATM) butterflies by selecting the middle strike of butterfly to be 45 - 55 delta
    middleStrike.deltaAbs(minDelta=45,maxDelta=55)
    Annotations
    @FunctionInfo()
  43. final def selectTopN(n: Int): RankByTrait

    Select the Top N matching spreads based on the "rankBy" criteria used.

    Select the Top N matching spreads based on the "rankBy" criteria used. Default is to select only the top (N=1)

    Definition Classes
    OrderFiltersT
    Annotations
    @FunctionInfo()
  44. final def sell(): OrderFiltersT[ButterflyT]

    Sell the specified spread.

    Sell the specified spread. To set the quantity, use the sizeBy () method

    var ndx = this.getSecurity("^NDX")
    val butterfly = ndx.strategies.butterflies.IronButterfly
    butterfly.sell().sizeBy.risk(targetRisk=10000)
    Definition Classes
    OrderFiltersT
    Annotations
    @FunctionInfo()
  45. final def sell(orderID: String, comments: String): OrderFiltersT[ButterflyT]

    Sell / short the spread.

    Sell / short the spread. Specify an orderID in order to reference this position in the future. To set the quantity, use the sizeBy method.

    To reference position using the orderID, use the selectPosition() API.

    var ndx = this.getSecurity("^NDX")
    val butterfly = ndx.strategies.butterflies.IronButterfly
    butterfly.sell ("MyButterfly", "MyComments").sizeBy.risk(targetRisk=10000)
    
    this.selectPosition("MyButterfly");
    Definition Classes
    OrderFiltersT
    Annotations
    @FunctionInfo()
    See also

    StrategyRunnerT#selectPosition

  46. final def setMaxOpenPositions(n: Int): Unit

    Set the maximum number of open positions of this particular type of order

    Set the maximum number of open positions of this particular type of order

    Definition Classes
    OrderFiltersT
    Annotations
    @FunctionInfo()
  47. def shouldReverseForBuy(): Boolean

    Attributes
    protected
    Definition Classes
    ButterflyTOrderFiltersT
  48. def shouldReverseForSell(): Boolean

    Attributes
    protected
    Definition Classes
    ButterflyTOrderFiltersT
  49. final def sizeBy(): SizeByFilterT

    Size all matching spreads by cost, risk, margin, etc.

    Size all matching spreads by cost, risk, margin, etc..

    Definition Classes
    OrderFiltersTSizeByTrait
    Annotations
    @FunctionInfo()
  50. def submitOrder(orderID: String = "")(implicit scriptCtx: <error>): Unit

    Attributes
    protected
    Definition Classes
    OrderFiltersT
  51. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  52. def toString(): String

    Definition Classes
    AnyRef → Any
  53. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  54. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  55. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. final def buy(quantity: Int): OrderFiltersT[ButterflyT]

    Buy the spread.

    Buy the spread. Quantity is ignored if specific "sizeBy" criteria are defined.

    Definition Classes
    OrderFiltersT
    Annotations
    @FunctionInfo() @deprecated
    Deprecated
  2. final def buy(quantity: Int, orderID: String = "", comments: String = ""): OrderFiltersT[ButterflyT]

    Buy the spread.

    Buy the spread. Specify an orderID in order to reference this position in the future. Quantity is ignored if specific "sizeBy" criteria are defined.

    To reference position using the orderID, use the selectPosition() API.

    val cc = ndx.strategies.withStock.CoveredCall
    cc.buy(quantity=10,orderID="vertical1001",comments="Enter CoveredCall When 50 Day MVG crosses above 200 Day MVG")
    
    .....
    .....
    
    // select the covered call order using the orderID
    val coveredCall = this.selectPosition(orderID="vertical1001")
    Definition Classes
    OrderFiltersT
    Annotations
    @FunctionInfo() @deprecated
    Deprecated
    See also

    StrategyRunnerT#selectPosition

  3. final def selectBy(): OrderFilterScope3T[ButterflyT]

    Select the entire butterfly position in order to add specific criteria for overall position

    Select the entire butterfly position in order to add specific criteria for overall position

    Certain metrics will change based on the size of the position. For example, max risk / max reward / option greeks will scale up or down based on the size of the position.

    By default, computation will be evaluated based on full position size.

    For example: select put butterfly with days to expiration between 1 to 4 days and risk / reward between 0.4 and 0.6

    putButterfly.selectBy.
    		daysToExpiration(minDays=1,maxDays=4).
    		riskReward(min=0.4,max=0.6)
    Definition Classes
    ButterflyTOrderFiltersT
    Annotations
    @FunctionInfo() @deprecated
    Deprecated
  4. final def sell(quantity: Int): OrderFiltersT[ButterflyT]

    Sell / short the spread.

    Sell / short the spread. Quantity is ignored if specific "sizeBy" criteria are defined.

    Definition Classes
    OrderFiltersT
    Annotations
    @FunctionInfo() @deprecated
    Deprecated
  5. final def sell(quantity: Int, orderID: String = "", comments: String = ""): OrderFiltersT[ButterflyT]

    Sell / short the spread.

    Sell / short the spread. Specify an orderID in order to reference this position in the future. Quantity is ignored if specific "sizeBy" criteria is defined.

    To reference position using the orderID, use the selectPosition() API.

    val cc = ndx.strategies.withStock.CoveredCall
    cc.sell(quantity=10,orderID="vertical1001",comments="Enter CoveredCall When 50 Day MVG crosses above 200 Day MVG")
    
    .....
    .....
    
    // select the covered call order using the orderID
    val coveredCall = this.selectPosition(orderID="vertical1001")
    Definition Classes
    OrderFiltersT
    Annotations
    @FunctionInfo() @deprecated
    Deprecated
    See also

    StrategyRunnerT#selectPosition

Inherited from OrderFiltersT[ButterflyT]

Inherited from Logging2

Inherited from AutoCompleteVisibility

Inherited from SizeByTrait

Inherited from RankByTrait

Inherited from AnyRef

Inherited from Any

Ungrouped