MCPcopy Create free account
hub / github.com/quantopian/zipline / get_environment

Method get_environment

zipline/algorithm.py:732–786  ·  view source on GitHub ↗

Query the execution environment. Parameters ---------- field : {'platform', 'arena', 'data_frequency', 'start', 'end', 'capital_base', 'platform', '*'} The field to query. The options have the following meanings: arena : str

(self, field='platform')

Source from the content-addressed store, hash-verified

730
731 @api_method
732 def get_environment(self, field='platform'):
733 """Query the execution environment.
734
735 Parameters
736 ----------
737 field : {'platform', 'arena', 'data_frequency',
738 'start', 'end', 'capital_base', 'platform', '*'}
739 The field to query. The options have the following meanings:
740 arena : str
741 The arena from the simulation parameters. This will normally
742 be ``'backtest'`` but some systems may use this distinguish
743 live trading from backtesting.
744 data_frequency : {'daily', 'minute'}
745 data_frequency tells the algorithm if it is running with
746 daily data or minute data.
747 start : datetime
748 The start date for the simulation.
749 end : datetime
750 The end date for the simulation.
751 capital_base : float
752 The starting capital for the simulation.
753 platform : str
754 The platform that the code is running on. By default this
755 will be the string 'zipline'. This can allow algorithms to
756 know if they are running on the Quantopian platform instead.
757 * : dict[str -> any]
758 Returns all of the fields in a dictionary.
759
760 Returns
761 -------
762 val : any
763 The value for the field queried. See above for more information.
764
765 Raises
766 ------
767 ValueError
768 Raised when ``field`` is not a valid option.
769 """
770 env = {
771 'arena': self.sim_params.arena,
772 'data_frequency': self.sim_params.data_frequency,
773 'start': self.sim_params.first_open,
774 'end': self.sim_params.last_close,
775 'capital_base': self.sim_params.capital_base,
776 'platform': self._platform
777 }
778 if field == '*':
779 return env
780 else:
781 try:
782 return env[field]
783 except KeyError:
784 raise ValueError(
785 '%r is not a valid field for get_environment' % field,
786 )
787
788 @api_method
789 def fetch_csv(self,

Callers 1

initializeMethod · 0.80

Calls

no outgoing calls

Tested by 1

initializeMethod · 0.64