investfly.models.strategy.TriggerSchedule

Schedules and decorators for time-driven strategy callbacks.

class SchedulePattern(builtins.str, enum.Enum):

Supported recurrence patterns for a scheduled callback.

class ScheduleDayMode(builtins.str, enum.Enum):

Calendar used to decide which days a schedule may run.

class Weekday(builtins.str, enum.Enum):

Weekday values accepted by weekly and custom-day schedules.

def toIndex(self) -> int:

Return the zero-based Monday-to-Sunday index.

@staticmethod
def fromIndex(index: int) -> Weekday:

Create a weekday from a zero-based Monday-to-Sunday index.

class MonthlyScheduleAnchor(builtins.str, enum.Enum):

Ways to anchor a monthly schedule within the month.

class ScheduleEventType(builtins.str, enum.Enum):

Market or instrument events usable by event-relative schedules.

class ScheduleEventTiming(builtins.str, enum.Enum):

Whether a callback runs before, after, or on its reference event.

@dataclass
class ScheduleWindow:

Intraday time window, expressed as HH:MM local market times.

@dataclass
class TriggerSchedule:

Recurrence definition used by scheduled().

Prefer the named factory methods such as daily(), weekly(), or eventRelative(); they populate the fields required by each pattern.

@staticmethod
def everyMinute( days: ScheduleDayMode = <ScheduleDayMode.TRADING: 'trading'>, window: Optional[ScheduleWindow] = None) -> TriggerSchedule:

Create a one-minute schedule within an optional intraday window.

@staticmethod
def everyFiveMinutes( days: ScheduleDayMode = <ScheduleDayMode.TRADING: 'trading'>, window: Optional[ScheduleWindow] = None) -> TriggerSchedule:

Create a five-minute schedule within an optional intraday window.

@staticmethod
def everyFifteenMinutes( days: ScheduleDayMode = <ScheduleDayMode.TRADING: 'trading'>, window: Optional[ScheduleWindow] = None) -> TriggerSchedule:

Create a fifteen-minute schedule within an optional intraday window.

@staticmethod
def everyThirtyMinutes( days: ScheduleDayMode = <ScheduleDayMode.TRADING: 'trading'>, window: Optional[ScheduleWindow] = None) -> TriggerSchedule:

Create a thirty-minute schedule within an optional intraday window.

@staticmethod
def interval( intervalMinutes: int = 15, days: Optional[ScheduleDayMode] = <ScheduleDayMode.TRADING: 'trading'>, daysOfWeek: Optional[Sequence[Weekday]] = None, window: Optional[ScheduleWindow] = None) -> TriggerSchedule:

Create a repeating minute interval on the selected days and time window.

@staticmethod
def hourly( days: Optional[ScheduleDayMode] = <ScheduleDayMode.TRADING: 'trading'>, daysOfWeek: Optional[Sequence[Weekday]] = None, window: Optional[ScheduleWindow] = None) -> TriggerSchedule:

Create an hourly schedule on the selected days and time window.

@staticmethod
def daily( time: str = '09:30', days: Optional[ScheduleDayMode] = <ScheduleDayMode.TRADING: 'trading'>, daysOfWeek: Optional[Sequence[Weekday]] = None) -> TriggerSchedule:

Create a once-per-day schedule at time in HH:MM format.

@staticmethod
def weekly( daysOfWeek: Union[Weekday, Sequence[Weekday]] = <Weekday.MON: 'MON'>, time: str = '09:30') -> TriggerSchedule:

Create a weekly schedule on one or more weekdays.

@staticmethod
def monthly( day: int = 1, time: str = '09:30') -> TriggerSchedule:

Create a monthly schedule on a calendar day from 1 through 31.

@staticmethod
def firstTradingDayOfMonth( time: str = '09:30') -> TriggerSchedule:

Create a schedule for the first trading day of every month.

@staticmethod
def lastTradingDayOfMonth( time: str = '09:30') -> TriggerSchedule:

Create a schedule for the last trading day of every month.

@staticmethod
def eventRelative( event: ScheduleEventType, timing: ScheduleEventTiming = <ScheduleEventTiming.BEFORE: 'before'>, offsetTradingDays: Optional[int] = 1, time: str = '09:30') -> TriggerSchedule:

Create a schedule relative to a market or instrument event.

@dataclass
class ScheduleEvent:

Invocation details passed to a scheduled strategy callback.

@dataclass
class ScheduledCallback:

A discovered callback together with its validated schedule.

def scheduled(schedule: TriggerSchedule):

Decorate a strategy method so Investfly invokes it on schedule.

The decorated method receives one ScheduleEvent and may return a list of trade orders, matching the scheduled callback contract on TradingStrategy.