trader.daemon.schedule module¶
Turning the market clock into an action.
Pure: a MarketClock and a now in, a decision out. The loop does the sleeping, so every case here is an equality assertion in a test rather than a stopwatch.
- class trader.daemon.schedule.MarketSchedule(config)[source]¶
Bases:
objectDecides only the market-state wait.
Deliberately not the other two waits in this system: the gap between cycles of an open market belongs to the loop, and the delay after a failure belongs to Backoff. Three sleeps with three owners means no test has to work out which one produced a duration.
- Parameters:
config (DaemonConfig)
- next_action(clock, now)[source]¶
Run now if the market is open, otherwise wait for the open.
Branches on is_open rather than comparing now against the timestamps: while the market is open, next_open is tomorrow’s session, so inferring the state from the timestamps would read an open market as one that opens in 20 hours.
- Parameters:
clock (MarketClock)
now (datetime)
- Return type: