From da89cec532efb3697afa67c942feef124a47a6b0 Mon Sep 17 00:00:00 2001 From: simongarisch Date: Fri, 12 Jul 2019 06:16:27 +1000 Subject: [PATCH 1/4] Adding .pytest_cache to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d1eadd9..5cb44a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Byte-compiled / optimized / DLL files __pycache__/ +.pytest_cache/ *.py[cod] # C extensions From 262b0f8cdfb29cfbcef1c79e998168894d6d46d6 Mon Sep 17 00:00:00 2001 From: simongarisch Date: Sun, 14 Jul 2019 07:03:40 +1000 Subject: [PATCH 2/4] Keeping the timezones consistent in trading_days vs start and end. --- prophet/app.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/prophet/app.py b/prophet/app.py index db3fffa..4d12596 100644 --- a/prophet/app.py +++ b/prophet/app.py @@ -1,4 +1,5 @@ import datetime as dt +import pandas as pd from prophet.analyze import Analysis from prophet.portfolio import Portfolio @@ -57,8 +58,10 @@ def run_backtest(self, raise ProphetException("Must set an order generator by calling" "set_order_generator.") - timestamps = trading_days[(trading_days >= start) & - (trading_days <= end)] + start_utc = pd.to_datetime(start, utc=True) + end_utc = pd.to_datetime(end, utc=True) + timestamps = trading_days[(trading_days >= start_utc) & + (trading_days <= end_utc)] effective_start = timestamps[0] data = self._generate_data(start=effective_start, From 810191db25f329b4e1ea3b24e36c50941791814b Mon Sep 17 00:00:00 2001 From: simongarisch Date: Sun, 14 Jul 2019 07:05:29 +1000 Subject: [PATCH 3/4] Removing tz info before passing date to yahoo. --- prophet/data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prophet/data.py b/prophet/data.py index 438b10b..3732047 100644 --- a/prophet/data.py +++ b/prophet/data.py @@ -41,7 +41,7 @@ def __init__(self, cache_path=None, data_path=None): data_path=data_path) def run(self, data, start, end, symbols, source, lookback=0): - data_start = self.get_data_start(start, lookback) + data_start = self.get_data_start(start, lookback).replace(tzinfo=None) # Current caching implementation based on Zipline symbols_data = dict() From 8ef40c481908c66c64d98dd49f5af573d166e606 Mon Sep 17 00:00:00 2001 From: simongarisch Date: Sun, 14 Jul 2019 07:05:59 +1000 Subject: [PATCH 4/4] Minor adjustment of values --- tests/integration/test_examples.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/test_examples.py b/tests/integration/test_examples.py index 6fb7dfc..d32a3e4 100644 --- a/tests/integration/test_examples.py +++ b/tests/integration/test_examples.py @@ -33,10 +33,10 @@ def test_quickstart(): prophet.register_portfolio_analyzers(default_analyzers) analysis = prophet.analyze_backtest(backtest) - assert round(analysis['sharpe'], 10) == 1.1083876014 - assert round(analysis['average_return'], 10) == 0.0010655311 - assert round(analysis['cumulative_return'], 10) == 2.2140809296 - assert round(analysis['volatility'], 10) == 0.0152607097 + assert round(analysis['sharpe'], 10) == 1.0967430073 + assert round(analysis['average_return'], 10) == 0.0010501702 + assert round(analysis['cumulative_return'], 10) == 2.1604345132 + assert round(analysis['volatility'], 10) == 0.0152004028 today = datetime(2014, 11, 10) expected_orders = Orders(Order(symbol='AAPL', shares=100))