def require_not_initialized(exception):
 def decorator(method):
  @wraps(method)
  def wrapped_method(self, *args, **kwargs):
   if self.initialized:
    raise exception
   return method(self, *args, **kwargs)
  return wrapped_method
 return decorator

def require_not_initialized ( exception ) : def decorator ( method ) : @ wraps ( method ) def wrapped_method ( self , * args , ** kwargs ) : if self . initialized : raise exception return method ( self , * args , ** kwargs ) return wrapped_method return decorator
decorator for api methods that should only be called during or before tradingalgorithm .