investfly.models.strategy.OptionStructureSpec

MAX_CUSTOM_COMBO_LEGS = 4
@dataclass
class OptionStructureSpec:
def isMultiLeg(self) -> bool:
def hasUnderlyingLeg(self) -> bool:
def lifecycleLegIds(self) -> List[str]:
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class LongCallSpec(OptionStructureSpec):
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class LongPutSpec(OptionStructureSpec):
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class CoveredCallSpec(OptionStructureSpec):
CoveredCallSpec( callSelector: investfly.models.strategy.OptionContractSelector, buyWrite: bool = False)
buyWrite: bool = False
def hasUnderlyingLeg(self) -> bool:
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class CashSecuredPutSpec(OptionStructureSpec):
CashSecuredPutSpec( putSelector: investfly.models.strategy.OptionContractSelector)
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class BullPutCreditSpreadSpec(OptionStructureSpec):
BullPutCreditSpreadSpec( shortPutSelector: investfly.models.strategy.OptionContractSelector, spreadWidth: float)
spreadWidth: float
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class BearCallCreditSpreadSpec(OptionStructureSpec):
BearCallCreditSpreadSpec( shortCallSelector: investfly.models.strategy.OptionContractSelector, spreadWidth: float)
spreadWidth: float
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class BullCallDebitSpreadSpec(OptionStructureSpec):
BullCallDebitSpreadSpec( longCallSelector: investfly.models.strategy.OptionContractSelector, spreadWidth: float)
spreadWidth: float
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class BearPutDebitSpreadSpec(OptionStructureSpec):
BearPutDebitSpreadSpec( longPutSelector: investfly.models.strategy.OptionContractSelector, spreadWidth: float)
spreadWidth: float
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class IronCondorSpec(OptionStructureSpec):
IronCondorSpec( shortPutSelector: investfly.models.strategy.OptionContractSelector, shortCallSelector: investfly.models.strategy.OptionContractSelector, putWingWidth: float, callWingWidth: float)
putWingWidth: float
callWingWidth: float
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class CallButterflySpec(OptionStructureSpec):
CallButterflySpec( bodySelector: investfly.models.strategy.OptionContractSelector, wingWidth: float)
wingWidth: float
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class PutButterflySpec(OptionStructureSpec):
PutButterflySpec( bodySelector: investfly.models.strategy.OptionContractSelector, wingWidth: float)
wingWidth: float
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class LongStraddleSpec(OptionStructureSpec):
LongStraddleSpec( bodySelector: investfly.models.strategy.OptionContractSelector)
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class ShortStraddleSpec(OptionStructureSpec):
ShortStraddleSpec( bodySelector: investfly.models.strategy.OptionContractSelector)
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class LongStrangleSpec(OptionStructureSpec):
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class ShortStrangleSpec(OptionStructureSpec):
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class LongCallCalendarSpreadSpec(OptionStructureSpec):
LongCallCalendarSpreadSpec( shortCallSelector: investfly.models.strategy.OptionContractSelector, longCallTargetDte: int)
longCallTargetDte: int
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class LongPutCalendarSpreadSpec(OptionStructureSpec):
LongPutCalendarSpreadSpec( shortPutSelector: investfly.models.strategy.OptionContractSelector, longPutTargetDte: int)
longPutTargetDte: int
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class LongCallDiagonalSpreadSpec(OptionStructureSpec):
LongCallDiagonalSpreadSpec( shortCallSelector: investfly.models.strategy.OptionContractSelector, longCallSelector: investfly.models.strategy.OptionContractSelector)
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class LongPutDiagonalSpreadSpec(OptionStructureSpec):
LongPutDiagonalSpreadSpec( shortPutSelector: investfly.models.strategy.OptionContractSelector, longPutSelector: investfly.models.strategy.OptionContractSelector)
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class ProtectivePutSpec(OptionStructureSpec):
ProtectivePutSpec( putSelector: investfly.models.strategy.OptionContractSelector, buyStock: bool = False)
buyStock: bool = False
def hasUnderlyingLeg(self) -> bool:
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class CollarSpec(OptionStructureSpec):
CollarSpec( putSelector: investfly.models.strategy.OptionContractSelector, callSelector: investfly.models.strategy.OptionContractSelector, buyStock: bool = False)
buyStock: bool = False
def hasUnderlyingLeg(self) -> bool:
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class IronButterflySpec(OptionStructureSpec):
IronButterflySpec( bodySelector: investfly.models.strategy.OptionContractSelector, wingWidth: float)
wingWidth: float
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class LongCallCondorSpec(OptionStructureSpec):
LongCallCondorSpec( lowerCallSelector: investfly.models.strategy.OptionContractSelector, wingWidth: float)
wingWidth: float
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
@dataclass
class CustomComboSpec(OptionStructureSpec):
CustomComboSpec(legs: List[investfly.models.strategy.OptionLegSpec])
def isMultiLeg(self) -> bool:
def hasUnderlyingLeg(self) -> bool:
def lifecycleLegIds(self) -> List[str]:
def validate(self) -> None:
def toDict(self) -> Dict[str, Any]:
def optionLegsForStructure( structure: OptionStructureSpec | None) -> List[investfly.models.strategy.OptionLegSpec]:
def optionStructureFromDict( jsonDict: Dict[str, Any]) -> OptionStructureSpec:
def legacyOptionStructureFromDict( jsonDict: Dict[str, Any]) -> OptionStructureSpec: