本文整理汇总了Python中zipline.TradingAlgorithm.all_api_methods方法的典型用法代码示例。如果您正苦于以下问题:Python TradingAlgorithm.all_api_methods方法的具体用法?Python TradingAlgorithm.all_api_methods怎么用?Python TradingAlgorithm.all_api_methods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zipline.TradingAlgorithm
的用法示例。
在下文中一共展示了TradingAlgorithm.all_api_methods方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from zipline import TradingAlgorithm [as 别名]
# 或者: from zipline.TradingAlgorithm import all_api_methods [as 别名]
def main():
with open(api.__file__.rstrip('c') + 'i', 'w') as stub:
# Imports so that Asset et al can be resolved.
# "from MOD import *" will re-export the imports from the stub, so
# explicitly importing.
stub.write(dedent("""\
from zipline.assets import Asset, Equity, Future
from zipline.assets.futures import FutureChain
from zipline.finance.cancel_policy import CancelPolicy
from zipline.pipeline import Pipeline
from zipline.protocol import Order
from zipline.utils.events import EventRule
"""))
# Sort to generate consistent stub file:
for api_func in sorted(TradingAlgorithm.all_api_methods(),
key=attrgetter('__name__')):
sig = inspect._signature_bound_method(inspect.signature(api_func))
indent = ' ' * 4
stub.write(dedent('''\
def {func_name}{func_sig}:
"""'''.format(func_name=api_func.__name__,
func_sig=sig)))
stub.write(dedent('{indent}{func_doc}'.format(
func_doc=api_func.__doc__ or '\n', # handle None docstring
indent=indent,
)))
stub.write('{indent}"""\n\n'.format(indent=indent))