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

Method validate_order_params

zipline/algorithm.py:1309–1342  ·  view source on GitHub ↗

Helper method for validating parameters to the order API function. Raises an UnsupportedOrderParameters if invalid arguments are found.

(self,
                              asset,
                              amount,
                              limit_price,
                              stop_price,
                              style)

Source from the content-addressed store, hash-verified

1307 return int(round_if_near_integer(amount))
1308
1309 def validate_order_params(self,
1310 asset,
1311 amount,
1312 limit_price,
1313 stop_price,
1314 style):
1315 """
1316 Helper method for validating parameters to the order API function.
1317
1318 Raises an UnsupportedOrderParameters if invalid arguments are found.
1319 """
1320
1321 if not self.initialized:
1322 raise OrderDuringInitialize(
1323 msg="order() can only be called from within handle_data()"
1324 )
1325
1326 if style:
1327 if limit_price:
1328 raise UnsupportedOrderParameters(
1329 msg="Passing both limit_price and style is not supported."
1330 )
1331
1332 if stop_price:
1333 raise UnsupportedOrderParameters(
1334 msg="Passing both stop_price and style is not supported."
1335 )
1336
1337 for control in self.trading_controls:
1338 control.validate(asset,
1339 amount,
1340 self.portfolio,
1341 self.get_datetime(),
1342 self.trading_client.current_data)
1343
1344 @staticmethod
1345 def __convert_order_params_for_blotter(asset,

Callers 1

_calculate_orderMethod · 0.95

Calls 4

get_datetimeMethod · 0.95
validateMethod · 0.45

Tested by

no test coverage detected