forked from scrtlabs/catalyst
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV: Adds type hinting stub for zipline.api
as well as tooling and docs to generate this for each release Also moved Cython files to package_data, so that we install them, instead of just packaging them.
- Loading branch information
1 parent
977e557
commit b9b4dc0
Showing
5 changed files
with
761 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import inspect | ||
from operator import attrgetter | ||
from textwrap import dedent | ||
|
||
from zipline import api, TradingAlgorithm | ||
|
||
|
||
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)) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,9 +270,13 @@ def setup_requirements(requirements_path, module_names, strict_bounds, | |
}, | ||
author='Quantopian Inc.', | ||
author_email='[email protected]', | ||
packages=find_packages('.', include=['zipline', 'zipline.*']), | ||
packages=find_packages(include=['zipline', 'zipline.*']), | ||
ext_modules=ext_modules, | ||
include_package_data=True, | ||
package_data={root.replace(os.sep, '.'): | ||
['*.pyi', '*.pyx', '*.pxi', '*.pxd'] | ||
for root, dirnames, filenames in os.walk('zipline') | ||
if '__pycache__' not in root}, | ||
license='Apache 2.0', | ||
classifiers=[ | ||
'Development Status :: 4 - Beta', | ||
|
Oops, something went wrong.