diff --git a/.travis.yml b/.travis.yml index f65cd46c..443db91e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,6 @@ install: - cat etc/requirements_dev.txt | grep -v "^#" | grep -v "^$" | grep -v ipython | grep -v nose | xargs pip install - etc/ordered_pip.sh etc/requirements.txt before_script: - - "flake8 --ignore=E124,E125,E126 zipline tests" + - "flake8 zipline tests" script: - nosetests diff --git a/README.md b/README.md index 6072c8e2..db09a054 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ The maintainers check the code using the flake8 script, requirements_dev.txt. Before submitting patches or pull requests, please ensure that your -changes pass ```flake8 --ignore=E124,E125,E126 zipline tests``` +changes pass ```flake8 zipline tests``` Discussion and Help =================== diff --git a/docs/contributing.rst b/docs/contributing.rst index d60d5af0..d99ae9e6 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -18,7 +18,7 @@ changes pass :: - flake8 --ignore=E124,E125,E126 zipline tests + flake8 zipline tests Discussion and Help =================== diff --git a/tests/test_finance.py b/tests/test_finance.py index 28a66f59..22dbc23f 100644 --- a/tests/test_finance.py +++ b/tests/test_finance.py @@ -31,9 +31,9 @@ from zipline.finance.performance import PerformanceTracker from zipline.utils.protocol_utils import ndict from zipline.finance.trading import TransactionSimulator from zipline.utils.test_utils import( - setup_logger, - teardown_logger, - assert_single_position + setup_logger, + teardown_logger, + assert_single_position ) DEFAULT_TIMEOUT = 15 # seconds diff --git a/tests/test_perf_tracking.py b/tests/test_perf_tracking.py index 5e1a1858..4435b780 100644 --- a/tests/test_perf_tracking.py +++ b/tests/test_perf_tracking.py @@ -126,8 +126,8 @@ check treasury and benchmark data in findb, and re-run the test.""" trades[-1]['price'], "last sale should be same as last trade. \ expected {exp} actual {act}".format( - exp=trades[-1]['price'], - act=pp.positions[1].last_sale_price) + exp=trades[-1]['price'], + act=pp.positions[1].last_sale_price) ) self.assertEqual( @@ -565,7 +565,7 @@ shares in position" 'price', 'changed'] perf_tracker = perf.PerformanceTracker( - self.trading_environment + self.trading_environment ) for event in trade_history: diff --git a/tests/test_risk.py b/tests/test_risk.py index 2c43410f..42a18863 100644 --- a/tests/test_risk.py +++ b/tests/test_risk.py @@ -763,12 +763,11 @@ class Risk(unittest.TestCase): "mismatch for total months - \ expected:{total_months}/actual:{actual}, \ period:{period_length}, start:{start_date}, \ - calculated end:{end}".format( - total_months=total_months, - period_length=period_length, - start_date=start_date, - end=col[-1].end_date, - actual=len(col)) + calculated end:{end}".format(total_months=total_months, + period_length=period_length, + start_date=start_date, + end=col[-1].end_date, + actual=len(col)) ) self.assert_month(start_date.month, col[-1].end_date.month) self.assert_last_day(col[-1].end_date) diff --git a/tests/test_transforms.py b/tests/test_transforms.py index 8c979095..0a44f5f1 100644 --- a/tests/test_transforms.py +++ b/tests/test_transforms.py @@ -332,18 +332,18 @@ class TestBatchTransform(TestCase): for test_history in [algo.history_return_price_class, algo.history_return_price_decorator]: np.testing.assert_array_equal( - range(2, 8), - test_history[2].values.flatten() + range(2, 8), + test_history[2].values.flatten() ) np.testing.assert_array_equal( - range(2, 8), - test_history[3].values.flatten() + range(2, 8), + test_history[3].values.flatten() ) np.testing.assert_array_equal( - range(4, 12), - test_history[4].values.flatten() + range(4, 12), + test_history[4].values.flatten() ) def test_passing_of_args(self): diff --git a/zipline/algorithm.py b/zipline/algorithm.py index 47386f0c..463851a9 100644 --- a/zipline/algorithm.py +++ b/zipline/algorithm.py @@ -24,9 +24,9 @@ from zipline.sources import DataFrameSource from zipline.utils.factory import create_trading_environment from zipline.transforms.utils import StatefulTransform from zipline.finance.slippage import ( - VolumeShareSlippage, - FixedSlippage, - transact_partial + VolumeShareSlippage, + FixedSlippage, + transact_partial ) from zipline.finance.commission import PerShare, PerTrade diff --git a/zipline/finance/performance.py b/zipline/finance/performance.py index a65f4dd6..98e2ac8d 100644 --- a/zipline/finance/performance.py +++ b/zipline/finance/performance.py @@ -389,13 +389,13 @@ class Position(object): class PerformancePeriod(object): def __init__( - self, - initial_positions, - starting_value, - starting_cash, - period_open=None, - period_close=None, - keep_transactions=False): + self, + initial_positions, + starting_value, + starting_cash, + period_open=None, + period_close=None, + keep_transactions=False): self.period_open = period_open self.period_close = period_close diff --git a/zipline/finance/risk.py b/zipline/finance/risk.py index 9260b9f3..b03471d6 100644 --- a/zipline/finance/risk.py +++ b/zipline/finance/risk.py @@ -107,8 +107,8 @@ class RiskMetricsBase(object): self.calculate_period_returns(returns) benchmark_returns = [ - x for x in self.trading_environment.benchmark_returns - if x.date >= returns[0].date and x.date <= returns[-1].date + x for x in self.trading_environment.benchmark_returns + if x.date >= returns[0].date and x.date <= returns[-1].date ] self.benchmark_period_returns, self.benchmark_returns = \ @@ -382,8 +382,8 @@ class RiskMetricsIterative(RiskMetricsBase): self.trading_days = 0 self.all_benchmark_returns = [ - x for x in self.trading_environment.benchmark_returns - if x.date >= self.start_date + x for x in self.trading_environment.benchmark_returns + if x.date >= self.start_date ] def update(self, returns_in_period): diff --git a/zipline/finance/slippage.py b/zipline/finance/slippage.py index ef312ee8..8c5d410e 100644 --- a/zipline/finance/slippage.py +++ b/zipline/finance/slippage.py @@ -42,11 +42,12 @@ def transact_partial(slippage, commission): def create_transaction(sid, amount, price, dt): - txn = {'sid': sid, - 'amount': int(amount), - 'dt': dt, - 'price': price, - } + txn = { + 'sid': sid, + 'amount': int(amount), + 'dt': dt, + 'price': price, + } transaction = ndict(txn) return transaction diff --git a/zipline/gens/utils.py b/zipline/gens/utils.py index 94e6985a..8f8105cf 100644 --- a/zipline/gens/utils.py +++ b/zipline/gens/utils.py @@ -37,11 +37,11 @@ def mock_raw_event(sid, dt): def mock_done(id): return ndict({ - 'dt': "DONE", - "source_id": id, - 'tnfm_id': id, - 'tnfm_value': None, - 'type': DATASOURCE_TYPE.DONE + 'dt': "DONE", + "source_id": id, + 'tnfm_id': id, + 'tnfm_value': None, + 'type': DATASOURCE_TYPE.DONE }) done_message = mock_done diff --git a/zipline/sources.py b/zipline/sources.py index eafb01e3..245c184c 100644 --- a/zipline/sources.py +++ b/zipline/sources.py @@ -242,9 +242,10 @@ class DataFrameSource(SpecificEquityTrades): for dt, series in df.iterrows(): if (dt < self.start) or (dt > self.end): continue - event = {'dt': dt, - 'source_id': self.get_hash(), - 'type': DATASOURCE_TYPE.TRADE + event = { + 'dt': dt, + 'source_id': self.get_hash(), + 'type': DATASOURCE_TYPE.TRADE } for sid, price in series.iterkv(): diff --git a/zipline/transforms/__init__.py b/zipline/transforms/__init__.py index f34cc5f2..4e7d56e9 100644 --- a/zipline/transforms/__init__.py +++ b/zipline/transforms/__init__.py @@ -19,10 +19,11 @@ from vwap import MovingVWAP from returns import Returns from utils import BatchTransform, batch_transform -__all__ = ['MovingAverage', - 'MovingStandardDev', - 'MovingVWAP', - 'Returns', - 'BatchTransform', - 'batch_transform' +__all__ = [ + 'MovingAverage', + 'MovingStandardDev', + 'MovingVWAP', + 'Returns', + 'BatchTransform', + 'batch_transform' ]