Skip to content

Commit

Permalink
Merge branch 'benchmark' into benchmark2
Browse files Browse the repository at this point in the history
* benchmark:
  STY: Flake8 style amendments
  • Loading branch information
samatix committed Apr 20, 2020
2 parents 7651c05 + b32f554 commit 1da88f8
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
6 changes: 4 additions & 2 deletions tests/test_benchmark.py
Expand Up @@ -398,11 +398,13 @@ def test_benchmark_file(self):
self.assertIs(sid, None)

expected_dates = pd.to_datetime(
['2020-01-03', '2020-01-06', '2020-01-07', '2020-01-08', '2020-01-09'],
['2020-01-03', '2020-01-06', '2020-01-07',
'2020-01-08', '2020-01-09'],
utc=True,
)
expected_values = [-0.1, 0.333, 0.167, 0.143, 6.375]
expected_returns = pd.Series(index=expected_dates, data=expected_values)
expected_returns = pd.Series(index=expected_dates,
data=expected_values)

assert_series_equal(returns, expected_returns, check_names=False)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_cmdline.py
Expand Up @@ -145,7 +145,7 @@ def test_benchmark_argument_handling(self):

# CLI validates that the algo file exists, so create an empty file.
algo_path = self.tmpdir.getpath('dummy_algo.py')
with open(algo_path, 'w') as f:
with open(algo_path, 'w'):
pass

def run_and_get_benchmark_spec(benchmark_args):
Expand All @@ -170,7 +170,8 @@ def run_and_get_benchmark_spec(benchmark_args):
raise AssertionError(
"Cli run failed with {exc}\n\n"
"Output was:\n\n"
"{output}".format(exc=result.exception, output=result.output),
"{output}".format(exc=result.exception,
output=result.output),
)

mock_run.assert_called_once()
Expand Down Expand Up @@ -209,7 +210,7 @@ def run_and_get_benchmark_spec(benchmark_args):

# CLI also validates the returns file exists.
bm_path = self.tmpdir.getpath('returns.csv')
with open(bm_path, 'w') as f:
with open(bm_path, 'w'):
pass

spec = run_and_get_benchmark_spec(['--benchmark-file', bm_path])
Expand All @@ -218,4 +219,3 @@ def run_and_get_benchmark_spec(benchmark_args):
assert_equal(spec.benchmark_sid, None)
assert_equal(spec.benchmark_symbol, None)
assert_equal(spec.no_benchmark, False)

2 changes: 0 additions & 2 deletions tests/test_examples.py
Expand Up @@ -21,7 +21,6 @@
import pandas as pd

from zipline import examples
from zipline.data.benchmarks import get_benchmark_returns_from_file
from zipline.data.bundles import register, unregister
from zipline.testing import test_resource_path
from zipline.testing.fixtures import (
Expand All @@ -31,7 +30,6 @@
)
from zipline.testing.predicates import assert_equal
from zipline.utils.cache import dataframe_cache
from zipline.utils.paths import update_modified_time


# Otherwise the next line sometimes complains about being run too late.
Expand Down
3 changes: 2 additions & 1 deletion zipline/data/benchmarks.py
Expand Up @@ -42,7 +42,8 @@ def get_benchmark_returns_from_file(filelike):
).tz_localize('utc')

if 'return' not in df.columns:
raise ValueError("The column 'return' not found in the benchmark file \n"
raise ValueError("The column 'return' not found in the "
"benchmark file \n"
"Expected benchmark file format :\n"
"date, return\n"
"2020-01-02 00:00:00+00:00,0.01\n"
Expand Down
1 change: 0 additions & 1 deletion zipline/data/loader.py
Expand Up @@ -14,7 +14,6 @@
# limitations under the License.
import os

import logbook
import pandas as pd


Expand Down
3 changes: 2 additions & 1 deletion zipline/examples/__init__.py
Expand Up @@ -63,7 +63,8 @@ def load_example_modules():
]


def run_example(example_modules, example_name, environ, benchmark_returns=None):
def run_example(example_modules, example_name, environ,
benchmark_returns=None):
"""
Run an example module from zipline.examples.
"""
Expand Down
1 change: 0 additions & 1 deletion zipline/finance/metrics/metric.py
Expand Up @@ -458,7 +458,6 @@ def end_of_bar(self,
if np.isnan(beta):
beta = None


risk['alpha'] = alpha
risk['beta'] = beta

Expand Down

0 comments on commit 1da88f8

Please sign in to comment.