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

def disallowed_in_before_trading_start ( exception ) : def decorator ( method ) : @ wraps ( method ) def wrapped_method ( self , * args , ** kwargs ) : if self . _in_before_trading_start : raise exception return method ( self , * args , ** kwargs ) return wrapped_method return decorator
decorator for api methods that cannot be called from within tradingalgorithm .