ENH: Add a classmethod to TradingAlgorithm to get all API methods.

This commit is contained in:
Scott Sanderson
2014-05-14 11:06:58 -04:00
parent c045f3a868
commit c3075f0ece
2 changed files with 9 additions and 1 deletions
+8
View File
@@ -881,3 +881,11 @@ class TradingAlgorithm(object):
Set a rule specifying that this algorithm cannot take short positions.
"""
self.register_trading_control(LongOnly())
@classmethod
def all_api_methods(cls):
"""
Return a list of all the TradingAlgorithm API methods.
"""
return [fn for fn in cls.__dict__.itervalues()
if getattr(fn, 'is_api_method', False)]
+1 -1
View File
@@ -61,5 +61,5 @@ def api_method(f):
# Add functor to zipline.api
setattr(zipline.api, f.__name__, wrapped)
zipline.api.__all__.append(f.__name__)
f.is_api_method = True
return f