MCPcopy Index your code
hub / github.com/quantopian/zipline / _create_clock

Method _create_clock

zipline/algorithm.py:489–533  ·  view source on GitHub ↗

If the clock property is not set, then create one based on frequency.

(self)

Source from the content-addressed store, hash-verified

487 recorded_vars=repr(self.recorded_vars))
488
489 def _create_clock(self):
490 """
491 If the clock property is not set, then create one based on frequency.
492 """
493 trading_o_and_c = self.trading_calendar.schedule.loc[
494 self.sim_params.sessions]
495 market_closes = trading_o_and_c['market_close']
496 minutely_emission = False
497
498 if self.sim_params.data_frequency == 'minute':
499 market_opens = trading_o_and_c['market_open']
500 minutely_emission = self.sim_params.emission_rate == "minute"
501
502 # The calendar's execution times are the minutes over which we
503 # actually want to run the clock. Typically the execution times
504 # simply adhere to the market open and close times. In the case of
505 # the futures calendar, for example, we only want to simulate over
506 # a subset of the full 24 hour calendar, so the execution times
507 # dictate a market open time of 6:31am US/Eastern and a close of
508 # 5:00pm US/Eastern.
509 execution_opens = \
510 self.trading_calendar.execution_time_from_open(market_opens)
511 execution_closes = \
512 self.trading_calendar.execution_time_from_close(market_closes)
513 else:
514 # in daily mode, we want to have one bar per session, timestamped
515 # as the last minute of the session.
516 execution_closes = \
517 self.trading_calendar.execution_time_from_close(market_closes)
518 execution_opens = execution_closes
519
520 # FIXME generalize these values
521 before_trading_start_minutes = days_at_time(
522 self.sim_params.sessions,
523 time(8, 45),
524 "US/Eastern"
525 )
526
527 return MinuteSimulationClock(
528 self.sim_params.sessions,
529 execution_opens,
530 execution_closes,
531 before_trading_start_minutes,
532 minute_emission=minutely_emission,
533 )
534
535 def _create_benchmark_source(self):
536 if self.benchmark_sid is not None:

Callers 1

_create_generatorMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected