mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-02 04:06:08 +08:00
ENH: Add a classmethod to TradingAlgorithm to get all API methods.
This commit is contained in:
@@ -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)]
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user