From 795dac9fb36e7256ea60356f90eaeb84dbc532fe Mon Sep 17 00:00:00 2001 From: jjcc Date: Sun, 30 Aug 2020 17:34:34 -0400 Subject: [PATCH] added index_code input as a list instead of a single code string --- opendatatools/swindex/swindex_agent.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/opendatatools/swindex/swindex_agent.py b/opendatatools/swindex/swindex_agent.py index 66bd186..3fd5107 100644 --- a/opendatatools/swindex/swindex_agent.py +++ b/opendatatools/swindex/swindex_agent.py @@ -81,7 +81,13 @@ def get_index_cons(self, index_code): def get_index_daily(self, index_code, start_date, end_date): url = 'http://www.swsindex.com/excel2.aspx?ctable=swindexhistory&where=%s ' - where_cond = " swindexcode in ('%s') and BargainDate >= '%s' and BargainDate <= '%s'" % (index_code, start_date, end_date) + if isinstance(index_code, str): + where_cond = " swindexcode in ('%s') and BargainDate >= '%s' and BargainDate <= '%s'" % (index_code, start_date, end_date) + elif isinstance(index_code,list): + index_code_list = "','".join(index_code) + where_cond = " swindexcode in ('%s') and BargainDate >= '%s' and BargainDate <= '%s'" % (index_code_list, start_date, end_date) + else: + return None, 'Input Error:index_code should be a string or a list of string' url = url % where_cond print(url)