From 7da72fe9cb6067363915ceafefc8ade0458337e0 Mon Sep 17 00:00:00 2001 From: fredfortier Date: Sat, 4 Nov 2017 16:22:10 -0400 Subject: [PATCH 1/3] BUG: working on issue #55 --- catalyst/support/issue_55.py | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 catalyst/support/issue_55.py diff --git a/catalyst/support/issue_55.py b/catalyst/support/issue_55.py new file mode 100644 index 00000000..bd17af90 --- /dev/null +++ b/catalyst/support/issue_55.py @@ -0,0 +1,42 @@ +import talib +import pandas as pd + +from catalyst import run_algorithm +from catalyst.api import symbol + + +def initialize(context): + print('initializing') + context.asset = symbol('xcp_btc') + + +def handle_data(context, data): + print('handling bar: {}'.format(data.current_dt)) + + price = data.current(context.asset, 'close') + print('got price {price}'.format(price=price)) + + try: + prices = data.history( + context.asset, + fields='price', + bar_count=1, + frequency='1D' + ) + print('got {} price entries'.format(len(prices))) + except Exception as e: + print(e) + + +run_algorithm( + capital_base=1, + start=pd.to_datetime('2015-3-2', utc=True), + end=pd.to_datetime('2017-8-31', utc=True), + data_frequency='daily', + initialize=initialize, + handle_data=handle_data, + analyze=None, + exchange_name='poloniex', + algo_namespace='issue_55', + base_currency='btc' +) From c9c16f54b1a54d3b0c9636f3088ea8113746b65d Mon Sep 17 00:00:00 2001 From: fredfortier Date: Sat, 4 Nov 2017 16:38:54 -0400 Subject: [PATCH 2/3] BUG: fixed on issue #55 with single history bar --- catalyst/exchange/exchange_bundle.py | 2 +- catalyst/support/issue_55.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/catalyst/exchange/exchange_bundle.py b/catalyst/exchange/exchange_bundle.py index a634757d..b5c66d7b 100644 --- a/catalyst/exchange/exchange_bundle.py +++ b/catalyst/exchange/exchange_bundle.py @@ -435,7 +435,7 @@ class ExchangeBundle: if end is None or (last_entry is not None and end > last_entry): end = last_entry - if end is None or start is None or start >= end: + if end is None or start is None or start > end: raise NoDataAvailableOnExchange( exchange=[asset.exchange for asset in assets], symbol=[asset.symbol for asset in assets], diff --git a/catalyst/support/issue_55.py b/catalyst/support/issue_55.py index bd17af90..195f5019 100644 --- a/catalyst/support/issue_55.py +++ b/catalyst/support/issue_55.py @@ -19,11 +19,11 @@ def handle_data(context, data): try: prices = data.history( context.asset, - fields='price', + fields='close', bar_count=1, frequency='1D' ) - print('got {} price entries'.format(len(prices))) + print('got {} price entries\n'.format(len(prices), prices)) except Exception as e: print(e) From d4148891fc99c877a8115999cef7a56471ffa738 Mon Sep 17 00:00:00 2001 From: fredfortier Date: Sat, 4 Nov 2017 16:43:27 -0400 Subject: [PATCH 3/3] DOC: updated release notes prior to release --- docs/source/releases.rst | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/source/releases.rst b/docs/source/releases.rst index 4a01d62c..01b215cb 100644 --- a/docs/source/releases.rst +++ b/docs/source/releases.rst @@ -2,9 +2,18 @@ Release Notes ============= +Version 0.3.6 +^^^^^^^^^^^^^ +**Release Date**: 2017-11-4 + +Bug Fixes +~~~~~~~~~ + +- Fixed an issue with single bar data.history() (:issue:`55`) + Version 0.3.5 ^^^^^^^^^^^^^ -**Release Date**: 2017-11-2 +**Release Date**: 2017-11-4 Bug Fixes ~~~~~~~~~