mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-27 17:47:56 +08:00
MAINT/STY: Upgrade flake8 and fix new failures.
This commit is contained in:
@@ -26,12 +26,10 @@ testfixtures==4.1.2
|
||||
|
||||
# Linting
|
||||
|
||||
flake8==2.4.1
|
||||
mccabe==0.3.1
|
||||
# Note: Old version of pep8 required by flake8 2.4.1
|
||||
pep8==1.5.7
|
||||
# Note: Old version of pyflakes required by flake8 2.4.1
|
||||
pyflakes==0.8.1
|
||||
flake8==3.3.0
|
||||
mccabe==0.6.0
|
||||
pycodestyle==2.3.1
|
||||
pyflakes==1.5.0
|
||||
|
||||
# Documentation Conversion
|
||||
|
||||
|
||||
@@ -35,10 +35,10 @@ from zipline.errors import (
|
||||
)
|
||||
|
||||
from zipline.testing.predicates import assert_equal
|
||||
from zipline.utils.calendars import(
|
||||
register_calendar,
|
||||
from zipline.utils.calendars import (
|
||||
deregister_calendar,
|
||||
get_calendar,
|
||||
register_calendar,
|
||||
)
|
||||
from zipline.utils.calendars.calendar_utils import (
|
||||
_default_calendar_aliases,
|
||||
|
||||
@@ -71,6 +71,7 @@ class SomeFactor(Factor):
|
||||
window_length = 5
|
||||
inputs = [SomeDataSet.foo, SomeDataSet.bar]
|
||||
|
||||
|
||||
SomeFactorAlias = SomeFactor
|
||||
|
||||
|
||||
|
||||
@@ -37,5 +37,6 @@ def main():
|
||||
print("Writing %s -> %s" % (symbol, dest))
|
||||
data.to_csv(dest, index_label='day')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
from nose_parameterized import parameterized
|
||||
from six.moves import range
|
||||
|
||||
from zipline.errors import(
|
||||
BadOrderParameters
|
||||
)
|
||||
from zipline.errors import BadOrderParameters
|
||||
from zipline.finance.execution import (
|
||||
LimitOrder,
|
||||
MarketOrder,
|
||||
|
||||
@@ -25,6 +25,7 @@ from zipline.testing.fixtures import (
|
||||
def str_to_ts(dt_str):
|
||||
return pd.Timestamp(dt_str, tz='UTC')
|
||||
|
||||
|
||||
FROZEN = RESTRICTION_STATES.FROZEN
|
||||
ALLOWED = RESTRICTION_STATES.ALLOWED
|
||||
MINUTE = pd.Timedelta(minutes=1)
|
||||
|
||||
+38
-38
@@ -15,6 +15,44 @@
|
||||
import os
|
||||
|
||||
|
||||
# This is *not* a place to dump arbitrary classes/modules for convenience,
|
||||
# it is a place to expose the public interfaces.
|
||||
from . import data
|
||||
from . import finance
|
||||
from . import gens
|
||||
from . import utils
|
||||
from .utils.calendars import get_calendar
|
||||
from .utils.run_algo import run_algorithm
|
||||
from ._version import get_versions
|
||||
|
||||
# These need to happen after the other imports.
|
||||
from . algorithm import TradingAlgorithm
|
||||
from . import api
|
||||
|
||||
|
||||
# PERF: Fire a warning if calendars were instantiated during zipline import.
|
||||
# Having calendars doesn't break anything per-se, but it makes zipline imports
|
||||
# noticeably slower, which becomes particularly noticeable in the Zipline CLI.
|
||||
from zipline.utils.calendars.calendar_utils import global_calendar_dispatcher
|
||||
if global_calendar_dispatcher._calendars:
|
||||
import warnings
|
||||
warnings.warn(
|
||||
"Found TradingCalendar instances after zipline import.\n"
|
||||
"Zipline startup will be much slower until this is fixed!",
|
||||
)
|
||||
del warnings
|
||||
del global_calendar_dispatcher
|
||||
|
||||
|
||||
__version__ = get_versions()['version']
|
||||
del get_versions
|
||||
|
||||
|
||||
def load_ipython_extension(ipython):
|
||||
from .__main__ import zipline_magic
|
||||
ipython.register_magic_function(zipline_magic, 'line_cell', 'zipline')
|
||||
|
||||
|
||||
if os.name == 'nt':
|
||||
# we need to be able to write to our temp directoy on windows so we
|
||||
# create a subdir in %TMP% that has write access and use that as %TMP%
|
||||
@@ -32,44 +70,6 @@ if os.name == 'nt':
|
||||
del _
|
||||
|
||||
|
||||
# This is *not* a place to dump arbitrary classes/modules for convenience,
|
||||
# it is a place to expose the public interfaces.
|
||||
from . import data
|
||||
from . import finance
|
||||
from . import gens
|
||||
from . import utils
|
||||
from .utils.calendars import get_calendar
|
||||
from .utils.run_algo import run_algorithm
|
||||
from ._version import get_versions
|
||||
|
||||
# These need to happen after the other imports.
|
||||
from . algorithm import TradingAlgorithm
|
||||
from . import api
|
||||
|
||||
|
||||
__version__ = get_versions()['version']
|
||||
del get_versions
|
||||
|
||||
|
||||
def load_ipython_extension(ipython):
|
||||
from .__main__ import zipline_magic
|
||||
ipython.register_magic_function(zipline_magic, 'line_cell', 'zipline')
|
||||
|
||||
|
||||
# PERF: Fire a warning if calendars were instantiated during zipline import.
|
||||
# Having calendars doesn't break anything per-se, but it makes zipline imports
|
||||
# noticeably slower, which becomes particularly noticeable in the Zipline CLI.
|
||||
from zipline.utils.calendars.calendar_utils import global_calendar_dispatcher
|
||||
if global_calendar_dispatcher._calendars:
|
||||
import warnings
|
||||
warnings.warn(
|
||||
"Found TradingCalendar instances after zipline import.\n"
|
||||
"Zipline startup will be much slower until this is fixed!",
|
||||
)
|
||||
del warnings
|
||||
del global_calendar_dispatcher
|
||||
|
||||
|
||||
__all__ = [
|
||||
'TradingAlgorithm',
|
||||
'api',
|
||||
|
||||
@@ -1365,6 +1365,7 @@ class PricingDataAssociable(with_metaclass(ABCMeta)):
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
PricingDataAssociable.register(Asset)
|
||||
PricingDataAssociable.register(Future)
|
||||
PricingDataAssociable.register(ContinuousFuture)
|
||||
|
||||
@@ -618,4 +618,5 @@ def _make_bundle_core():
|
||||
|
||||
return BundleCore(bundles, register, unregister, ingest, load, clean)
|
||||
|
||||
|
||||
bundles, register, unregister, ingest, load, clean = _make_bundle_core()
|
||||
|
||||
@@ -805,6 +805,7 @@ class AnnualizedVolatility(CustomFactor):
|
||||
def compute(self, today, assets, out, returns, annualization_factor):
|
||||
out[:] = nanstd(returns, axis=0) * (annualization_factor ** .5)
|
||||
|
||||
|
||||
# Convenience aliases.
|
||||
EWMA = ExponentialWeightedMovingAverage
|
||||
EWMSTD = ExponentialWeightedMovingStdDev
|
||||
|
||||
@@ -55,6 +55,7 @@ class FetcherCSVRedirectError(ZiplineError):
|
||||
|
||||
super(FetcherCSVRedirectError, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
# The following optional arguments are supported for
|
||||
# requests backed data sources.
|
||||
# see http://docs.python-requests.org/en/latest/api/#main-interface
|
||||
@@ -63,7 +64,8 @@ ALLOWED_REQUESTS_KWARGS = {
|
||||
'params',
|
||||
'headers',
|
||||
'auth',
|
||||
'cert'}
|
||||
'cert'
|
||||
}
|
||||
|
||||
|
||||
# The following optional arguments are supported for pandas' read_csv
|
||||
|
||||
@@ -789,6 +789,7 @@ def handle_data_api(context, data):
|
||||
|
||||
record(incr=context.incr)
|
||||
|
||||
|
||||
###########################
|
||||
# AlgoScripts as strings
|
||||
noop_algo = """
|
||||
|
||||
@@ -1142,7 +1142,8 @@ def parameter_space(__fail_fast=False, **params):
|
||||
"supplied to parameter_space()." % extra
|
||||
)
|
||||
|
||||
make_param_sets = lambda: product(*(params[name] for name in argnames))
|
||||
def make_param_sets():
|
||||
return product(*(params[name] for name in argnames))
|
||||
|
||||
if __fail_fast:
|
||||
@wraps(f)
|
||||
|
||||
@@ -5,6 +5,8 @@ from six import viewkeys
|
||||
from six.moves import map, zip
|
||||
from toolz import curry, flip
|
||||
|
||||
from .sentinel import sentinel
|
||||
|
||||
|
||||
@curry
|
||||
def apply(f, *args, **kwargs):
|
||||
@@ -57,8 +59,6 @@ def apply(f, *args, **kwargs):
|
||||
# Alias for use as a class decorator.
|
||||
instance = apply
|
||||
|
||||
from zipline.utils.sentinel import sentinel
|
||||
|
||||
|
||||
def mapall(funcs, seq):
|
||||
"""
|
||||
|
||||
@@ -57,4 +57,6 @@ def sentinel(name, doc=None):
|
||||
|
||||
sentinel._cache[name] = Sentinel # cache result
|
||||
return Sentinel
|
||||
|
||||
|
||||
sentinel._cache = {}
|
||||
|
||||
@@ -266,6 +266,7 @@ def get_non_trading_days(start, end):
|
||||
non_trading_days.sort()
|
||||
return pd.DatetimeIndex(non_trading_days)
|
||||
|
||||
|
||||
non_trading_days = get_non_trading_days(start, end)
|
||||
trading_day = pd.tseries.offsets.CDay(holidays=non_trading_days)
|
||||
|
||||
@@ -275,6 +276,7 @@ def get_trading_days(start, end, trading_day=trading_day):
|
||||
end=end.date(),
|
||||
freq=trading_day).tz_localize('UTC')
|
||||
|
||||
|
||||
trading_days = get_trading_days(start, end)
|
||||
|
||||
|
||||
@@ -384,6 +386,7 @@ def get_early_closes(start, end):
|
||||
early_closes.sort()
|
||||
return pd.DatetimeIndex(early_closes)
|
||||
|
||||
|
||||
early_closes = get_early_closes(start, end)
|
||||
|
||||
|
||||
@@ -420,5 +423,6 @@ def get_open_and_closes(trading_days, early_closes, get_open_and_close):
|
||||
|
||||
return open_and_closes
|
||||
|
||||
|
||||
open_and_closes = get_open_and_closes(trading_days, early_closes,
|
||||
get_open_and_close)
|
||||
|
||||
Reference in New Issue
Block a user