Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_order_limit(self):
self.assertEqual(self.order_package.order_limit(OrderPackageType.PLACE), 200)
self.assertEqual(self.order_package.order_limit(OrderPackageType.CANCEL), 60)
self.assertEqual(self.order_package.order_limit(OrderPackageType.UPDATE), 60)
self.assertEqual(self.order_package.order_limit(OrderPackageType.REPLACE), 60)
def test_order_limit(self):
self.assertEqual(self.order_package.order_limit(OrderPackageType.PLACE), 200)
self.assertEqual(self.order_package.order_limit(OrderPackageType.CANCEL), 60)
self.assertEqual(self.order_package.order_limit(OrderPackageType.UPDATE), 60)
self.assertEqual(self.order_package.order_limit(OrderPackageType.REPLACE), 60)
def handler(self, order_package: BaseOrderPackage):
""" Handles order_package, capable of place, cancel,
replace and update.
"""
http_session = self._get_http_session()
if order_package.package_type == OrderPackageType.PLACE:
func = self.execute_place
elif order_package.package_type == OrderPackageType.CANCEL:
func = self.execute_cancel
elif order_package.package_type == OrderPackageType.UPDATE:
func = self.execute_update
elif order_package.package_type == OrderPackageType.REPLACE:
func = self.execute_replace
else:
raise NotImplementedError()
self._thread_pool.submit(func, order_package, http_session)
def order_limit(cls, package_type: OrderPackageType) -> int:
if package_type == OrderPackageType.PLACE:
return order_limits["placeOrders"]
elif package_type == OrderPackageType.CANCEL:
return order_limits["cancelOrders"]
elif package_type == OrderPackageType.UPDATE:
return order_limits["updateOrders"]
elif package_type == OrderPackageType.REPLACE:
return order_limits["replaceOrders"]
def _validate(self, order_package) -> None:
self._check_hour()
self.total += 1
if order_package.package_type == OrderPackageType.PLACE:
self._check_transaction_count(len(order_package))
self.place_requests += len(order_package)
if not self.safe: # and order.flumine_order_type == "initial"
for order in order_package:
self._on_error(
order,
"Max Order Count has been reached ({0}) for current hour".format(
self.transaction_count
),
)
elif order_package.package_type == OrderPackageType.CANCEL:
self.cancel_requests += len(order_package)
elif order_package.package_type == OrderPackageType.UPDATE:
self.update_requests += len(order_package)
elif order_package.package_type == OrderPackageType.REPLACE:
self.replace_requests += len(order_package)