(self,
sim_params,
data_portal=None,
asset_finder=None,
# Algorithm API
namespace=None,
script=None,
algo_filename=None,
initialize=None,
handle_data=None,
before_trading_start=None,
analyze=None,
#
trading_calendar=None,
metrics_set=None,
blotter=None,
blotter_class=None,
cancel_policy=None,
benchmark_sid=None,
benchmark_returns=None,
platform='zipline',
capital_changes=None,
get_pipeline_loader=None,
create_event_context=None,
**initialize_kwargs)
| 216 | """ |
| 217 | |
| 218 | def __init__(self, |
| 219 | sim_params, |
| 220 | data_portal=None, |
| 221 | asset_finder=None, |
| 222 | # Algorithm API |
| 223 | namespace=None, |
| 224 | script=None, |
| 225 | algo_filename=None, |
| 226 | initialize=None, |
| 227 | handle_data=None, |
| 228 | before_trading_start=None, |
| 229 | analyze=None, |
| 230 | # |
| 231 | trading_calendar=None, |
| 232 | metrics_set=None, |
| 233 | blotter=None, |
| 234 | blotter_class=None, |
| 235 | cancel_policy=None, |
| 236 | benchmark_sid=None, |
| 237 | benchmark_returns=None, |
| 238 | platform='zipline', |
| 239 | capital_changes=None, |
| 240 | get_pipeline_loader=None, |
| 241 | create_event_context=None, |
| 242 | **initialize_kwargs): |
| 243 | # List of trading controls to be used to validate orders. |
| 244 | self.trading_controls = [] |
| 245 | |
| 246 | # List of account controls to be checked on each bar. |
| 247 | self.account_controls = [] |
| 248 | |
| 249 | self._recorded_vars = {} |
| 250 | self.namespace = namespace or {} |
| 251 | |
| 252 | self._platform = platform |
| 253 | self.logger = None |
| 254 | |
| 255 | # XXX: This is kind of a mess. |
| 256 | # We support passing a data_portal in `run`, but we need an asset |
| 257 | # finder earlier than that to look up assets for things like |
| 258 | # set_benchmark. |
| 259 | self.data_portal = data_portal |
| 260 | |
| 261 | if self.data_portal is None: |
| 262 | if asset_finder is None: |
| 263 | raise ValueError( |
| 264 | "Must pass either data_portal or asset_finder " |
| 265 | "to TradingAlgorithm()" |
| 266 | ) |
| 267 | self.asset_finder = asset_finder |
| 268 | else: |
| 269 | # Raise an error if we were passed two different asset finders. |
| 270 | # There's no world where that's a good idea. |
| 271 | if asset_finder is not None \ |
| 272 | and asset_finder is not data_portal.asset_finder: |
| 273 | raise ValueError( |
| 274 | "Inconsistent asset_finders in TradingAlgorithm()" |
| 275 | ) |
nothing calls this directly
no test coverage detected